← 返回首页 ❓ 面试题库
📑 本篇章节导航 (共5章,点击直达)
一、GitOps原理(1-8)二、ArgoCD核心架构(9-20)三、ArgoCD高级特性(21-32)四、GitOps生产实践(33-42)五、面试综合设计题(43-50)

Q68 - GitOps与ArgoCD深度实战

共50道题 | 难度分布:★★★★☆平均 | 20K+ DevOps/云原生岗位必考

一、GitOps原理(1-8)

GitOps的定义与核心原则?

★★★★★

1. 声明式:系统描述是声明式的(YAML/HCL)。

2. 版本控制:所有配置存储在Git中,有完整历史。

3. 自动拉取:系统自动从Git拉取并应用变更。

4. 持续协调:软件Agent持续对比期望状态和实际状态。

GitOps Push vs Pull模式?

★★★★★

GitOps的工作流程?

★★★★☆

1. 开发者修改代码 → 提交PR。

2. CI流水线:构建镜像 → 推送到Registry → 运行测试。

3. CI更新GitOps仓库中的镜像Tag(自动化commit)。

4. ArgoCD检测到Git变更 → 自动同步到K8s集群。

5. ArgoCD报告部署状态。

GitOps仓库结构设计?

★★★★☆


gitops/
├── base/            # 基础配置
│   ├── deployment.yaml
│   └── service.yaml
├── overlays/
│   ├── staging/     # 测试环境覆盖
│   └── production/  # 生产环境覆盖
└── apps/            # ArgoCD Application定义

GitOps的回滚策略?

★★★★★

GitOps的密钥管理?

★★★★★

GitOps与基础设施即代码?

★★★★☆

GitOps的局限性?

★★★★☆


二、ArgoCD核心架构(9-20)

ArgoCD的架构?

★★★★★

1. Application Controller定期轮询Git仓库。

2. 检测到变更 → 渲染模板 → 对比K8s实际状态。

3. 如果有差异(Drift) → 根据Sync Policy决定是否自动同步。

4. 执行同步 → 创建/更新/删除K8s资源。

ArgoCD Application概念?

★★★★★


apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: payment-service
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/org/gitops.git
    targetRevision: main
    path: apps/payment-service
  destination:
    server: https://kubernetes.default.svc
    namespace: payment
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

ArgoCD Sync策略?

★★★★★

ArgoCD的同步状态?

★★★★☆

ArgoCD Project?

★★★★☆


apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
  name: team-payments
spec:
  sourceRepos:
  - 'https://github.com/org/payment-*'
  destinations:
  - namespace: 'payment-*'
    server: '*'
  clusterResourceWhitelist:
  - group: ''
    kind: Namespace

ArgoCD多集群管理?

★★★★☆


destination:
  server: https://cluster-api-address
  namespace: production

destination:
  name: production-cluster
  namespace: production

ArgoCD与Kustomize?

★★★★☆


source:
  repoURL: ...
  path: overlays/production
  kustomize:
    images:
    - myapp=registry/myapp:v2.0.0

ArgoCD与Helm?

★★★★☆

1. Helm Chart仓库:source.chart: my-chart。

2. Git仓库中的Helm Chart:source.path: charts/my-chart。

3. Helm + Kustomize组合:先Helm渲染再Kustomize覆盖。


source:
  helm:
    valueFiles:
    - values.yaml
    - values-prod.yaml
    parameters:
    - name: image.tag
      value: v2.0.0

ArgoCD的RBAC?

★★★★☆

ArgoCD的SSO集成?

★★★★☆

1. 在Provider注册OAuth App。

2. 配置argocd-cm中的oidc.config或dex.config。

3. 配置RBAC映射Group到Role。

ArgoCD的Resource Hook?

★★★★☆


metadata:
  annotations:
    argocd.argoproj.io/hook: PreSync

ArgoCD Notifications?

★★★★☆


三、ArgoCD高级特性(21-32)

ApplicationSet?

★★★★★


apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: payment-service
spec:
  generators:
  - clusters: {}
  template:
    spec:
      source:
        repoURL: https://github.com/org/gitops.git
        path: apps/payment-service
      destination:
        server: '{{server}}'
        namespace: payment

ArgoCD的Progressive Delivery?

★★★★☆

Argo Rollouts Canary策略?

★★★★★


spec:
  strategy:
    canary:
      steps:
      - setWeight: 10
      - pause: {duration: 5m}
      - setWeight: 30
      - pause: {duration: 5m}
      - setWeight: 50
      - analysis:
          templates:
          - templateName: success-rate
      - setWeight: 100

Argo Rollouts Analysis Template?

★★★★☆


apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
  name: success-rate
spec:
  metrics:
  - name: success-rate
    provider:
      prometheus:
        query: |
          sum(rate(http_requests_total{status!~"5.."}[5m]))
          / sum(rate(http_requests_total[5m]))
    successCondition: result[0] >= 0.99

ArgoCD的Resource Diff?

★★★★☆


ignoreDifferences:
- group: apps
  kind: Deployment
  jsonPointers:
  - /spec/replicas

ArgoCD的缓存与性能?

★★★★☆

ArgoCD的高可用部署?

★★★★☆

ArgoCD与CI流水线集成?

★★★★☆

ArgoCD Image Updater?

★★★★☆


annotations:
  argocd-image-updater.argoproj.io/image-list: myapp=registry/myapp
  argocd-image-updater.argoproj.io/myapp.update-strategy: semver
  argocd-image-updater.argoproj.io/myapp.allow-tags: regexp:^v\d+\.\d+\.\d+$

ArgoCD的灾难恢复?

★★★★☆


apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: apps
spec:
  source:
    repoURL: https://github.com/org/gitops.git
    path: argocd-apps

ArgoCD vs Flux?

★★★★★

ArgoCD的安全最佳实践?

★★★★☆


四、GitOps生产实践(33-42)

GitOps分支策略?

★★★★☆

GitOps的Code Review策略?

★★★★☆

GitOps的Drift Detection?

★★★★☆

GitOps与数据库迁移?

★★★★☆


annotations:
  argocd.argoproj.io/hook: PreSync

GitOps的监控告警?

★★★★☆

多环境GitOps管理?

★★★★☆

GitOps的灾备与多活?

★★★★☆

GitOps的合规与审计?

★★★★☆

GitOps的性能基准?

★★★★☆

GitOps常见故障排查?

★★★★☆


五、面试综合设计题(43-50)

设计一个完整的GitOps CI/CD流水线?

★★★★★

1. GitHub/GitLab:代码仓库 + GitOps配置仓库。

2. GitHub Actions/Jenkins:CI(构建+测试+推送镜像)。

3. ArgoCD:CD(GitOps持续部署)。

4. Argo Rollouts:渐进式发布(Canary + Analysis)。

5. Prometheus + Grafana:监控。

1. 开发者提交代码 → CI构建镜像 → 推送到Registry。

2. CI更新GitOps仓库中的镜像Tag。

3. ArgoCD检测变更 → 渲染模板 → 同步到K8s。

4. Argo Rollouts执行Canary发布 → Analysis检查指标。

5. 成功 → 全量发布;失败 → 自动回滚。

ArgoCD + Backstage集成方案?

★★★★☆

1. 安装@backstage/plugin-argo-cd插件。

2. 配置ArgoCD API连接。

3. 通过Annotation关联Component和ArgoCD Application。


annotations:
  argocd/app-name: payment-service

设计ArgoCD多集群部署方案?

★★★★★

GitOps与微服务部署策略?

★★★★☆

设计GitOps的安全合规方案?

★★★★★

1. Git层:分支保护、PR Review、Signed Commit。

2. ArgoCD层:SSO + RBAC + Project隔离。

3. K8s层:OPA Gatekeeper/kyverno策略 + Network Policy。

4. 密钥层:External Secrets Operator + Vault。

5. 镜像层:镜像签名(Cosign)+ 漏洞扫描(Trivy)。

ArgoCD的运维SOP?

★★★★☆

1. 测试环境先升级ArgoCD。

2. 验证所有Application正常。

3. 生产环境升级。

4. 升级后验证。

1. ArgoCD不可用 → 检查Pod状态 → 检查数据库。

2. Application持续OutOfSync → 检查Git仓库 → 检查Repo Server。

从零搭建GitOps平台?

★★★★★

GitOps面试架构设计题:设计一个支持100+微服务的GitOps平台?

★★★★★

1. App of Apps模式:顶层Application管理所有服务。

2. ApplicationSet + Git Directory Generator:自动发现新服务。

3. Kustomize Overlays:环境差异管理。

4. ArgoCD HA:3副本Server + 3副本Repo Server + PostgreSQL。

5. Argo Rollouts:Canary发布 + Prometheus Analysis。

6. External Secrets:Vault集成。

7. OPA Gatekeeper:策略即代码。

8. ArgoCD Notifications:统一告警。