Skip to content
CNPE · Chapter 5 of 22 Day 3: Argo CD – Git is the truth

Day 3: Argo CD – Git is the truth

Goal: Install Argo CD, roll out an application from Gitea, detect drift and let it heal itself, clean up deleted objects and control the order of a sync with waves and hooks · Duration: approx. 75 min · Prerequisite: Day 2

Briefing

  • GitOps means: the desired state is in Git, and an agent in the cluster constantly compares it with the actual state and reconciles. Nobody needs kubectl apply against production – and every change has a commit.
  • Argo CD is that agent. Its central resource is the Application: source (repo, revision, path) → destination (cluster, namespace).
  • Two states you must be able to read confidently in the exam:
Field Values Meaning
Sync Status Synced, OutOfSync does the cluster match Git?
Health Status Healthy, Progressing, Degraded, Missing does what is in the cluster work?
  • Three switches determine how much Argo CD does by itself: automated (synchronise on new commits), selfHeal (revert changes made to the cluster), prune (delete objects that have disappeared from Git).

Drill 1: Installing Argo CD

# on cp1
mkdir -p ~/cnpe/tag03 && cd ~/cnpe/tag03
cat > argocd-werte.yaml <<'EOF'
global:
  domain: 172.16.0.126:30080            # address in links of the UI and the CLI
  priorityClassName: plattform-kritisch # platform service (Day 2)
configs:
  params:
    server.insecure: true               # HTTP instead of HTTPS – lab only
  cm:
    timeout.reconciliation: 60s         # poll Git every 60 s (default: 120 s)
server:
  service:
    type: NodePort
    nodePortHttp: 30080
dex:
  enabled: false                        # no SSO in the lab
notifications:
  enabled: false
EOF
helm repo add argo https://argoproj.github.io/argo-helm
helm repo update
helm install argocd argo/argo-cd --version 10.20.0 -n argocd --create-namespace -f argocd-werte.yaml
k -n argocd rollout status deploy/argocd-server --timeout=300s
k -n argocd get pods

Expected (abridged):

STATUS: deployed
deployment "argocd-server" successfully rolled out
NAME                                                READY   STATUS      RESTARTS   AGE
argocd-application-controller-0                     1/1     Running     0          15s
argocd-applicationset-controller-6894b6f9d7-927ql   1/1     Running     0          15s
argocd-redis-c6c794b4-cj8v7                         1/1     Running     0          16s
argocd-redis-secret-init-27v2x                      0/1     Completed   0          60s
argocd-repo-server-86d5f8d74f-6r9md                 1/1     Running     0          15s
argocd-server-64d867fb5b-mxqrz                      1/1     Running     0          15s

The building blocks: the application-controller compares and synchronises, the repo-server fetches Git and renders manifests (Kustomize, Helm), the server provides the API and UI, the applicationset-controller generates Applications from templates (Day 4).

Now the CLI and the login:

# on cp1
ARCH=$(dpkg --print-architecture)
sudo curl -sSfL -o /usr/local/bin/argocd \
  https://github.com/argoproj/argo-cd/releases/download/v3.6.3/argocd-linux-$ARCH
sudo chmod 755 /usr/local/bin/argocd
argocd version --client --short
# the initial admin password is in a Secret
PW=$(k -n argocd get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' | base64 -d)
#   --plaintext   HTTP without TLS (matches server.insecure)
argocd login 172.16.0.126:30080 --username admin --password "$PW" --plaintext

Expected:

argocd: v3.6.3+b4accc4
'admin:login' logged in successfully
Context '172.16.0.126:30080' updated

You reach the UI at http://172.16.0.126:30080 with the same password (echo $PW).

Save your progress? Sign up for free

Drill 2: Registering the repository

The repository plattform in Gitea is private. Argo CD needs credentials:

# on cp1
argocd repo add http://172.16.0.126:30300/platform/plattform.git \
  --username platform --password platform-lab-123
argocd repo list

Expected:

Repository 'http://172.16.0.126:30300/platform/plattform.git' added
TYPE  NAME  REPO                                              INSECURE  OCI    LFS    CREDS  STATUS      MESSAGE  PROJECT
git         http://172.16.0.126:30300/platform/plattform.git  false     false  false  true   Successful

Behind the command is a Secret in the namespace argocd with the label argocd.argoproj.io/secret-type: repository – so you can also create repos declaratively (k -n argocd get secret -l argocd.argoproj.io/secret-type=repository).

Save your progress? Sign up for free

Drill 3: The first Application

Team Green gets a service shop. The manifests go into the platform repo:

# on cp1
cd ~/cnpe/plattform
mkdir -p apps/team-green/shop
cat > apps/team-green/shop/deployment.yaml <<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
  name: shop
  namespace: team-green
spec:
  replicas: 2
  selector:
    matchLabels: {app: shop}
  template:
    metadata:
      labels: {app: shop}
    spec:
      containers:
      - name: shop
        image: nginx:1.29
        ports: [{containerPort: 80}]
EOF
cat > apps/team-green/shop/service.yaml <<'EOF'
apiVersion: v1
kind: Service
metadata:
  name: shop
  namespace: team-green
spec:
  selector: {app: shop}
  ports: [{port: 80}]
EOF
git add -A && git commit -qm 'shop für Team Green' && git push -q

The Application itself is a Kubernetes resource in the namespace argocd:

# on cp1
cd ~/cnpe/tag03
cat > shop-app.yaml <<'EOF'
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: team-green-shop
  namespace: argocd                    # Applications always live with Argo CD
spec:
  project: default                     # AppProject with rules (Day 4)
  source:
    repoURL: http://172.16.0.126:30300/platform/plattform.git
    targetRevision: main               # branch, tag or commit
    path: apps/team-green/shop         # directory with the manifests
  destination:
    server: https://kubernetes.default.svc   # the same cluster
    namespace: team-green              # for objects without a namespace of their own
EOF
k apply -f shop-app.yaml
sleep 10
argocd app get team-green-shop

Expected (abridged):

application.argoproj.io/team-green-shop created
Name:               argocd/team-green-shop
...
Sync Policy:        Manual
Sync Status:        OutOfSync from main (b13109e)
Health Status:      Missing

GROUP  KIND        NAMESPACE   NAME  STATUS     HEALTH   HOOK  MESSAGE
       Service     team-green  shop  OutOfSync  Missing
apps   Deployment  team-green  shop  OutOfSync  Missing

Without a sync policy, Argo CD does not synchronise by itself – it only shows the difference. The first sync by hand:

# on cp1
argocd app sync team-green-shop
#   --health   wait until everything is healthy (not just in sync)
argocd app wait team-green-shop --health --timeout 120
k -n team-green get deploy,svc

Expected (abridged):

Message:            successfully synced (all tasks run)

GROUP  KIND        NAMESPACE   NAME  STATUS  HEALTH       HOOK  MESSAGE
       Service     team-green  shop  Synced  Healthy            service/shop created
apps   Deployment  team-green  shop  Synced  Progressing        deployment.apps/shop created
...
Sync Status:        Synced to main (b13109e)
Health Status:      Healthy
NAME                   READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/shop   2/2     2            2           3s

NAME           TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE
service/shop   ClusterIP   10.107.32.159   <none>        80/TCP    3s

Save your progress? Sign up for free

Drill 4: Drift and self-healing

Someone scales shop by hand – bypassing Git:

# on cp1
k -n team-green scale deploy shop --replicas=5
sleep 5
#   --refresh   compare immediately instead of waiting for the next cycle
argocd app get team-green-shop --refresh | grep -E 'Sync Status|^apps'
# what exactly differs?
argocd app diff team-green-shop

Expected (abridged):

deployment.apps/shop scaled
Sync Status:        OutOfSync from main (b13109e)
apps   Deployment  team-green  shop  OutOfSync  Healthy        deployment.apps/shop created

===== apps/Deployment team-green/shop ======
107c107
<   replicas: 5
---
>   replicas: 2

< is the cluster, > is Git. Now you switch on automation – declaratively, in the Application itself:

# on cp1
cat >> shop-app.yaml <<'EOF'
  syncPolicy:
    automated:                         # synchronise new commits automatically
      prune: true                      # delete objects in the cluster that were deleted from Git
      selfHeal: true                   # revert changes made to the cluster
EOF
k apply -f shop-app.yaml
sleep 20
k -n team-green get deploy shop
# change it by hand once more
k -n team-green scale deploy shop --replicas=7
sleep 15
k -n team-green get deploy shop

Expected:

application.argoproj.io/team-green-shop configured
NAME   READY   UP-TO-DATE   AVAILABLE   AGE
shop   2/2     2            2           34s
deployment.apps/shop scaled
NAME   READY   UP-TO-DATE   AVAILABLE   AGE
shop   2/2     2            2           50s

Argo CD set the 5 back to 2 immediately and the 7 after a few seconds. Self-heal reacts to changes in the cluster (via watches), not only at the next Git reconciliation.

Save your progress? Sign up for free

Drill 5: Prune – Git deletes too

# on cp1
cd ~/cnpe/plattform
git rm -q apps/team-green/shop/service.yaml
git commit -qm 'shop ohne Service' && git push -q
# do not wait 60 s: poll Git right away
argocd app get team-green-shop --refresh >/dev/null
sleep 15
k -n team-green get svc shop
argocd app history team-green-shop

Expected:

Error from server (NotFound): services "shop" not found
SOURCE  http://172.16.0.126:30300/platform/plattform.git
ID      DATE                           REVISION
0       2026-11-27 23:13:08 +0000 UTC  main (b13109e)
1       2026-11-27 23:14:07 +0000 UTC  main (43ea131)

Without prune: true, the Service would remain in the cluster, and the Application would show it as “OutOfSync, requires pruning”. The history links every sync to a commit – a rollback is argocd app rollback team-green-shop 0 (only works without automated, otherwise Git wins again immediately).

Save your progress? Sign up for free

Drill 6: Waves and hooks

Some things must happen before others: the configuration before the Deployment, the database migration before the new version. Argo CD arranges a sync in phases (PreSync, Sync, PostSync) and within a phase in waves (sync-wave, lower number first, default 0).

# on cp1
cd ~/cnpe/plattform
D=apps/team-green/shop
# restore the Service from the second-to-last commit
git checkout -q HEAD~1 -- $D/service.yaml
cat > $D/config.yaml <<'EOF'
apiVersion: v1
kind: ConfigMap
metadata:
  name: shop-config
  namespace: team-green
  annotations:
    argocd.argoproj.io/sync-wave: "-1"   # before everything in wave 0
data:
  WAEHRUNG: EUR
EOF
cat > $D/migration.yaml <<'EOF'
apiVersion: batch/v1
kind: Job
metadata:
  generateName: shop-migration-          # every run gets a new name
  namespace: team-green
  annotations:
    argocd.argoproj.io/hook: PreSync                         # before the actual sync
    argocd.argoproj.io/hook-delete-policy: BeforeHookCreation # delete the old job before the next run
spec:
  backoffLimit: 0                        # if the migration fails, the sync fails
  template:
    spec:
      restartPolicy: Never
      containers:
      - name: migration
        image: busybox:1.37
        command: ["sh", "-c", "echo Schema v2 eingespielt; sleep 3"]
EOF
git add -A && git commit -qm 'shop: Config in Welle -1, Migration als PreSync-Hook, Service zurück' && git push -q
argocd app sync team-green-shop
k -n team-green get jobs
k -n team-green logs job/$(k -n team-green get jobs -o jsonpath='{.items[0].metadata.name}')

Expected (abridged):

Message:            successfully synced (all tasks run)
GROUP  KIND        NAMESPACE   NAME                                       STATUS     HEALTH   HOOK     MESSAGE
batch  Job         team-green  shop-migration-5f39f04-presync-1795821272  Succeeded  Synced   PreSync  Reached expected number of succeeded pods
       ConfigMap   team-green  shop-config                                Synced                       configmap/shop-config created
       Service     team-green  shop                                       Synced     Healthy           service/shop created
apps   Deployment  team-green  shop                                       Synced     Healthy           deployment.apps/shop unchanged
NAME                                        STATUS     COMPLETIONS   DURATION   AGE
shop-migration-5f39f04-presync-1795821272   Complete   1/1           6s         16s
Schema v2 eingespielt

Order: first the PreSync job, then the ConfigMap (wave −1), then Service and Deployment (wave 0). Between waves, Argo CD waits until everything in the previous wave is healthy.

Save your progress? Sign up for free

Exercise: State in 60 seconds

Time limit: 3 minutes. For all Applications, show sync status, health and sync policy in one line per app – once with the Argo CD CLI, once with kubectl only.

Solution

# on cp1
argocd app list
# fields directly from the resource
k -n argocd get applications \
  -o custom-columns=NAME:.metadata.name,SYNC:.status.sync.status,HEALTH:.status.health.status,AUTO:.spec.syncPolicy.automated

Expected (abridged):

NAME                    CLUSTER                         NAMESPACE   PROJECT  STATUS  HEALTH   SYNCPOLICY  CONDITIONS  REPO ...
argocd/team-green-shop  https://kubernetes.default.svc  team-green  default  Synced  Healthy  Auto-Prune  <none>      http://172.16.0.126:30300/platform/plattform.git ...
NAME              SYNC     HEALTH    AUTO
team-green-shop   Synced   Healthy   map[prune:true selfHeal:true]

In the exam it is not guaranteed that you have a logged-in argocd CLI. The kubectl variant always works.

Save your progress? Sign up for free

Challenge

Time limit: 10 minutes. A colleague pushes a Deployment with a typo in the image (nginx:1.29-nicht-da). What does Argo CD show as sync and health status, and how do you bring the application back without switching Argo CD off?

Solution

The sync succeeds (the manifest is valid), but the new pod hangs in ImagePullBackOff: Synced and Progressing, and after progressDeadlineSeconds (default 600 s) has elapsed, Degraded. Because automated is on, neither k rollout undo (selfHeal reverts it) nor argocd app rollback (only works without automated) helps. The GitOps way is a commit:

# on cp1
cd ~/cnpe/plattform
# undo the last commit – with a new commit, the history is preserved
git revert --no-edit HEAD && git push -q
argocd app get team-green-shop --refresh >/dev/null
# wait briefly until the rollout is through
sleep 30
argocd app get team-green-shop | grep -E 'Sync Status|Health Status'
k -n team-green get pods -l app=shop

Expected (abridged; before the revert the app showed Synced and Progressing, one pod hung in ImagePullBackOff, the two old ones kept running):

[main f8a12ad] Revert "shop: neues Image"
 1 file changed, 1 insertion(+), 1 deletion(-)
Sync Status:        Synced to main (f8a12ad)
Health Status:      Healthy
NAME                    READY   STATUS    RESTARTS   AGE
shop-5c4465bfcc-6n75q   1/1     Running   0          6m2s
shop-5c4465bfcc-7brcx   1/1     Running   0          6m9s

That the old pods kept running is thanks to the rolling update: the new pod never became ready, so no old one was terminated.

Save your progress? Sign up for free

Checkpoint

# on cp1
# Argo CD in version 3.6.3
argocd version --short 2>/dev/null | grep argocd-server
# Application in sync and healthy, with automation
k -n argocd get application team-green-shop -o jsonpath='{.status.sync.status} {.status.health.status} {.spec.syncPolicy.automated}{"\n"}'
# objects of shop in the cluster
k -n team-green get deploy/shop svc/shop cm/shop-config -o name

Expected:

argocd-server: v3.6.3
Synced Healthy {"prune":true,"selfHeal":true}
deployment.apps/shop
service/shop
configmap/shop-config

Interview Note

  • Push or pull for delivery? With GitOps, an agent in the cluster pulls. The CI needs no credentials for the cluster, and drift is detected.
  • Synced but Degraded – what does that mean? The cluster matches Git, but what is in Git does not work. An error in the manifest, not in the reconciliation.
  • Why is a rollback with argocd app rollback pointless with automatic sync? Git remains the truth; the next reconciliation restores the new state. Rollback means git revert.

Enterprise Note

  • TLS for the Argo CD server and SSO via OIDC (Dex or directly); then disable the admin user (admin.enabled: false) and delete argocd-initial-admin-secret.
  • Repo access via deploy keys or read-only tokens, not via Gitea’s admin account.
  • Webhooks from Gitea to Argo CD (/api/webhook) instead of polling every 60 s – faster and quieter.
  • Argo CD manages itself via an Application (app of apps) – Day 4 lays the foundation.

Contents

More