Zum Inhalt springen
Trainingslager IT-Trainingslager

Tag 13: Argo Rollouts

Ziel: Eine neue Version von notes-api geht schrittweise live. Eine Analyse prüft sie unterwegs und bricht ab, wenn sie nicht funktioniert. Danach dasselbe als Blue-Green mit Vorschau. · Dauer: ca. 60 min · Voraussetzung: Tag 12

Briefing

  • Ein Deployment tauscht Pods einfach der Reihe nach aus. Ob die neue Version richtig arbeitet, prüft es nicht. Merkt es niemand, ist sie nach einer Minute überall.
  • Argo Rollouts ist ein eigener Controller mit dem Objekt Rollout. Es sieht aus wie ein Deployment, hat aber eine Strategie mit Schritten.
  • Canary: Erst ein Teil der Pods bekommt die neue Version. Zwischen den Schritten wartet der Rollout auf einen Menschen, eine feste Zeit oder eine Analyse.
  • Blue-Green: Die neue Version läuft komplett neben der alten. Ein zweiter Service zeigt sie als Vorschau, und erst beim Befördern schaltet der Haupt-Service um.
  • Eine AnalysisTemplate beschreibt eine Prüfung, hier einen Job mit curl. Scheitert sie, bricht der Rollout ab und die alte Version bleibt.
  • Argo CD kennt den Zustand eines Rollouts: Eine Pause erscheint als Suspended, ein Abbruch als Degraded.
 Canary, Schritte:  25 % ─► Analyse ─► 50 % ─► 30 s ─► 100 %
                     │         │
 notes-stable ──► alte Pods    └── Job: curl http://notes-canary/notes
 notes-canary ──► neue Pods

Drill 1: Argo Rollouts installieren

Der Controller ist Plattform-Software, also kommt er über Git. Kustomize kann eine Datei direkt von einer URL einbinden:

cd ~/argo-lab/argocd-fleet
git pull
mkdir -p platform/argo-rollouts
cat > platform/argo-rollouts/kustomization.yaml <<'EOF'
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: argo-rollouts
resources:
  - https://github.com/argoproj/argo-rollouts/releases/download/v1.10.2/install.yaml
EOF
cat > applications/argo-rollouts.yaml <<'EOF'
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: argo-rollouts
  namespace: argocd
spec:
  project: default
  source:
    repoURL: [email protected]:<du>/argocd-fleet.git
    targetRevision: main
    path: platform/argo-rollouts
  destination:
    server: https://kubernetes.default.svc
    namespace: argo-rollouts
  syncPolicy:
    automated:
      selfHeal: true
      prune: true
    syncOptions:
      - CreateNamespace=true
EOF
git add -A
git commit -m "Argo Rollouts"
git push
argocd app get root --refresh
sleep 40
argocd app get argo-rollouts | grep -E "Sync Status|Health Status"
kubectl -n argocd get app argo-rollouts -o jsonpath='{.status.operationState.message}'
echo

Erwartet (gekürzt):

Sync Status:        OutOfSync from main (0e9423c)
Health Status:      Healthy
one or more synchronization tasks completed unsuccessfully, reason: CustomResourceDefinition.apiextensions.k8s.io "analysisruns.argoproj.io" is invalid: metadata.annotations: Too long: may not be more than 262144 bytes,… Retrying attempt #2 at 8:06AM.

Dasselbe Problem wie in Tag 1: Zwei CRDs sind zu groß für ein normales apply. Argo CD kann wie kubectl serverseitig anwenden. syncOptions ist der letzte Block der Datei, also hängst du die Option einfach an:

echo "      - ServerSideApply=true" >> applications/argo-rollouts.yaml
tail -3 applications/argo-rollouts.yaml
git commit -am "Argo Rollouts: Server-Side Apply"
git push
argocd app get root --refresh
sleep 30
argocd app get argo-rollouts | grep -E "Sync Status|Health Status"

Erwartet (gekürzt):

    syncOptions:
      - CreateNamespace=true
      - ServerSideApply=true
…
Sync Status:        OutOfSync from main (d1dc992)
Health Status:      Healthy

Ausprobiert: Die Option steht in der Application, aber argo-rollouts bleibt OutOfSync. Der gescheiterte Sync läuft noch und wiederholt sich mit der alten Revision, immer mit längeren Pausen. Erst terminate-op beendet ihn, danach startet der automatische Sync neu.

argocd app terminate-op argo-rollouts
sleep 30
argocd app get argo-rollouts | grep -E "Sync Status|Health Status"
kubectl -n argo-rollouts get deploy

Erwartet:

Application 'argo-rollouts' operation terminating
Sync Status:        Synced to main (d1dc992)
Health Status:      Healthy
NAME            READY   UP-TO-DATE   AVAILABLE   AGE
argo-rollouts   1/1     1            1           94s

Für die Befehlszeile gibt es ein Plugin für kubectl:

AR_URL=https://github.com/argoproj/argo-rollouts/releases/download/v1.10.2
curl -sLo ~/.local/bin/kubectl-argo-rollouts $AR_URL/kubectl-argo-rollouts-linux-amd64
chmod +x ~/.local/bin/kubectl-argo-rollouts
kubectl argo rollouts version | head -1

Erwartet:

kubectl-argo-rollouts: v1.10.2+be8a622

kubectl findet jedes Programm kubectl-<name> im PATH und macht daraus den Befehl kubectl <name>.

Hinweis: Meldet argocd irgendwann token is expired, ist deine Anmeldung von Tag 1 älter als 24 Stunden. Melde dich neu an wie in Tag 1.

Fortschritt speichern? Kostenlos registrieren

Drill 2: Eine Application für den Rollout

Der Rollout bekommt einen eigenen Namespace notes-rollout und speichert seine Notizen nur im Speicher. Vorher eine Falle aus Tag 12: Der Image Updater überwacht alles, was mit notes beginnt.

Ausprobiert: Mit namePattern: "notes*" hat der Image Updater auch die neue Application notes-rollout erfasst und 0.7.1 in ihre kustomization.yaml geschrieben. Jeder Versuch, eine andere Version von Hand zu setzen, lief damit ins Leere.

Du nennst die beiden Applications deshalb einzeln. Die ganze Datei:

cat > applications/notes-updater.yaml <<'EOF'
apiVersion: argocd-image-updater.argoproj.io/v1alpha1
kind: ImageUpdater
metadata:
  name: notes
  namespace: argocd
spec:
  writeBackConfig:
    method: git
    gitConfig:
      branch: main
      writeBackTarget: kustomization
  applicationRefs:
    - namePattern: notes
      images:
        - alias: api
          imageName: ghcr.io/thomaszachmann/notes-api:~0.7
    - namePattern: notes-dev
      images:
        - alias: api
          imageName: ghcr.io/thomaszachmann/notes-api:~0.7
EOF

notes-api startet nicht ohne API-Key. Er kommt verschlüsselt ins Repo, wie in Tag 10:

mkdir -p apps/notes-rollout
cat > apps/notes-rollout/secret.enc.yaml <<'EOF'
apiVersion: v1
kind: Secret
metadata:
  name: notes-api
stringData:
  apiKey: lab-rollout-key-123
EOF
sops encrypt -i apps/notes-rollout/secret.enc.yaml
grep apiKey apps/notes-rollout/secret.enc.yaml | cut -c1-40
cat > apps/notes-rollout/secret-generator.yaml <<'EOF'
apiVersion: viaduct.ai/v1
kind: ksops
metadata:
  name: notes-rollout-secrets
  annotations:
    config.kubernetes.io/function: |
      exec:
        path: ksops
files:
  - ./secret.enc.yaml
EOF

Erwartet:

    apiKey: ENC[AES256_GCM,data:OzC1L06s

Jetzt der Rollout. Der obere Teil gleicht einem Deployment. Neu ist strategy:

cat > apps/notes-rollout/rollout.yaml <<'EOF'
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
  name: notes
spec:
  replicas: 4
  selector:
    matchLabels:
      app: notes
  template:
    metadata:
      labels:
        app: notes
    spec:
      containers:
        - name: api
          image: ghcr.io/thomaszachmann/notes-api:0.5.3
          ports:
            - containerPort: 8080
          env:
            - name: NOTES_API_KEY
              valueFrom:
                secretKeyRef:
                  name: notes-api
                  key: apiKey
          readinessProbe:
            httpGet:
              path: /healthz
              port: 8080
  strategy:
    canary:
      stableService: notes-stable
      canaryService: notes-canary
      steps:
        - setWeight: 25
        - pause: {}
        - setWeight: 50
        - pause:
            duration: 30s
EOF
  • setWeight: 25 heißt hier: ein Viertel der Pods bekommt die neue Version. Ohne Service-Mesh oder Ingress-Controller verteilt Rollouts den Verkehr über die Zahl der Pods.
  • pause: {} wartet unbegrenzt auf einen Menschen, duration: 30s nur 30 Sekunden.
  • stableService und canaryService sind zwei Services. Rollouts biegt ihre Selektoren so um, dass einer nur alte, der andere nur neue Pods erreicht.

Die beiden Services, beide als NodePort zum Ausprobieren:

cat > apps/notes-rollout/services.yaml <<'EOF'
apiVersion: v1
kind: Service
metadata:
  name: notes-stable
spec:
  type: NodePort
  selector:
    app: notes
  ports:
    - port: 80
      targetPort: 8080
      nodePort: 30085
---
apiVersion: v1
kind: Service
metadata:
  name: notes-canary
spec:
  type: NodePort
  selector:
    app: notes
  ports:
    - port: 80
      targetPort: 8080
      nodePort: 30086
EOF
cat > apps/notes-rollout/kustomization.yaml <<'EOF'
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
generators:
  - secret-generator.yaml
resources:
  - rollout.yaml
  - services.yaml
EOF

Die Application gehört ins Projekt notes. Der Namespace notes-rollout passt zu notes*:

cat > applications/notes-rollout.yaml <<'EOF'
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: notes-rollout
  namespace: argocd
spec:
  project: notes
  source:
    repoURL: [email protected]:<du>/argocd-fleet.git
    targetRevision: main
    path: apps/notes-rollout
  destination:
    server: https://kubernetes.default.svc
    namespace: notes-rollout
  syncPolicy:
    automated:
      selfHeal: true
      prune: true
    syncOptions:
      - CreateNamespace=true
EOF
git add -A
git commit -m "notes-rollout: Canary"
git push
argocd app get root --refresh
sleep 50
kubectl argo rollouts get rollout notes -n notes-rollout

Erwartet:

Name:            notes
Namespace:       notes-rollout
Status:          ✔ Healthy
Strategy:        Canary
  Step:          4/4
  SetWeight:     100
  ActualWeight:  100
Images:          ghcr.io/thomaszachmann/notes-api:0.5.3 (stable)
Replicas:
  Desired:       4
  Current:       4
  Updated:       4
  Ready:         4
  Available:     4

NAME                              KIND        STATUS     AGE  INFO
⟳ notes                           Rollout     ✔ Healthy  35s
└──# revision:1
   └──⧉ notes-95fd5cfc5           ReplicaSet  ✔ Healthy  35s  stable
      ├──□ notes-95fd5cfc5-254vx  Pod         ✔ Running  35s  ready:1/1
      ├──□ notes-95fd5cfc5-86q48  Pod         ✔ Running  35s  ready:1/1
      ├──□ notes-95fd5cfc5-j665r  Pod         ✔ Running  35s  ready:1/1
      └──□ notes-95fd5cfc5-z47wh  Pod         ✔ Running  35s  ready:1/1

Beim ersten Mal gibt es nichts zu vergleichen. Der Rollout springt sofort auf 100 %.

Fortschritt speichern? Kostenlos registrieren

Drill 3: Canary von Hand

sed -i "s/notes-api:0.5.3/notes-api:0.7.0/" apps/notes-rollout/rollout.yaml
git commit -am "notes-rollout: 0.7.0"
git push
argocd app get notes-rollout --refresh
sleep 30
kubectl argo rollouts get rollout notes -n notes-rollout

Erwartet:

Name:            notes
Namespace:       notes-rollout
Status:          ॥ Paused
Message:         CanaryPauseStep
Strategy:        Canary
  Step:          1/4
  SetWeight:     25
  ActualWeight:  25
Images:          ghcr.io/thomaszachmann/notes-api:0.5.3 (stable)
                 ghcr.io/thomaszachmann/notes-api:0.7.0 (canary)
Replicas:
  Desired:       4
  Current:       4
  Updated:       1
  Ready:         4
  Available:     4

NAME                               KIND        STATUS     AGE  INFO
⟳ notes                            Rollout     ॥ Paused   76s
├──# revision:2
│  └──⧉ notes-5ff689668b           ReplicaSet  ✔ Healthy  28s  canary
│     └──□ notes-5ff689668b-f7wvv  Pod         ✔ Running  28s  ready:1/1
└──# revision:1
   └──⧉ notes-95fd5cfc5            ReplicaSet  ✔ Healthy  76s  stable
      ├──□ notes-95fd5cfc5-66jzz   Pod         ✔ Running  76s  ready:1/1
      ├──□ notes-95fd5cfc5-k5v8k   Pod         ✔ Running  76s  ready:1/1
      └──□ notes-95fd5cfc5-z6c9c   Pod         ✔ Running  76s  ready:1/1

Ein Pod mit 0.7.0, drei mit 0.5.3. Was sehen Argo CD und die beiden Services?

argocd app get notes-rollout | grep -E "Sync Status|Health Status"
curl -s localhost:30085/version
curl -s localhost:30086/version
kubectl -n notes-rollout get svc notes-stable notes-canary \
  -o custom-columns=NAME:.metadata.name,SELECTOR:.spec.selector

Erwartet:

Sync Status:        Synced to main (7f960f6)
Health Status:      Suspended
0.5.3
0.7.0
NAME           SELECTOR
notes-stable   map[app:notes rollouts-pod-template-hash:95fd5cfc5]
notes-canary   map[app:notes rollouts-pod-template-hash:5ff689668b]
  • Für Argo CD ist alles Synced, denn der Rollout im Cluster entspricht Git. Die Pause erscheint als Health Suspended.
  • Rollouts hat beide Services um den Hash des jeweiligen ReplicaSets ergänzt. Über Port 30086 testest du gezielt die neue Version.

Sieht 0.7.0 gut aus, gibst du den nächsten Schritt frei:

kubectl argo rollouts promote notes -n notes-rollout
sleep 10
kubectl argo rollouts get rollout notes -n notes-rollout | sed -n 3,10p

Erwartet:

rollout 'notes' promoted
Status:          ॥ Paused
Message:         CanaryPauseStep
Strategy:        Canary
  Step:          3/4
  SetWeight:     50
  ActualWeight:  50
Images:          ghcr.io/thomaszachmann/notes-api:0.5.3 (stable)
                 ghcr.io/thomaszachmann/notes-api:0.7.0 (canary)

Die Pause von 30 Sekunden läuft von allein ab:

sleep 45
kubectl argo rollouts get rollout notes -n notes-rollout | sed -n 3,9p
argocd app get notes-rollout | grep -E "Sync Status|Health Status"

Erwartet:

Status:          ✔ Healthy
Strategy:        Canary
  Step:          4/4
  SetWeight:     100
  ActualWeight:  100
Images:          ghcr.io/thomaszachmann/notes-api:0.7.0 (stable)
Replicas:
Sync Status:        Synced to main (7f960f6)
Health Status:      Healthy

promote ändert nur den Status des Rollouts, nicht seine Spezifikation. Deshalb bleibt Argo CD die ganze Zeit Synced.

Fortschritt speichern? Kostenlos registrieren

Drill 4: Eine Analyse statt eines Menschen

Die Pause von Hand wird durch eine Prüfung ersetzt. Ein Job legt dreimal im Abstand von zehn Sekunden über den Canary-Service eine Notiz an. Schlägt einer fehl, ist die Analyse gescheitert:

cat > apps/notes-rollout/analysis-template.yaml <<'EOF'
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
  name: smoke
spec:
  metrics:
    - name: notiz-anlegen
      count: 3
      interval: 10s
      failureLimit: 0
      provider:
        job:
          spec:
            backoffLimit: 0
            template:
              spec:
                restartPolicy: Never
                containers:
                  - name: curl
                    image: curlimages/curl:8.17.0
                    env:
                      - name: KEY
                        valueFrom:
                          secretKeyRef:
                            name: notes-api
                            key: apiKey
                    command: ["sh", "-c"]
                    args:
                      - >-
                        curl -sf -H "X-API-Key: $KEY" -d '{"text":"canary"}'
                        http://notes-canary/notes
EOF
  • count: 3 und interval: 10s: drei Messungen, eine alle zehn Sekunden.
  • failureLimit: 0: Schon eine fehlgeschlagene Messung lässt die Analyse scheitern.
  • curl -f endet mit einem Fehler, wenn der Server mit 4xx oder 5xx antwortet. Dann scheitert der Job.

In apps/notes-rollout/rollout.yaml ersetzt du den Schritt pause: {} durch die Analyse und hebst das Image auf 0.7.1. Die Schritte sehen danach so aus:

      steps:
        - setWeight: 25
        - analysis:
            templates:
              - templateName: smoke
        - setWeight: 50
        - pause:
            duration: 30s
sed -i "s/notes-api:0.7.0/notes-api:0.7.1/" apps/notes-rollout/rollout.yaml
echo "  - analysis-template.yaml" >> apps/notes-rollout/kustomization.yaml
git add -A
git commit -m "notes-rollout: Analyse, 0.7.1"
git push
argocd app get notes-rollout --refresh
sleep 25
kubectl argo rollouts get rollout notes -n notes-rollout | sed -n 3,10p

Erwartet:

Status:          ◌ Progressing
Message:         more replicas need to be updated
Strategy:        Canary
  Step:          1/4
  SetWeight:     25
  ActualWeight:  25
Images:          ghcr.io/thomaszachmann/notes-api:0.7.0 (stable)
                 ghcr.io/thomaszachmann/notes-api:0.7.1 (canary)

Der Rollout steht beim ersten Schritt, die Analyse läuft. Im Baum, den kubectl argo rollouts get rollout darunter zeigt, hängt jetzt eine AnalysisRun mit ihren Jobs am neuen ReplicaSet. Eine Minute später:

sleep 45
kubectl -n notes-rollout get analysisrun
kubectl argo rollouts status notes -n notes-rollout --timeout 60s
curl -s localhost:30085/version

Erwartet:

NAME                   STATUS       AGE
notes-74d46fd559-3-1   Successful   67s
Healthy
0.7.1

Niemand musste promote aufrufen. Die Analyse hat die neue Version freigegeben.

Fortschritt speichern? Kostenlos registrieren

Drill 5: Der Abbruch

Ein Kollege hat zum Testen einen festen API-Key eingetragen und vergessen, ihn wieder herauszunehmen. In apps/notes-rollout/rollout.yaml steht danach:

          env:
            - name: NOTES_API_KEY
              value: test-key
git diff

Erwartet (gekürzt):

             - name: NOTES_API_KEY
-              valueFrom:
-                secretKeyRef:
-                  name: notes-api
-                  key: apiKey
+              value: test-key

notes-api startet damit, /healthz meldet ok, die Readiness-Probe ist zufrieden. Ein normales Deployment würde die Version überall ausrollen.

git commit -am "notes-rollout: Test-Key"
git push
argocd app get notes-rollout --refresh
sleep 50
kubectl argo rollouts get rollout notes -n notes-rollout | sed -n 1,16p

Erwartet:

Name:            notes
Namespace:       notes-rollout
Status:          ✖ Degraded
Message:         RolloutAborted: Rollout aborted update to revision 4: Step-based analysis phase error/failed: Metric "notiz-anlegen" assessed Failed due to failed (1) > failureLimit (0)
Strategy:        Canary
  Step:          0/4
  SetWeight:     0
  ActualWeight:  0
Images:          ghcr.io/thomaszachmann/notes-api:0.7.1 (stable)
Replicas:
  Desired:       4
  Current:       4
  Updated:       0
  Ready:         4
  Available:     4

Der Job hat mit dem echten Key eine Notiz angelegt und 401 bekommen. Rollouts hat den Canary-Pod entfernt, alle vier Pods laufen mit der alten Version.

argocd app get notes-rollout | grep -E "Sync Status|Health Status"
curl -s localhost:30085/version

Erwartet:

Sync Status:        Synced to main (af44734)
Health Status:      Degraded
0.7.1

Synced und Degraded zugleich: Git beschreibt die kaputte Version, der Cluster verweigert sie. Repariert wird in Git. git revert macht den letzten Commit rückgängig:

git revert --no-edit HEAD
git push
argocd app get notes-rollout --refresh
sleep 20
kubectl argo rollouts get rollout notes -n notes-rollout | sed -n 3,9p
argocd app get notes-rollout | grep -E "Sync Status|Health Status"

Erwartet (gekürzt):

[main af0008e] Revert "notes-rollout: Test-Key"
…
Status:          ✔ Healthy
Strategy:        Canary
  Step:          4/4
  SetWeight:     100
  ActualWeight:  100
Images:          ghcr.io/thomaszachmann/notes-api:0.7.1 (stable)
Replicas:
Sync Status:        Synced to main (af0008e)
Health Status:      Healthy

Git beschreibt wieder genau die laufende Version. Rollouts erkennt das und ist sofort gesund, ohne neue Analyse.

Fortschritt speichern? Kostenlos registrieren

Drill 6: Blue-Green

Angenommen, in 0.7.1 taucht ein Fehler auf, und ihr wollt kontrolliert zurück auf 0.7.0. Diesmal soll die alte Version erst komplett neben der laufenden stehen und über die Vorschau geprüft werden. In apps/notes-rollout/rollout.yaml ersetzt du den ganzen Block strategy:

  strategy:
    blueGreen:
      activeService: notes-stable
      previewService: notes-canary
      autoPromotionEnabled: false
  • activeService bekommt den Verkehr, previewService zeigt die neue Version.
  • autoPromotionEnabled: false: Umgeschaltet wird erst nach einem promote.
sed -i "s/notes-api:0.7.1/notes-api:0.7.0/" apps/notes-rollout/rollout.yaml
git commit -am "notes-rollout: Blue-Green, zurück auf 0.7.0"
git push
argocd app get notes-rollout --refresh
sleep 40
kubectl argo rollouts get rollout notes -n notes-rollout | sed -n 1,13p
curl -s localhost:30085/version
curl -s localhost:30086/version

Erwartet:

Name:            notes
Namespace:       notes-rollout
Status:          ॥ Paused
Message:         BlueGreenPause
Strategy:        BlueGreen
Images:          ghcr.io/thomaszachmann/notes-api:0.7.0 (preview)
                 ghcr.io/thomaszachmann/notes-api:0.7.1 (stable, active)
Replicas:
  Desired:       4
  Current:       8
  Updated:       4
  Ready:         4
  Available:     4
0.7.1
0.7.0

Acht Pods: vier aktive mit 0.7.1, vier in der Vorschau mit 0.7.0. Der Verkehr auf 30085 merkt davon nichts. Nach der Prüfung schaltest du um:

kubectl argo rollouts promote notes -n notes-rollout
sleep 10
curl -s localhost:30085/version
sleep 40
kubectl -n notes-rollout get rs \
  -o custom-columns=NAME:.metadata.name,DESIRED:.spec.replicas,\
IMAGE:.spec.template.spec.containers[0].image

Erwartet:

rollout 'notes' promoted
0.7.0
NAME               DESIRED   IMAGE
notes-5ff689668b   4         ghcr.io/thomaszachmann/notes-api:0.7.0
notes-74d46fd559   0         ghcr.io/thomaszachmann/notes-api:0.7.1
notes-7b857f8796   0         ghcr.io/thomaszachmann/notes-api:0.7.1
notes-95fd5cfc5    0         ghcr.io/thomaszachmann/notes-api:0.5.3

Das Umschalten passiert in einem Schritt, indem Rollouts den Selektor von notes-stable ändert. Die alten Pods laufen danach noch 30 Sekunden weiter, damit offene Verbindungen sauber enden. Erst dann skaliert Rollouts sie auf null.

Fortschritt speichern? Kostenlos registrieren

Kontrollpunkt

kubectl argo rollouts status notes -n notes-rollout --timeout 30s

Erwartet: Healthy.

kubectl -n notes-rollout get analysisrun

Erwartet: eine Successful und eine Failed.

argocd app get notes-rollout | grep -E "Sync Status|Health Status"

Erwartet: Synced und Healthy.

curl -s localhost:30085/version

Erwartet: 0.7.0.

Challenge

Stell notes-rollout wieder auf 0.7.1. Prüfe die Vorschau, entscheide dich gegen den Wechsel und brich ihn ab. Wie bekommst du Argo CD danach wieder auf Healthy?

Hinweis: Neben promote kennt das Plugin abort.

Lösung

cd ~/argo-lab/argocd-fleet
git pull
sed -i "s/notes-api:0.7.0/notes-api:0.7.1/" apps/notes-rollout/rollout.yaml
git commit -am "notes-rollout: wieder 0.7.1"
git push
argocd app get notes-rollout --refresh
sleep 40
curl -s localhost:30085/version
curl -s localhost:30086/version
kubectl argo rollouts abort notes -n notes-rollout
sleep 10
kubectl argo rollouts get rollout notes -n notes-rollout | sed -n 3,7p
argocd app get notes-rollout | grep -E "Sync Status|Health Status"

Erwartet:

0.7.0
0.7.1
rollout 'notes' aborted
Status:          ✖ Degraded
Message:         RolloutAborted: Rollout aborted update to revision 7
Strategy:        BlueGreen
Images:          ghcr.io/thomaszachmann/notes-api:0.7.0 (stable, active)
                 ghcr.io/thomaszachmann/notes-api:0.7.1 (preview)
Sync Status:        Synced to main (ef21df2)
Health Status:      Degraded

Wie in Drill 5 bleibt der Abbruch Degraded, bis Git wieder die laufende Version beschreibt:

git revert --no-edit HEAD
git push
argocd app get notes-rollout --refresh
sleep 20
argocd app get notes-rollout | grep -E "Sync Status|Health Status"

Erwartet (gekürzt):

…
Sync Status:        Synced to main (f5bb443)
Health Status:      Healthy

Fortschritt speichern? Kostenlos registrieren

Enterprise-Notiz

  • Echte Gewichte wie 5 % unabhängig von der Zahl der Pods bekommt man mit trafficRouting, etwa über einen Ingress-Controller, die Gateway API oder ein Service-Mesh.
  • Statt eines Jobs fragt eine Analyse meist Prometheus ab, etwa die Fehlerquote des Canary. Das zeigt das Buch zu Observability.
  • Der Image Updater und Rollouts ergänzen sich: Der eine schreibt die neue Version nach Git, der andere bringt sie vorsichtig in den Cluster.
  • Ein abgebrochener Rollout bleibt Degraded, bis jemand Git korrigiert. Eine Notification auf on-health-degraded sorgt dafür, dass das nicht unbemerkt bleibt.