Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
The quick answer
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: shop
namespace: argocd
spec:
project: default
source:
repoURL: git@github.com:ORG/deploy.git
targetRevision: main
path: shop/overlays/prod
destination:
server: https://kubernetes.default.svc
namespace: shop
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=trueStep by step
- A deploy repository with the manifests (plain YAML, Kustomize or a Helm chart with values) — separate from the app's source code is common:
shop/
base/ deployment.yaml, service.yaml, kustomization.yaml
overlays/
staging/ kustomization.yaml (image tag, replicas)
prod/ kustomization.yaml
apps/
shop.yaml the Argo CD Application- Give Argo CD read access — a read-only deploy key:
ssh-keygen -t ed25519 -f ~/.ssh/argocd-deploy -N '' -C argocd
argocd repo add git@github.com:ORG/deploy.git --ssh-private-key-path ~/.ssh/argocd-deployAdd the public key in the Git host as a read-only deploy key.
- Create the Application (quick answer).
automated= sync on every Git change;prune= delete objects removed from Git;selfHeal= undo manual changes in the cluster. - Deploy a new version — change Git, not the cluster:
cd deploy/shop/overlays/prod
kustomize edit set image registry.example.com/shop/api:1.4.3
git commit -am "shop api 1.4.3" && git pushArgo CD sees the commit (polling about every 3 minutes, or at once with a webhook) and rolls it out. CI can open this commit as a pull request automatically.
- Watch and act:
- Rollback = revert in Git (with auto-sync, an
argocd app rollbackis undone by the next sync):
- Safety: use AppProjects to limit which repos and namespaces a team may deploy to, SSO for the UI, and keep Secrets out of Git (SOPS / External Secrets).
Check that it worked
argocd app get shop shows Sync Status: Synced and Health Status: Healthy; change a replica count by hand with kubectl scale — with self-heal, Argo CD sets it back within moments.
Common problems
| Problem | Cause | Fix |
|---|---|---|
OutOfSync that never ends | Fields changed by controllers (HPA replicas, defaults). | ignoreDifferences for those fields; let the HPA own replicas. |
ComparisonError: repository not accessible | Deploy key / URL wrong. | argocd repo list; check the key and the repo URL. |
| Manual fix in the cluster disappears | selfHeal: true (by design). | Change Git instead. |
| Deleted file, object still in the cluster | prune is off. | Turn on prune, or sync with prune once. |
| New version not deployed | Git not updated, or polling delay. | Check the commit; add a Git webhook for instant syncs. |
| Secrets visible in the UI diff | Plain Secrets in Git or in manifests. | SOPS or External Secrets; RBAC on who can see the app. |
Go further
- Command pages: argocd, kubectl, kustomize, git.
- Next how-tos: Use Kustomize overlays per environment, Roll back a deployment, Create a Kubernetes Secret safely, Deploy from Git with Flux.
- Full guide: Argo CD. Learn it: GitOps — Principles, GitOps — The Application, GitOps — Sync, GitOps — Projects.
- Practise: Lab: deploy with Argo CD — auto-sync, self-heal, prune and a rollback.
1In GitOps, how do you roll back a bad release?
Revert the commit in Git; Argo CD syncs the cluster back.
2What do prune and selfHeal do?
prune deletes objects removed from Git; selfHeal undoes manual changes in the cluster.