Skip to content

Как настроить GitOps с ArgoCD

Коротко:

GitOps через ArgoCD: манифесты в Git → agent в Kubernetes автоматически применяет → UI показывает sync status. Setup за 15 мин: install ArgoCD через manifests, create Application CRD pointing Git repo, enable auto-sync. Changes в Git = changes в cluster автоматически. Rollback = git revert.

Ниже: пошаговая инструкция, рабочие примеры, типичные ошибки, FAQ.

Пошаговая настройка

  1. Install ArgoCD: kubectl create namespace argocd && kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
  2. Получите initial password: kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
  3. Port-forward UI: kubectl port-forward svc/argocd-server -n argocd 8080:443 → https://localhost:8080
  4. Create Git repo для manifests (отдельный от app code)
  5. Define Application CRD: source=Git path, destination=cluster namespace
  6. Enable auto-sync: syncPolicy: { automated: { prune: true, selfHeal: true } }
  7. Test: commit изменение в Git → через 3 мин applied в cluster

Рабочие примеры

СценарийКонфиг
First ApplicationapiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: my-app namespace: argocd spec: project: default source: repoURL: https://github.com/me/manifests path: apps/my-app targetRevision: main destination: server: https://kubernetes.default.svc namespace: my-app syncPolicy: automated: prune: true selfHeal: true
App of Apps patternapiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: root spec: source: repoURL: https://github.com/me/manifests path: root # Directory содержит yaml с дополнительными Application CRDs
Helm chart via ArgoCDsource: repoURL: https://charts.bitnami.com/bitnami chart: postgresql targetRevision: 13.0.0 helm: values: | auth: { postgresPassword: "from-secret" }
Sync wave (order resources)metadata: annotations: argocd.argoproj.io/sync-wave: "1" # Deploy этот first
Notifications на Slack# Install argocd-notifications addon data: service.slack: | token: $slack-token subscriptions: | - recipients: [slack:deployments] triggers: [on-sync-succeeded, on-sync-failed]

Типичные ошибки

  • auto-sync + prune: true на критичный resource → случайное удаление при Git revert
  • SSH keys для private Git — нужен Kubernetes secret + правильный auth
  • App-of-apps без TTL — broken child app держит parent в Degraded state
  • Helm releases managed ArgoCD conflict с manual helm install
  • Multi-cluster: нужны cluster credentials + certificate auth или kube API token

Больше по теме

Часто задаваемые вопросы

ArgoCD для small cluster — overkill?

Для 1 app — overkill. Для 3+ apps/services в Kubernetes — ArgoCD убирает manual kubectl + provides audit trail + rollback.

Private repos — доступ?

HTTPS: username + personal access token в secret. SSH: deploy key. В UI → Settings → Repositories.

Как secrets?

НЕ plain в Git. Sealed Secrets (bitnami) encrypted в Git, расшифровываются в cluster. Или External Secrets Operator → Vault/AWS SM/SSM.

Multi-env (dev/staging/prod)?

Kustomize overlays + separate Applications per env. Или ApplicationSet для DRY.