Tag 18: CI und GitOps
Ziel: Ein Chart in einer Pipeline prüfen, unveränderlich veröffentlichen und wissen, was Flux und Argo CD mit einem Chart anders machen als
helm upgrade. · Dauer: ca. 90 min · Voraussetzung: Tag 17
Briefing
- chart-testing (
ct) vergleicht gegen den Zielzweig: Jede Änderung an einem Chart braucht eine neue Version.ct installinstalliert in einen Cluster und rufthelm test. - Eine Version wird genau einmal veröffentlicht, per Digest signiert und per Digest ausgerollt.
- Flux (helm-controller) benutzt das Helm-SDK: echte Releases,
lookup, echte Hooks. - Argo CD rendert mit
helm templateund wendet selbst an: kein Release,lookupleer, Hooks werden Argo-Hooks. - Mehr zu den Werkzeugen: „GitHub Actions zum Anfassen“, „Flux zum Anfassen“ (Tag 6–7), „GitOps mit Argo CD zum Anfassen“ (Tag 5). Hier nur, was Chart-Autoren wissen müssen.
Drill 1: ct lint verlangt eine neue Version
chart-testing als Binärdatei; yamllint kommt aus Ubuntu. Yamale
(Schema von Chart.yaml) ist nur per pip zu haben – im Labor
bleibt diese Prüfung aus, in CI bringt die chart-testing-Action beides
mit.
# auf prod
mkdir -p ~/helm/tag18/bin && cd ~/helm/tag18/bin
ARCH=$(dpkg --print-architecture)
U=https://github.com/helm/chart-testing/releases/download/v3.15.0
curl -fsSLO $U/chart-testing_3.15.0_linux_$ARCH.tar.gz && curl -fsSLO $U/checksums.txt
grep " chart-testing_3.15.0_linux_$ARCH.tar.gz$" checksums.txt | sha256sum -c
tar -xzf chart-testing_3.15.0_linux_$ARCH.tar.gz ct etc
sudo install -m 755 ct /usr/local/bin/ct
mkdir -p ~/.ct && cp etc/chart_schema.yaml etc/lintconf.yaml ~/.ct/
sudo apt-get install -y yamllint >/dev/null 2>&1
ct version | head -1; yamllint --versionErwartet:
chart-testing_3.15.0_linux_amd64.tar.gz: OK
Version: v3.15.0
yamllint 1.33.0
ct erkennt geänderte Charts über git diff
gegen <remote>/<zielzweig>. Das Labor-Repo hat
keinen Server – ein lokales Bare-Repo spielt ihn. Sein main
steht auf dem Stand von Tag 15, so als wären die Tests aus Tag 17 ein
offener Pull-Request:
# auf prod
git init -q --bare ~/helm/charts.git
cd ~/helm/charts
git remote add origin ~/helm/charts.git
git push -q origin 8daf326:refs/heads/main
git fetch -q origin
git log --oneline origin/main -1
git diff --stat origin/main -- notes | tail -1
cat > ct.yaml <<'EOF'
# ct.yaml – Stand Tag 18
chart-dirs: [.]
remote: origin
target-branch: main
validate-chart-schema: false
validate-maintainers: false
helm-dependency-extra-args: ["--plain-http"]
EOF
ct lint 2>&1 | grep -E "Charts to be|=>|chart version|✖|^Error" | uniq
echo "Exit: ${PIPESTATUS[0]}"Erwartet (gekürzt):
8daf326 Tag 15: Abhängigkeiten aus zot, notes 0.12.0, helper 0.2.1
4 files changed, 137 insertions(+), 1 deletion(-)
Charts to be processed:
notes => (version: "0.12.0", path: "notes")
Linting chart "notes => (version: \"0.12.0\", path: \"notes\")"
Checking chart "notes => (version: \"0.12.0\", path: \"notes\")" for a version bump...
Old chart version: 0.12.0
New chart version: 0.12.0
✖︎ notes => (version: "0.12.0", path: "notes") > chart version not ok. Needs a vers…
Error: failed linting charts: failed processing charts
Exit: 1
ct liest ct.yaml im aktuellen Ordner. Die
Charts liegen im Wurzelverzeichnis (chart-dirs: [.]),
ct baut die Abhängigkeiten selbst – ohne
--plain-http scheitert es an zot. Die Tests aus Tag 17
haben das Chart geändert, die Version nicht.
(--use-helmignore würde Änderungen an ignorierten Dateien
wie tests/ nicht zählen – hier hat sich aber auch
.helmignore selbst geändert.)
Fortschritt speichern? Kostenlos registrieren
Drill 2: Neue Version, ct lint und ct install
ct install nimmt jede Datei aus ci/ als
Werte-Satz. Das Secret muss im Ziel-Namespace liegen, deshalb ein fester
Namespace statt eines zufälligen:
# auf prod
sed -i 's/^version: 0.12.0/version: 0.12.1/; 1s/Stand Tag 15/Stand Tag 18/' \
notes/Chart.yaml
mkdir -p notes/ci
cat > notes/ci/default-values.yaml <<'EOF'
# notes/ci/default-values.yaml – Stand Tag 18
apiKey:
existingSecret: notes-api-key
EOF
ct lint 2>&1 | grep -E "chart version|values file|✔|successfully" | uniq
kubectl create namespace tag18
kubectl -n tag18 create secret generic notes-api-key --from-literal=api-key=lab-key-123
ct install --namespace tag18 --helm-extra-args "--timeout 180s" 2>&1 \
| grep -E 'Installing chart|^(ok|version ok|POST)|Deleting release|✔|success' \
| grep -v Readiness
helm list -n tag18 -q | wc -lErwartet:
Old chart version: 0.12.0
New chart version: 0.12.1
Linting chart with values file "notes/ci/default-values.yaml"...
✔︎ notes => (version: "0.12.1", path: "notes")
All charts linted successfully
namespace/tag18 created
secret/notes-api-key created
Installing chart "notes => (version: \"0.12.1\", path: \"notes\")"...
Installing chart with values file "notes/ci/default-values.yaml"...
deployment "notes-vqmiqwmpxf" successfully rolled out
ok
version ok
POST ohne Key: 401
Deleting release "notes-vqmiqwmpxf"...
✔︎ notes => (version: "0.12.1", path: "notes")
All charts installed successfully
0
ct install installiert mit zufälligem Release-Namen,
wartet, ruft helm test (die drei Zeilen kommen aus dem
Test-Pod von Tag 11), gibt bei Fehlern Beschreibungen und Logs aus und
deinstalliert. Der Test-Pod selbst bleibt liegen – er ist ein Hook ohne
Delete-Policy. Jetzt in den Zielzweig:
# auf prod
git add ct.yaml notes/ci notes/Chart.yaml
git commit -qm "Tag 18: ct-Konfiguration, CI-Werte, notes 0.12.1"
git push -q origin main
git log --oneline -1
ct lint 2>&1 | grep -E "No chart changes"Erwartet:
5bcd288 Tag 18: ct-Konfiguration, CI-Werte, notes 0.12.1
No chart changes detected.
Fortschritt speichern? Kostenlos registrieren
Drill 3: Veröffentlichen, Schritt für Schritt
Die Veröffentlichungsstufe einer Pipeline, von Hand: Version aus dem
Git-Tag, Abgleich mit Chart.yaml, keine Version zweimal,
schieben, per Digest signieren, per Digest ausrollen.
# auf prod
git tag notes-0.12.1
T=$(git describe --tags --exact-match); V=${T#notes-}; echo "$T -> $V"
test "$(yq .version notes/Chart.yaml)" = "$V" && echo "Chart.yaml passt"
helm show chart oci://localhost:30500/charts/notes --version $V --plain-http \
>/dev/null 2>&1 && echo "Version $V existiert schon" || echo "Version $V ist neu"
helm dependency build notes --plain-http 2>&1 | tail -1
helm package notes -d ~/helm/tag18
helm push ~/helm/tag18/notes-$V.tgz oci://localhost:30500/charts --plain-http \
2> ~/helm/tag18/push.log
D=$(awk '/^Digest/{print $2}' ~/helm/tag18/push.log); echo $D
cd ~/helm/tag16 && export COSIGN_PASSWORD=lab-cosign-123
cosign sign --key cosign.key -y --signing-config offline.json --allow-http-registry \
localhost:30500/charts/notes@$D 2>&1 | tail -1
cd ~/helm/charts
helm upgrade notes oci://localhost:30500/charts/notes@$D -n notes -f values/prod.yaml \
--plain-http --wait --rollback-on-failure --timeout 3m | grep -E '^(STATUS|REVISION)'
helm list -n notes --filter '^notes$' -o json \
| jq -r '.[0] | "\(.revision) \(.chart) \(.status)"'Erwartet (gekürzt):
notes-0.12.1 -> 0.12.1
Chart.yaml passt
Version 0.12.1 ist neu
Deleting outdated charts
Successfully packaged chart and saved it to: /home/ubuntu/helm/tag18/notes-0.12.1.tgz
Pushed: localhost:30500/charts/notes:0.12.1
Digest: sha256:4f9a83f635ada8fd6159bbab7e0daa182733c6734524724764d25256719cfdb9
error during command execution: signing [localhost:30500/charts/notes@]: parsing refer…
STATUS: deployed
REVISION: 32
32 notes-0.12.1 deployed
Drei Fehler auf einmal – genau so passieren sie in Pipelines:
helm pushschreibtPushed:undDigest:auf stdout (anders alspullundshow, Tag 15).push.logist leer,$Dauch.- cosign scheitert – aber nichts hält die nächste Zeile auf.
oci://…/notes@mit leerem Digest installiert kommentarlos die neueste Version. Die Revision 32 läuft – richtig, aber ungeprüft.
Reparieren: Digest aus der Registry holen, signieren, prüfen. Ein zweiter Lauf zeigt die Sperre gegen doppelte Versionen:
# auf prod
wc -c < ~/helm/tag18/push.log
cd ~/helm/tag16
D=$(helm show chart oci://localhost:30500/charts/notes --version 0.12.1 --plain-http \
2>&1 >/dev/null | awk '/^Digest/{print $2}')
test -n "$D" && cosign sign --key cosign.key -y --signing-config offline.json \
--allow-http-registry localhost:30500/charts/notes@$D 2>&1 | tail -1
cosign verify --key cosign.pub --allow-http-registry --insecure-ignore-tlog \
localhost:30500/charts/notes:0.12.1 >/dev/null 2>&1 && echo "notes 0.12.1 signiert"
helm test notes -n notes | grep Phase
cd ~/helm/charts
helm show chart oci://localhost:30500/charts/notes --version 0.12.1 --plain-http \
>/dev/null 2>&1 && echo "Version 0.12.1 existiert schon – Abbruch"Erwartet:
0
Pushing signature to: localhost:30500/charts/notes
notes 0.12.1 signiert
Phase: Succeeded
Version 0.12.1 existiert schon – Abbruch
In einer echten Pipeline gehören set -euo pipefail,
test -n "$D" und das
cosign verify … && vor dem Ausrollen dazu. zot
selbst überschreibt Tags (Tag 15) – die Unveränderlichkeit sichert hier
die Pipeline.
Fortschritt speichern? Kostenlos registrieren
Drill 4: Die Workflow-Datei
Dieselben Stufen als GitHub-Workflow – nur gezeigt, ausgeführt wird er im Labor nicht (Details in „GitHub Actions zum Anfassen“). Actions sind per Commit-Hash gepinnt, die Version steht als Kommentar darüber:
# auf prod
mkdir -p .github/workflows
cat > .github/workflows/chart.yaml <<'EOF'
# .github/workflows/chart.yaml – Stand Tag 18 (gezeigt, nicht ausgeführt)
name: chart
on:
pull_request:
push:
tags: ["notes-*"]
jobs:
pruefen:
runs-on: ubuntu-24.04
steps:
# v7.0.1
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
fetch-depth: 0
# v5.1.0
- uses: azure/setup-helm@2f5e7bc67f1f9972ab16657bb795f36d8f04de0e
with:
version: v4.3.2
# v2.9.0
- uses: helm/chart-testing-action@720270857a28afd41e2426521a7801db09e9b510
with:
version: v3.15.0
- run: ct lint --config ct.yaml --validate-chart-schema=true
- run: |
set -o pipefail
for env in dev staging prod; do
helm template notes ./notes -f values/$env.yaml \
| kubeconform -strict -summary -kubernetes-version 1.37.0
done
- run: helm unittest notes
veroeffentlichen:
if: startsWith(github.ref, 'refs/tags/notes-')
needs: pruefen
runs-on: ubuntu-24.04
steps:
# v7.0.1
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
# v5.1.0
- uses: azure/setup-helm@2f5e7bc67f1f9972ab16657bb795f36d8f04de0e
with:
version: v4.3.2
# v4.1.3
- uses: sigstore/cosign-installer@756fe2d284c7292c4e9b62c8a28f1e5629c59532
- run: |
set -euo pipefail
V=${GITHUB_REF_NAME#notes-}
test "$(yq .version notes/Chart.yaml)" = "$V"
if helm show chart "oci://$REGISTRY/charts/notes" --version "$V" \
>/dev/null 2>&1; then echo "Version $V existiert schon"; exit 1; fi
helm dependency build notes
helm package notes
helm push "notes-$V.tgz" "oci://$REGISTRY/charts" > push.log
D=$(awk '/^Digest/{print $2}' push.log)
test -n "$D"
cosign sign --key env://COSIGN_KEY -y "$REGISTRY/charts/notes@$D"
env:
REGISTRY: registry.example.com
COSIGN_KEY: ${{ secrets.COSIGN_KEY }}
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
EOF
yamllint -d '{extends: relaxed, rules: {line-length: {max: 88}}}' \
.github/workflows/chart.yaml && echo "yamllint ok"
git add .github && git commit -qm "Tag 18: Workflow-Datei" && git push -q origin main
git log --oneline -1Erwartet:
yamllint ok
095cf42 Tag 18: Workflow-Datei
fetch-depth: 0 braucht ct für den Vergleich
mit dem Zielzweig. Anmeldung an der Registry und die Installation von
helm-unittest und kubeconform fehlen bewusst – sie hängen an der
jeweiligen Umgebung. Ebenso die Registry-Adresse der Abhängigkeiten in
Chart.yaml (noch localhost:30500) und, bei
einer internen Registry, die Signing-Config aus Tag 16 – ohne sie landet
die Signatur im öffentlichen Rekor. Das Ausrollen übernimmt in der
GitOps-Welt nicht die Pipeline, sondern Flux oder Argo CD.
Fortschritt speichern? Kostenlos registrieren
Drill 5: Flux zieht das Chart aus zot
Ein kleines Prüf-Chart zeigt die Unterschiede: eine ConfigMap mit
lookup und .Release.Revision, dazu ein
Hook-Job.
# auf prod
cd ~/helm/tag18 && mkdir -p probe/templates
cat > probe/Chart.yaml <<'EOF'
# probe/Chart.yaml – Stand Tag 18
apiVersion: v2
name: probe
version: 0.1.0
EOF
cat > probe/templates/configmap.yaml <<'EOF'
{{/* probe/templates/configmap.yaml – Stand Tag 18 */}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-probe
data:
lookup: {{ dig "metadata" "uid" "leer" (lookup "v1" "Namespace" "" "kube-system")
| quote }}
revision: {{ .Release.Revision | quote }}
EOF
cat > probe/templates/hook.yaml <<'EOF'
{{/* probe/templates/hook.yaml – Stand Tag 18 */}}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ .Release.Name }}-hook
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-delete-policy": before-hook-creation
spec:
template:
spec:
restartPolicy: Never
containers:
- name: hook
image: curlimages/curl:8.23.0
command: ["sh", "-c", "echo Hook gelaufen"]
EOF
helm template p ./probe -s templates/configmap.yaml | tail -3
helm package probe -d . && helm push probe-0.1.0.tgz oci://localhost:30500/charts \
--plain-http
cd ~/helm/tag16 && export COSIGN_PASSWORD=lab-cosign-123
D=$(helm show chart oci://localhost:30500/charts/probe --version 0.1.0 --plain-http \
2>&1 >/dev/null | awk '/^Digest/{print $2}')
cosign sign --key cosign.key -y --signing-config offline.json --allow-http-registry \
localhost:30500/charts/probe@$D 2>&1 | tail -1Erwartet (gekürzt):
lookup: "leer"
revision: "1"
Successfully packaged chart and saved it to: /home/ubuntu/helm/tag18/probe-0.1.0.tgz
Pushed: localhost:30500/charts/probe:0.1.0
Digest: sha256:499e3b4f3a1e566d2fc7947459c109f945a52ef7fbd5458eb395bf1fe276e8a6
Pushing signature to: localhost:30500/charts/probe
dig statt .metadata.uid: Ein leeres
lookup ergibt eine leere Map, ein direkter Feldzugriff
bräche ab. Flux-CLI mit Prüfsumme, nur die zwei Controller für Helm
(RAM):
# auf prod
cd ~/helm/tag18/bin
U=https://github.com/fluxcd/flux2/releases/download/v2.10.0
curl -fsSLO $U/flux_2.10.0_linux_$ARCH.tar.gz
curl -fsSLO $U/flux_2.10.0_checksums.txt
grep " flux_2.10.0_linux_$ARCH.tar.gz$" flux_2.10.0_checksums.txt | sha256sum -c
tar -xzf flux_2.10.0_linux_$ARCH.tar.gz flux && sudo install -m 755 flux /usr/local/bin/
flux version --client
flux install --components=source-controller,helm-controller 2>&1 | tail -2
kubectl -n flux-system get deploy \
-o jsonpath='{range .items[*]}{.spec.template.spec.containers[0].image}{"\n"}{end}'Erwartet:
flux_2.10.0_linux_amd64.tar.gz: OK
flux: v2.10.0
✔ source-controller: deployment ready
✔ install finished
ghcr.io/fluxcd/helm-controller:v1.7.1
ghcr.io/fluxcd/source-controller:v1.10.1
Aus dem Cluster heißt zot nicht localhost:30500, sondern
zot.zot.svc.cluster.local:5000. Die Quelle prüft die
cosign-Signatur aus Tag 16:
# auf prod
kubectl create namespace tag18f
kubectl -n tag18f create secret docker-registry zot-auth \
--docker-server=zot.zot.svc.cluster.local:5000 \
--docker-username=lab-zot-user --docker-password=lab-zot-123
kubectl -n tag18f create secret generic cosign-pub \
--from-file=cosign.pub=$HOME/helm/tag16/cosign.pub
cat > ~/helm/tag18/flux-probe.yaml <<'EOF'
# ~/helm/tag18/flux-probe.yaml – Stand Tag 18
apiVersion: source.toolkit.fluxcd.io/v1
kind: OCIRepository
metadata:
name: probe
namespace: tag18f
spec:
url: oci://zot.zot.svc.cluster.local:5000/charts/probe
ref:
semver: "0.1.x"
interval: 5m
insecure: true
secretRef:
name: zot-auth
verify:
provider: cosign
secretRef:
name: cosign-pub
layerSelector:
mediaType: application/vnd.cncf.helm.chart.content.v1.tar+gzip
operation: copy
---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: probe
namespace: tag18f
spec:
interval: 10m
chartRef:
kind: OCIRepository
name: probe
install:
crds: CreateReplace
upgrade:
crds: CreateReplace
EOF
kubectl apply -f ~/helm/tag18/flux-probe.yaml
sleep 30
flux get sources oci -n tag18f
flux get helmreleases -n tag18fErwartet (gekürzt):
namespace/tag18f created
secret/zot-auth created
secret/cosign-pub created
ocirepository.source.toolkit.fluxcd.io/probe created
helmrelease.helm.toolkit.fluxcd.io/probe created
NAME REVISION SUSPENDED READY MESSAGE
probe 0.1.0@sha256:499e3b4f False True stored artifact for digest '0.1.0@sha2…
NAME REVISION SUSPENDED READY MESSAGE
probe 0.1.0+499e3b4f3a1e False True Helm install succeeded for release tag18f…
layerSelector nimmt die Chart-Schicht des OCI-Artefakts;
crds: CreateReplace installiert und
aktualisiert CRDs aus crds/ – genau das, was Helm
selbst nicht tut (Tag 12). Standard ist Create bei der
Installation und Skip beim Upgrade.
Fortschritt speichern? Kostenlos registrieren
Drill 6: Was Flux aus dem Release macht
# auf prod
kubectl -n tag18f get ocirepository probe \
-o jsonpath='{range .status.conditions[*]}{.type}={.status}{"\n"}{end}'
helm list -n tag18f
helm get metadata probe -n tag18f | grep -E 'APPLY|^VERSION'
kubectl -n tag18f get cm probe-probe -o jsonpath='{.data.lookup}{"\n"}'
kubectl -n tag18f logs job/probe-hook
kubectl -n tag18f get cm probe-probe --show-managed-fields -o json \
| jq -r '.metadata.managedFields[] | [.manager,.operation] | @tsv'Erwartet (gekürzt):
Ready=True
ArtifactInStorage=True
SourceVerified=True
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
probe tag18f 1 … deployed probe-0.1.0+499e3b4f3a1e
VERSION: 0.1.0+499e3b4f3a1e
APPLY_METHOD: server-side apply
062efa14-7d3b-44dd-8c30-06e5a795eee5
Hook gelaufen
helm-controller Apply
Für den Chart-Autor ändert sich wenig: Es gibt einen echten Release
(helm list, helm history, Rollback),
lookup sieht den Cluster, Hooks laufen als Helm-Hooks.
Unterschiede: Flux hängt den Digest als Build-Metadaten an die Version;
der Field Manager heißt helm-controller statt
helm – wer einen von Hand installierten Release an Flux
übergibt, riskiert SSA-Konflikte wie in Tag 14, sobald Flux ein Feld
anders setzt als zuletzt helm; neue Releases laufen per
Server-Side Apply. Ein unsigniertes Chart lässt Flux nicht herein:
# auf prod
cat > ~/helm/tag18/flux-unsigniert.yaml <<'EOF'
# ~/helm/tag18/flux-unsigniert.yaml – Stand Tag 18
apiVersion: source.toolkit.fluxcd.io/v1
kind: OCIRepository
metadata:
name: postgres
namespace: tag18f
spec:
url: oci://zot.zot.svc.cluster.local:5000/charts/postgres
ref:
tag: "0.1.0"
interval: 5m
insecure: true
secretRef:
name: zot-auth
verify:
provider: cosign
secretRef:
name: cosign-pub
EOF
kubectl apply -f ~/helm/tag18/flux-unsigniert.yaml
sleep 15
kubectl -n tag18f get ocirepository postgres \
-o jsonpath='{.status.conditions[?(@.type=="SourceVerified")].message}{"\n"}' \
| fold -w 88Erwartet (gekürzt):
ocirepository.source.toolkit.fluxcd.io/postgres created
failed to verify the signature using provider 'cosign': no matching signatures were fo
und for 'zot.zot.svc.cluster.local:5000/charts/postgres@sha256:c5891446…'
Flux 2.10 versteht die Sigstore-Bundles von cosign 3 (Referrers) – das Tor aus Tag 16 sitzt jetzt im Cluster. Flux wieder entfernen (der Speicher reicht nicht für Flux und Argo CD zugleich):
# auf prod
ps -eo rss,comm | grep -E "helm-controller|source-contr"
kubectl delete -f ~/helm/tag18/flux-unsigniert.yaml -f ~/helm/tag18/flux-probe.yaml
sleep 5
helm list -n tag18f -q | wc -l
flux uninstall --silent 2>&1 | tail -1
kubectl delete namespace tag18fErwartet:
92068 source-controll
90492 helm-controller
ocirepository.source.toolkit.fluxcd.io "postgres" deleted from tag18f namespace
ocirepository.source.toolkit.fluxcd.io "probe" deleted from tag18f namespace
helmrelease.helm.toolkit.fluxcd.io "probe" deleted from tag18f namespace
0
✔ uninstall finished
namespace "tag18f" deleted
Das Löschen der HelmRelease deinstalliert den Release. Zusammen brauchen die zwei Controller rund 180 MB.
Fortschritt speichern? Kostenlos registrieren
Drill 7: Argo CD rendert nur
Argo CD core: ohne API-Server, ohne Benutzerverwaltung, gesteuert über Kubernetes-Objekte. Manifest vom Release-Tag, CLI mit Prüfsumme:
# auf prod
mkdir -p ~/helm/tag18/argo && cd ~/helm/tag18/argo
M=https://raw.githubusercontent.com/argoproj/argo-cd/v3.6.2/manifests
curl -fsSLO $M/core-install.yaml
yq -N 'select(.kind=="Deployment" or .kind=="StatefulSet")
| .kind + " " + .metadata.name' \
core-install.yaml
kubectl create namespace argocd
kubectl apply -n argocd --server-side -f core-install.yaml | tail -1
kubectl -n argocd wait --for=condition=Available deploy --all --timeout 180s
kubectl -n argocd rollout status statefulset argocd-application-controller \
--timeout 180s
U=https://github.com/argoproj/argo-cd/releases/download/v3.6.2
curl -fsSLO $U/argocd-linux-$ARCH && curl -fsSLO $U/cli_checksums.txt
grep " argocd-linux-$ARCH$" cli_checksums.txt | sha256sum -c
sudo install -m 755 argocd-linux-$ARCH /usr/local/bin/argocd
argocd version --client --short
free -m | sed -n 2pErwartet (gekürzt):
Deployment argocd-applicationset-controller
Deployment argocd-redis
Deployment argocd-repo-server
StatefulSet argocd-application-controller
namespace/argocd created
networkpolicy.networking.k8s.io/argocd-repo-server-network-policy serverside-applied
deployment.apps/argocd-applicationset-controller condition met
deployment.apps/argocd-redis condition met
deployment.apps/argocd-repo-server condition met
partitioned roll out complete: 1 new pods have been updated...
argocd-linux-amd64: OK
argocd: v3.6.2+8e8268e
Mem: 3915 2193 209 86 1884 1721
Repository mit OCI-Zugang (HTTP, deshalb
insecureOCIForceHttp) und eine Application –
repoURL ohne oci://:
# auf prod
cat > ~/helm/tag18/argo-probe.yaml <<'EOF'
# ~/helm/tag18/argo-probe.yaml – Stand Tag 18
apiVersion: v1
kind: Secret
metadata:
name: zot-charts
namespace: argocd
labels:
argocd.argoproj.io/secret-type: repository
stringData:
type: helm
name: zot
url: zot.zot.svc.cluster.local:5000/charts
enableOCI: "true"
insecureOCIForceHttp: "true"
username: lab-zot-user
password: lab-zot-123
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: probe
namespace: argocd
spec:
project: default
source:
repoURL: zot.zot.svc.cluster.local:5000/charts
chart: probe
targetRevision: 0.1.0
destination:
server: https://kubernetes.default.svc
namespace: tag18a
syncPolicy:
automated: {}
syncOptions:
- CreateNamespace=true
- ServerSideApply=true
EOF
kubectl apply -f ~/helm/tag18/argo-probe.yaml
sleep 40
kubectl -n argocd get application probe \
-o jsonpath='{.status.conditions[0].message}{"\n"}'Erwartet:
secret/zot-charts created
application.argoproj.io/probe created
Application referencing project default which does not exist
Das Core-Manifest legt das Projekt default nicht an –
sonst erledigt das der API-Server. Projekt nachreichen; die Application
merkt es erst nach einem harten Refresh:
# auf prod
cat > ~/helm/tag18/argo-project.yaml <<'EOF'
# ~/helm/tag18/argo-project.yaml – Stand Tag 18
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
name: default
namespace: argocd
spec:
sourceRepos: ["*"]
destinations:
- server: https://kubernetes.default.svc
namespace: "*"
clusterResourceWhitelist:
- group: "*"
kind: "*"
EOF
kubectl apply -f ~/helm/tag18/argo-project.yaml
kubectl -n argocd annotate application probe argocd.argoproj.io/refresh=hard --overwrite
sleep 40
kubectl -n argocd get application probe \
-o jsonpath='{.status.sync.status} {.status.health.status}{"\n"}'
helm list -n tag18a
kubectl -n tag18a get secret -l owner=helm 2>&1
kubectl -n tag18a get cm probe-probe -o jsonpath='{.data}{"\n"}'
kubectl -n tag18a get job probe-hook -o jsonpath='{.metadata.annotations}{"\n"}' \
| fold -w 88
kubectl -n tag18a get cm probe-probe --show-managed-fields -o json \
| jq -r '.metadata.managedFields[] | [.manager,.operation] | @tsv'Erwartet:
appproject.argoproj.io/default created
application.argoproj.io/probe annotated
Synced Healthy
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
No resources found in tag18a namespace.
{"lookup":"leer","revision":"1"}
{"argocd.argoproj.io/tracking-id":"probe:batch/Job:tag18a/probe-hook","helm.sh/hook":"po
st-install,post-upgrade","helm.sh/hook-delete-policy":"before-hook-creation"}
argocd-controller Apply
Kein Release, kein Release-Secret, lookup leer,
.Release.Revision ewig 1. Den Hook-Job hat Argo CD trotzdem
ausgeführt: Es übersetzt
post-install/post-upgrade in einen
PostSync-Hook (Anker-Symbol im Baum). Field Manager ist
argocd-controller. Eine Oberfläche hat Argo CD core nicht
im Cluster – die CLI startet sie lokal
(argocd admin dashboard -n argocd --port 8085 --address 127.0.0.1,
vom Mac per SSH-Tunnel ssh -L 18085:127.0.0.1:8085):
Aufräumen – mit einer letzten Falle:
# auf prod
kubectl -n argocd delete application probe
sleep 5
kubectl -n tag18a get cm,job --no-headers | awk '{print $1}'
kubectl delete namespace tag18a
kubectl delete -n argocd -f ~/helm/tag18/argo/core-install.yaml --wait 2>&1 | tail -1
kubectl delete namespace argocd
kubectl get crd | grep -c argoprojErwartet:
application.argoproj.io "probe" deleted from argocd namespace
configmap/kube-root-ca.crt
configmap/probe-probe
job.batch/probe-hook
namespace "tag18a" deleted
networkpolicy.networking.k8s.io "argocd-repo-server-network-policy" deleted from …
namespace "argocd" deleted
0
Ohne den Finalizer
resources-finalizer.argocd.argoproj.io lässt das Löschen
der Application alle Objekte stehen – bei Flux verschwindet mit der
HelmRelease der Release.
Fortschritt speichern? Kostenlos registrieren
Drill 8: Kustomize mit helmCharts
Kustomize kann ein Chart rendern und danach patchen – ebenfalls über
helm template:
# auf prod
mkdir -p ~/helm/tag18/kust/charts && cd ~/helm/tag18/kust
cp -r ../probe charts/
cat > kustomization.yaml <<'EOF'
# ~/helm/tag18/kust/kustomization.yaml – Stand Tag 18
namespace: tag18k
helmCharts:
- name: probe
releaseName: k
labels:
- pairs: {team: plattform}
includeSelectors: false
EOF
kubectl kustomize . 2>&1 | tail -1
kubectl kustomize --enable-helm . 2>&1 | tail -1 | fold -w 88
printf '# probe/values.yaml – Stand Tag 18 (leer)\n' > charts/probe/values.yaml
kubectl kustomize --enable-helm . \
| grep -E '^kind:|lookup:|helm.sh/hook:|team:|namespace:'Erwartet:
`: must specify --enable-helm
error: evalsymlink failure on '/home/ubuntu/helm/tag18/kust/charts/probe/values.yaml' :
lstat /home/ubuntu/helm/tag18/kust/charts/probe/values.yaml: no such file or directory
lookup: leer
kind: ConfigMap
team: plattform
kind: Job
helm.sh/hook: post-install,post-upgrade
team: plattform
Drei Befunde mit Kustomize 5.8.1 (in kubectl 1.37): Helm muss
ausdrücklich erlaubt werden, das Chart braucht eine
values.yaml (auch eine leere), und das Chart muss unterhalb
der kustomization.yaml liegen (charts/). Vor
allem aber: namespace: wirkt nicht auf die gerenderten
Objekte – keine einzige namespace:-Zeile. Der Hook ist ein
ganz normaler Job:
# auf prod
kubectl create namespace tag18k
kubectl kustomize --enable-helm . | kubectl apply -n tag18k --server-side -f -
sleep 8
helm list -n tag18k -q | wc -l
kubectl -n tag18k get cm k-probe -o jsonpath='{.data.lookup}{"\n"}'
kubectl -n tag18k get job k-hook -o jsonpath='{.status.succeeded}{"\n"}'
kubectl delete namespace tag18kErwartet:
namespace/tag18k created
configmap/k-probe serverside-applied
job.batch/k-hook serverside-applied
0
leer
1
namespace "tag18k" deleted
helm upgrade / Flux |
Argo CD | Kustomize helmCharts |
|
|---|---|---|---|
Release, helm list, Rollback |
ja | nein (eigene Historie) | nein |
lookup |
Cluster | leer | leer |
| Hooks | Helm-Hooks | Sync-Hooks (übersetzt) | normale Objekte |
| CRD-Updates | Flux: crds: CreateReplace |
SSA, CRDs wie alles andere | wie alles andere |
Faustregel: Eigene Anwendungen mit Varianten pro Umgebung →
Helm-Chart mit Werte-Dateien. Fremde Charts mit kleinen Änderungen, die
das Chart nicht vorsieht → Kustomize über dem Rendering (oder
Post-Renderer, Tag 14). Charts, die mit Argo CD laufen sollen, dürfen
sich nicht auf lookup, .Release.Revision oder
.Release.IsUpgrade verlassen.
Fortschritt speichern? Kostenlos registrieren
Übung: Speed-Drills
- Welche Charts würde
ct lintjetzt prüfen? Zeitziel: 20 s - Welcher Digest gehört zu
notes0.12.1 in zot? Zeitziel: 20 s - Ist
notes0.12.1 signiert? Zeitziel: 30 s - Welche Chart-Version läuft im Release
notes? Nur die Version. Zeitziel: 15 s
Lösung
# auf prod
cd ~/helm/charts
ct lint 2>&1 | grep -E "No chart changes|=>" | head -2
helm show chart oci://localhost:30500/charts/notes --version 0.12.1 --plain-http \
2>&1 >/dev/null | awk '/^Digest/{print $2}'
cosign verify --key ~/helm/tag16/cosign.pub --allow-http-registry \
--insecure-ignore-tlog localhost:30500/charts/notes:0.12.1 >/dev/null 2>&1 \
&& echo signiert
helm list -n notes --filter '^notes$' -o json | jq -r '.[0].chart'Erwartet:
No chart changes detected.
sha256:4f9a83f635ada8fd6159bbab7e0daa182733c6734524724764d25256719cfdb9
signiert
notes-0.12.1
Fortschritt speichern? Kostenlos registrieren
Kontrollpunkt
# auf prod
helm list -n notes --filter '^notes$'Erwartet: Revision 32, notes-0.12.1,
deployed.
# auf prod
helm test notes -n notes | grep PhaseErwartet: Phase: Succeeded
# auf prod
kubectl get ns -o name | grep -cE 'flux|argo|tag18[afk]'Erwartet: 0 – keine Reste von Flux,
Argo CD oder den Drill-Namespaces; tag18 räumt „Aufräumen“
weg.
Challenge
Veröffentliche probe 0.1.1 (mit
values.yaml) nach den Regeln aus Drill 3 und 4: Version
prüfen, schieben, Digest von stdout, signieren, Signatur prüfen. Lass
dieselbe Logik zweimal laufen – der zweite Lauf muss abbrechen.
Hinweis: Eine Schleife über zwei Läufe reicht;
test -n "$D" gehört vor cosign sign.
Lösung
# auf prod
cd ~/helm/tag18
printf '# probe/values.yaml – Stand Tag 18 (leer)\n' > probe/values.yaml
sed -i 's/^version: 0.1.0/version: 0.1.1/' probe/Chart.yaml
K=~/helm/tag16
for lauf in 1 2; do
V=$(yq .version probe/Chart.yaml)
if helm show chart oci://localhost:30500/charts/probe --version "$V" --plain-http \
>/dev/null 2>&1; then echo "Lauf $lauf: $V existiert schon – Abbruch"; continue; fi
helm package probe >/dev/null
D=$(helm push probe-$V.tgz oci://localhost:30500/charts --plain-http \
| awk '/^Digest/{print $2}')
test -n "$D" || { echo "kein Digest"; continue; }
cosign sign --key $K/cosign.key -y --signing-config $K/offline.json \
--allow-http-registry localhost:30500/charts/probe@$D >/dev/null 2>&1
cosign verify --key $K/cosign.pub --allow-http-registry --insecure-ignore-tlog \
localhost:30500/charts/probe@$D >/dev/null 2>&1 \
&& echo "Lauf $lauf: probe $V veröffentlicht und signiert (${D:0:19}…)"
doneErwartet:
Lauf 1: probe 0.1.1 veröffentlicht und signiert (sha256:2e6c50272def…)
Lauf 2: 0.1.1 existiert schon – Abbruch
Mit semver: "0.1.x" hätte Flux 0.1.1 beim nächsten
Abgleich von selbst gezogen – geprüft und per Digest. Genau dafür ist
die Unveränderlichkeit wichtig: Ein überschriebener Tag würde in allen
Clustern still ausgetauscht.
Fortschritt speichern? Kostenlos registrieren
Aufräumen
# auf prod
kubectl -n tag18 get pods --no-headers | awk '{print $1}'
kubectl delete namespace tag18Erwartet:
notes-vqmiqwmpxf-test
namespace "tag18" deleted
Der Test-Pod von ct install war noch da (Drill 2). Das
lokale Remote ~/helm/charts.git, der Git-Tag
notes-0.12.1, probe 0.1.0/0.1.1 in zot und die
CLIs (ct, flux, argocd)
bleiben.
Interview-Notiz
- Was prüft chart-testing zusätzlich zu
helm lint? Nur geänderte Charts gegen den Zielzweig, Versionserhöhung, YAML-Lint, Schema vonChart.yaml, jedeci/-Werte- Datei;ct installinstalliert und rufthelm test. - Worin unterscheiden sich Flux und Argo CD für einen
Chart-Autor? Flux nutzt das Helm-SDK (echter Release,
lookup, Helm-Hooks), Argo CD rendert mithelm templateund wendet selbst an (kein Release,lookupleer, Hooks als Sync-Hooks). - Wie stellst du sicher, dass eine Chart-Version unveränderlich ist? Pipeline bricht ab, wenn die Version existiert; Installation per Digest; Registry mit unveränderlichen Tags, wo verfügbar; Signatur-Prüfung im GitOps-Werkzeug.
Enterprise-Notiz
- Pipelines mit
set -euo pipefail, Tor vor jedem Ausrollen (cosign verify … &&), kein Schritt verlässt sich auf eine Variable, die nicht geprüft wurde. - Charts für Argo-CD-Umgebungen ohne
lookupund ohne zufällige Werte bauen (randAlphaNumerzeugt bei jedem Rendern einen Diff). Secrets von außen (Tag 16). - Beim Wechsel von manuellem Helm zu Flux den Field Manager bedenken
(
helm→helm-controller) und die Übernahme mit--force-conflicts-Äquivalent oder frischer Installation planen. - Argo CD: Finalizer an Applications setzen, sonst bleiben beim
Löschen verwaiste Objekte.
ServerSideApply=truefür große CRDs. - Renovate oder Flux-Image-Automation halten Chart-Versionen in Git aktuell – mit derselben Pipeline als Tor.