共50道题 | 难度分布:★★★★☆平均 | 20K+ DevOps/云原生岗位必考
★★★★★
1. 声明式:系统描述是声明式的(YAML/HCL)。
2. 版本控制:所有配置存储在Git中,有完整历史。
3. 自动拉取:系统自动从Git拉取并应用变更。
4. 持续协调:软件Agent持续对比期望状态和实际状态。
★★★★★
kubectl apply推送到集群。★★★★☆
1. 开发者修改代码 → 提交PR。
2. CI流水线:构建镜像 → 推送到Registry → 运行测试。
3. CI更新GitOps仓库中的镜像Tag(自动化commit)。
4. ArgoCD检测到Git变更 → 自动同步到K8s集群。
5. ArgoCD报告部署状态。
env/staging、env/production各自维护配置。/overlays/staging、/overlays/production。★★★★☆
gitops/
├── base/ # 基础配置
│ ├── deployment.yaml
│ └── service.yaml
├── overlays/
│ ├── staging/ # 测试环境覆盖
│ └── production/ # 生产环境覆盖
└── apps/ # ArgoCD Application定义
★★★★★
git revert提交 → ArgoCD自动同步回滚。kubectl rollout undo(ArgoCD会检测到Drift并提示)。kubectl修改会被ArgoCD检测为OutOfSync,可能被覆盖。★★★★★
★★★★☆
★★★★☆
argocd app sync手动触发)。★★★★★
argocd-server:API Server + Web UI。argocd-repo-server:Git仓库缓存和模板渲染。argocd-application-controller:Application状态协调器。argocd-dex:SSO/OIDC认证。argocd-redis:缓存。1. Application Controller定期轮询Git仓库。
2. 检测到变更 → 渲染模板 → 对比K8s实际状态。
3. 如果有差异(Drift) → 根据Sync Policy决定是否自动同步。
4. 执行同步 → 创建/更新/删除K8s资源。
★★★★★
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
★★★★★
prune: true:自动删除Git中不存在的资源。selfHeal: true:自动修复手动修改(配置漂移自愈)。CreateNamespace=true:自动创建Namespace。ServerSideApply=true:使用Server-Side Apply。PruneLast=true:最后删除资源(先创建再删除)。★★★★☆
Synced:Git状态和K8s状态一致。OutOfSync:Git有变更未同步到K8s。Healthy:所有资源健康。Progressing:部署进行中。Degraded:部署失败或资源不健康。Missing:资源不存在。Suspended:资源暂停(如CronJob)。★★★★☆
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 cluster add <context>。argocd-cm ConfigMap和Secret中。
destination:
server: https://cluster-api-address
namespace: production
destination:
name: production-cluster
namespace: production
★★★★☆
kustomization.yaml。
source:
repoURL: ...
path: overlays/production
kustomize:
images:
- myapp=registry/myapp:v2.0.0
★★★★☆
Chart.yaml。 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
★★★★☆
policy.csv配置。argocd-rbac-cm ConfigMap。★★★★☆
1. 在Provider注册OAuth App。
2. 配置argocd-cm中的oidc.config或dex.config。
3. 配置RBAC映射Group到Role。
★★★★☆
metadata:
annotations:
argocd.argoproj.io/hook: PreSync
★★★★☆
argocd-notifications-cm ConfigMap + Subscription。★★★★★
Git Directory:根据Git目录结构生成Application。Git Files:根据Git文件内容生成。Cluster:根据注册的集群列表生成。Matrix:组合多个Generator(如:集群 × 服务)。List:静态列表。
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
★★★★☆
★★★★★
spec:
strategy:
canary:
steps:
- setWeight: 10
- pause: {duration: 5m}
- setWeight: 30
- pause: {duration: 5m}
- setWeight: 50
- analysis:
templates:
- templateName: success-rate
- setWeight: 100
★★★★☆
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
★★★★☆
replicas被HPA修改)可以配置忽略。
ignoreDifferences:
- group: apps
kind: Deployment
jsonPointers:
- /spec/replicas
★★★★☆
status.processors:增加Controller的Worker数量。repo.server.parallelism.limit:限制并行Git操作。controller.status.processors:增加状态处理并行度。★★★★☆
argocd-server:多副本 + Ingress负载均衡。argocd-repo-server:多副本(无状态)。argocd-application-controller:单副本(Leader Election)。redis:Sentinel模式或Redis Cluster。★★★★☆
argocd app set命令更新参数。★★★★☆
semver:语义化版本(如v2.1.0 > v2.0.0)。latest:最新Tag。name:按名称排序。digest:按Digest匹配。
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+$
★★★★☆
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: apps
spec:
source:
repoURL: https://github.com/org/gitops.git
path: argocd-apps
★★★★★
★★★★☆
★★★★☆
main:生产环境配置。staging:测试环境配置。/overlays/staging和/overlays/production。★★★★☆
latest)。★★★★☆
kubectl edit修改。OutOfSync。selfHeal: true → 自动修复Drift。selfHeal: false → 只告警不修复。★★★★☆
annotations:
argocd.argoproj.io/hook: PreSync
★★★★☆
argocd_app_sync_status:同步状态。argocd_app_health_status:健康状态。argocd_app_sync_total:同步次数。★★★★☆
base/:公共配置。overlays/dev/:开发环境覆盖。overlays/staging/:测试环境覆盖。overlays/prod/:生产环境覆盖。values.yaml:公共默认值。values-dev.yaml:开发环境覆盖。values-prod.yaml:生产环境覆盖。★★★★☆
★★★★☆
★★★★☆
repo.refreshInterval)。★★★★☆
kubectl logs -n argocd)。kubectl describe)。★★★★★
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. 成功 → 全量发布;失败 → 自动回滚。
★★★★☆
1. 安装@backstage/plugin-argo-cd插件。
2. 配置ArgoCD API连接。
3. 通过Annotation关联Component和ArgoCD Application。
annotations:
argocd/app-name: payment-service
★★★★★
argocd cluster add注册远程集群。★★★★☆
★★★★★
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)。
★★★★☆
1. 测试环境先升级ArgoCD。
2. 验证所有Application正常。
3. 生产环境升级。
4. 升级后验证。
1. ArgoCD不可用 → 检查Pod状态 → 检查数据库。
2. Application持续OutOfSync → 检查Git仓库 → 检查Repo Server。
★★★★★
★★★★★
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:统一告警。