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.
kubectl create namespace argocd && kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yamlkubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -dkubectl port-forward svc/argocd-server -n argocd 8080:443 → https://localhost:8080syncPolicy: { automated: { prune: true, selfHeal: true } }| Сценарий | Конфиг |
|---|---|
| First Application | apiVersion: 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 pattern | apiVersion: 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 ArgoCD | source:
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] |
Для 1 app — overkill. Для 3+ apps/services в Kubernetes — ArgoCD убирает manual kubectl + provides audit trail + rollback.
HTTPS: username + personal access token в secret. SSH: deploy key. В UI → Settings → Repositories.
НЕ plain в Git. Sealed Secrets (bitnami) encrypted в Git, расшифровываются в cluster. Или External Secrets Operator → Vault/AWS SM/SSM.
Kustomize overlays + separate Applications per env. Или ApplicationSet для DRY.