Day 17: Lint, kubeconform and helm-unittest
Goal: Check a chart without a cluster for typos, schema violations, insecure settings and outdated APIs, and pin down its behavior with unit tests. · Duration: approx. 75 min · Prerequisite: Day 16
Briefing
helm lintchecks the chart (structure, values schema, template syntax), not the Kubernetes schema of the rendered objects.helm template | kubeconform -strictchecks every object against the OpenAPI schema – per environment, so per values file.kubectl apply --dry-run=serverasks a real API server (staging),trivy configlooks for insecure settings,plutofor outdated APIs.- helm-unittest renders locally and checks paths in the result: one test for every condition in the template.
helm lint ─▶ helm unittest ─▶ helm template | kubeconform ─▶ trivy / pluto
(chart) (behavior) (schema per environment) (security, APIs)
└─▶ kubectl apply --dry-run=server (staging)
Drill 1: Tools
trivy does not name its archives after the Debian architecture – a
case translates:
# on prod
mkdir -p ~/helm/tag17/bin && cd ~/helm/tag17/bin
ARCH=$(dpkg --print-architecture)
case $ARCH in amd64) TA=64bit ;; arm64) TA=ARM64 ;; esac
K=https://github.com/yannh/kubeconform/releases/download/v0.8.0
P=https://github.com/FairwindsOps/pluto/releases/download/v5.24.5
T=https://github.com/aquasecurity/trivy/releases/download/v0.76.2
curl -fsSLO $K/kubeconform-linux-$ARCH.tar.gz && curl -fsSLO $K/CHECKSUMS
curl -fsSLO $P/pluto_5.24.5_linux_$ARCH.tar.gz && curl -fsSLO $P/checksums.txt
curl -fsSLO $T/trivy_0.76.2_Linux-$TA.tar.gz
curl -fsSLO $T/trivy_0.76.2_checksums.txt
grep " kubeconform-linux-$ARCH.tar.gz$" CHECKSUMS | sha256sum -c
grep " pluto_5.24.5_linux_$ARCH.tar.gz$" checksums.txt | sha256sum -c
grep " trivy_0.76.2_Linux-$TA.tar.gz$" trivy_0.76.2_checksums.txt | sha256sum -c
tar -xzf kubeconform-linux-$ARCH.tar.gz kubeconform
tar -xzf pluto_5.24.5_linux_$ARCH.tar.gz pluto
tar -xzf trivy_0.76.2_Linux-$TA.tar.gz trivy
sudo install -m 755 kubeconform pluto trivy /usr/local/bin/
kubeconform -v; pluto version | cut -d' ' -f1; trivy --version | head -1Expected:
kubeconform-linux-amd64.tar.gz: OK
pluto_5.24.5_linux_amd64.tar.gz: OK
trivy_0.76.2_Linux-64bit.tar.gz: OK
v0.8.0
Version:5.24.5
Version: 0.76.2
Save your progress? Sign up for free
Drill 2: What helm lint sees – and what it doesn’t
# on prod
cd ~/helm/charts
helm lint notes --strict -f values/prod.yaml
helm lint notes --strict --with-subcharts -f values/prod.yaml | grep -E 'Linting|linted'Expected:
==> Linting notes
[INFO] Chart.yaml: icon is recommended
1 chart(s) linted, 0 chart(s) failed
==> Linting notes
==> Linting notes/charts/plattform-0.1.0.tgz
==> Linting notes/charts/postgres-0.1.0.tgz
3 chart(s) linted, 0 chart(s) failed
--strict turns warnings into errors,
--with-subcharts checks the dependencies as well. Now a
typo in the template – in a copy:
# on prod
cd ~/helm/tag17 && cp -r ~/helm/charts/notes .
sed -i 's/^ replicas:/ replica:/' notes/templates/deployment.yaml
helm lint notes --strict -f ~/helm/charts/values/prod.yaml | tail -1
helm template notes ./notes -f ~/helm/charts/values/prod.yaml \
-s templates/deployment.yaml | grep -A1 '^spec:'Expected:
1 chart(s) linted, 0 chart(s) failed
spec:
replica: 2
replica is valid YAML, and Helm does not know the
Kubernetes schema while linting. A typo in the values
(replicaCont: 3), on the other hand, would be caught – the
schema from Day 8 forbids unknown keys.
Save your progress? Sign up for free
Drill 3: kubeconform for every environment
# on prod
cd ~/helm/charts
for env in dev staging prod; do
echo "== $env"; helm template notes ./notes -f values/$env.yaml 2>/dev/null \
| kubeconform -strict -summary
doneExpected:
== dev
Summary: 0 resource found parsing stdin - Valid: 0, Invalid: 0, Errors: 0, Skipped: 0
== staging
Summary: 0 resource found parsing stdin - Valid: 0, Invalid: 0, Errors: 0, Skipped: 0
== prod
Summary: 10 resources found parsing stdin - Valid: 10, Invalid: 0, Errors: 0, Skipped: 0
Zero resources and no errors – a green pipeline that checked nothing. The reason:
# on prod
set -o pipefail
helm template notes ./notes -f values/dev.yaml 2>&1 >/dev/null | head -1 | fold -w 88
helm template notes ./notes -f values/dev.yaml 2>/dev/null \
| kubeconform -strict -summary >/dev/null 2>&1; echo "Exit: $?"Expected:
Error: execution error at (notes/templates/deployment.yaml:35:27): apiKey.existingSecret
fehlt
Exit: 1
Since Day 8, apiKey.existingSecret is required
(fehlt = missing), but dev.yaml and
staging.yaml have not grown along since Day 3. Without
pipefail, only the exit code of the last command in a pipe
counts. Fix both files, then run again – plus the copy with the
typo:
# on prod
for env in dev staging; do
yq -i '.apiKey.existingSecret = "notes-api-key"' values/$env.yaml
sed -i "1s/Stand Tag 03/Stand Tag 17/" values/$env.yaml
done
cat values/dev.yaml
for env in dev staging prod; do
echo "== $env"; helm template notes ./notes -f values/$env.yaml \
| kubeconform -strict -summary
done
helm template notes ~/helm/tag17/notes -f values/prod.yaml \
| kubeconform -strict -summary \
| grep -oE "Deployment notes is invalid|at '/spec'.*|Summary.*"Expected:
# values/dev.yaml – Stand Tag 17
replicaCount: 1
env:
NOTES_LOG_LEVEL: debug
NOTES_FEATURE_TAGS: "on"
apiKey:
existingSecret: notes-api-key
== dev
Summary: 6 resources found parsing stdin - Valid: 6, Invalid: 0, Errors: 0, Skipped: 0
== staging
Summary: 6 resources found parsing stdin - Valid: 6, Invalid: 0, Errors: 0, Skipped: 0
== prod
Summary: 10 resources found parsing stdin - Valid: 10, Invalid: 0, Errors: 0, Skipped: 0
Deployment notes is invalid
at '/spec': additional properties 'replica' not allowed
Summary: 10 resources found parsing stdin - Valid: 9, Invalid: 1, Errors: 0, Skipped: 0
-strict forbids additional fields – without the flag,
replica would have slipped through. kubeconform downloads
the schemas from the network (default: Kubernetes master);
with -kubernetes-version you check against the version of
the target cluster. CRDs (e.g. NoteBackup) need their own
schemas or -ignore-missing-schemas.
Save your progress? Sign up for free
Drill 4: Against a real API server
kubeconform only knows schemas. A server dry run against staging also
checks admission, defaults and quotas. tag17 plays staging
here:
# on prod
kubectl create namespace tag17
helm template notes ~/helm/tag17/notes -f values/staging.yaml -n tag17 \
| kubectl apply --dry-run=server -n tag17 -f - 2>&1 | grep -v created | fold -w 88
helm template notes ~/helm/tag17/notes -f values/staging.yaml -n tag17 \
| kubectl apply --dry-run=server --server-side -n tag17 -f - 2>&1 \
| grep -v applied | fold -w 88
helm template notes ./notes -f values/staging.yaml -n tag17 --skip-tests --no-hooks \
| kubectl apply --dry-run=server --server-side -n tag17 -f -
kubectl -n tag17 get secret notes-api-key 2>&1Expected:
namespace/tag17 created
Error from server (BadRequest): error when creating "STDIN": Deployment in version "v1"
cannot be handled as a Deployment: strict decoding error: unknown field "spec.replica"
Error from server: failed to create typed patch object (tag17/notes; apps/v1, Kind=Deplo
yment): .spec.replica: field not declared in schema
configmap/notes-config serverside-applied (server dry run)
configmap/notes-info serverside-applied (server dry run)
configmap/notes-files serverside-applied (server dry run)
service/notes serverside-applied (server dry run)
deployment.apps/notes serverside-applied (server dry run)
Error from server (NotFound): secrets "notes-api-key" not found
Both ways find the typo. helm template also renders test
Pods and hooks; --skip-tests --no-hooks leaves them out,
otherwise the dry run “creates” them too. What the dry run does not
check: references. The Secret notes-api-key is missing in
staging, so the Pod would hang in
CreateContainerConfigError. By the way, for type errors in
the chart helm install --dry-run=server is not enough (Day
4) – only kubectl apply validates strictly.
Save your progress? Sign up for free
Drill 5: Insecure settings and old APIs
# on prod
cd ~/helm/charts
helm template notes ./notes -f values/prod.yaml -n notes --skip-tests \
> ~/helm/tag17/prod.yaml
cd ~/helm/tag17
trivy config --quiet --format json prod.yaml | jq -r '.Results[].Misconfigurations[]?
| .Severity' | sort | uniq -c
trivy config --quiet --format json --severity HIGH,CRITICAL prod.yaml \
| jq -r '.Results[].Misconfigurations[]? | "\(.ID) \(.Message)"' | cut -c1-88
trivy config --quiet --severity HIGH,CRITICAL --exit-code 1 prod.yaml >/dev/null
echo "Exit: $?"Expected:
3 HIGH
19 LOW
6 MEDIUM
KSV-0014 Container 'postgres' of StatefulSet 'notes-postgres' should set 'securityContex
KSV-0118 container notes-postgres in default namespace is using the default security con
KSV-0118 statefulset notes-postgres in default namespace is using the default security c
Exit: 1
All HIGH findings hit the postgres subchart – the same
finding as the PSA probe on Day 10. notes-api with the
restricted contexts from plattform is clean.
--exit-code 1 with a severity filter turns this into a
gate; “in default namespace” comes from helm template not
writing metadata.namespace. Now outdated APIs:
# on prod
pluto detect prod.yaml; echo "Exit: $?"
cat > alt.yaml <<'EOF'
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: alt
spec:
maxUnavailable: 1
selector:
matchLabels: {app: alt}
EOF
pluto detect alt.yaml; echo "Exit: $?"
pluto detect alt.yaml --target-versions k8s=v1.20.0; echo "Exit: $?"
pluto detect-helm; echo "Exit: $?"
cd ~/helm/charts
helm lint notes -f values/prod.yaml --kube-version 1.32.0 | tail -1
helm template notes ./notes -f values/prod.yaml --kube-version 1.32.0 2>&1 \
| head -1 | fold -w 88Expected (shortened):
There were no resources found with known deprecated apiVersions.
Exit: 0
NAME KIND VERSION REPLACEMENT REMOVED DEPRECATED ...
alt PodDisruptionBudget policy/v1beta1 policy/v1 true true ...
Exit: 3
No output to display
Exit: 0
There were no resources found with known deprecated apiVersions.
Exit: 0
1 chart(s) linted, 0 chart(s) failed
Error: chart requires kubeVersion: >=1.33.0-0 which is incompatible with Kubernetes v1.3
2.0
pluto checks against a target version: for 1.20,
policy/v1beta1 was not deprecated yet. Exit 3 means
“removed”, 2 “deprecated”. detect-helm reads the stored
manifests of all releases – exactly where the problem sits that Day 19
fixes in Drill 8. helm lint ignores
kubeVersion from Chart.yaml even with
--kube-version, helm template does not.
Save your progress? Sign up for free
Drill 6: helm-unittest and the first suite
Under Helm 4 as a signed plugin archive (the project’s instructions
mention --verify=false for the Git installation – you don’t
need that with the archive):
# on prod
mkdir -p ~/helm/tag17/unittest && cd ~/helm/tag17/unittest
U=https://github.com/helm-unittest/helm-unittest/releases/download/v1.2.1
curl -fsSLO $U/unittest-1.2.1.tgz && curl -fsSLO $U/unittest-1.2.1.tgz.prov
curl -fsSL -o public-key.asc \
https://raw.githubusercontent.com/helm-unittest/helm-unittest/v1.2.1/public-key.asc
gpg --show-keys public-key.asc | sed -n 2,3p
gpg --no-default-keyring --keyring ./unittest.kbx --import public-key.asc 2>&1 | tail -1
helm plugin install unittest-1.2.1.tgz --keyring ./unittest.kbx | tail -1
helm plugin list | awk '$1=="unittest" {print $1, $2, $5}'Expected:
853008CD0B0A5A2DA04FF8A5616AD47F65B54AC7
uid helm-unittest Plugin <[email protected]>
gpg: imported: 1
Installed plugin: unittest
unittest 1.2.1 signed
Suites live in notes/tests/*_test.yaml. Every condition
in the Deployment template gets a test (the test names are German,
e.g. erzeugt genau ein Deployment = creates exactly one
Deployment):
# on prod
cd ~/helm/charts && mkdir -p notes/tests
cat > notes/tests/deployment_test.yaml <<'EOF'
# notes/tests/deployment_test.yaml – Stand Tag 17
suite: Deployment
templates:
- templates/deployment.yaml
- templates/config.yaml
release:
name: notes
set:
apiKey.existingSecret: notes-api-key
tests:
- it: erzeugt genau ein Deployment
template: templates/deployment.yaml
asserts:
- hasDocuments:
count: 1
- isKind:
of: Deployment
- it: nimmt appVersion als Image-Tag
template: templates/deployment.yaml
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: ghcr.io/thomaszachmann/notes-api:0.7.1
- it: nimmt einen gesetzten Tag
template: templates/deployment.yaml
set:
image.tag: 0.8.0-rc.1
asserts:
- matchRegex:
path: spec.template.spec.containers[0].image
pattern: :0\.8\.0-rc\.1$
- it: erlaubt null Replikas
template: templates/deployment.yaml
set:
replicaCount: 0
asserts:
- equal:
path: spec.replicas
value: 0
- it: liest den API-Key aus dem vorhandenen Secret
template: templates/deployment.yaml
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: NOTES_API_KEY
valueFrom:
secretKeyRef:
name: notes-api-key
key: api-key
- it: setzt ohne Werte keinen nodeSelector
template: templates/deployment.yaml
asserts:
- notExists:
path: spec.template.spec.nodeSelector
- it: verlangt apiKey.existingSecret
template: templates/deployment.yaml
set:
apiKey.existingSecret: ""
asserts:
- failedTemplate:
errorMessage: apiKey.existingSecret fehlt
EOF
helm unittest notesExpected (shortened):
### Chart [ notes ] notes
PASS Deployment notes/tests/deployment_test.yaml
Charts: 1 passed, 1 total
Test Suites: 1 passed, 1 total
Tests: 7 passed, 7 total
Snapshot: 0 passed, 0 total
Why is config.yaml in the list? The Deployment reads the
file via include for the checksum (Day 7). helm-unittest
renders only the templates you list – if it is missing, every test
fails:
# on prod
cp notes/tests/deployment_test.yaml ~/helm/tag17/ohne-config.yaml
yq -i 'del(.templates[1])' ~/helm/tag17/ohne-config.yaml
helm unittest notes -f ../../tag17/ohne-config.yaml 2>&1 \
| grep -m1 -A1 'error calling include'
helm unittest notes -f ../../tag17/ohne-config.yaml 2>&1 | grep '^Tests:'Expected:
error calling include:
template: no template "notes/templates/config.yaml" associated with template "gotpl"
Tests: 7 failed, 6 errored, 0 passed, 7 total
With two templates in templates:, every test needs
template:, otherwise the assertions apply to both files.
-f is relative to the chart folder.
Save your progress? Sign up for free
Drill 7: Ingress, schema and the typo
# on prod
cat > notes/tests/ingress_test.yaml <<'EOF'
# notes/tests/ingress_test.yaml – Stand Tag 17
suite: Ingress
templates:
- templates/ingress.yaml
release:
name: notes
tests:
- it: fehlt ohne enabled
asserts:
- hasDocuments:
count: 0
- it: fehlt ohne Hosts
set:
ingress.enabled: true
asserts:
- hasDocuments:
count: 0
- it: rendert Hosts mit tpl
set:
ingress.enabled: true
ingress.hosts: ["{{ .Release.Name }}.lab", "api.{{ .Release.Name }}.lab"]
asserts:
- equal:
path: spec.rules[1].host
value: api.notes.lab
- equal:
path: metadata.annotations["traefik.ingress.kubernetes.io/router.entrypoints"]
value: web
- it: setzt die Traefik-Annotation nur für traefik
set:
ingress.enabled: true
ingress.hosts: [notes.lab]
ingress.className: nginx
asserts:
- notExists:
path: metadata.annotations
EOF
cat > notes/tests/schema_test.yaml <<'EOF'
# notes/tests/schema_test.yaml – Stand Tag 17
suite: Schema
templates:
- templates/deployment.yaml
set:
apiKey.existingSecret: notes-api-key
tests:
- it: lehnt Text als Replikazahl ab
set:
replicaCount: abc
asserts:
- failedTemplate:
errorPattern: "got string, want (integer|null)"
- it: lehnt unbekannte Schlüssel ab
set:
replica: 3
asserts:
- failedTemplate:
errorPattern: "additional properties 'replica' not allowed"
EOF
helm unittest notes | grep -E 'PASS|FAIL|^Tests:'
cp -r notes/tests ~/helm/tag17/notes/
helm unittest ~/helm/tag17/notes 2>&1 | grep -E 'FAIL|^\s+- |^Tests:' | head -4Expected:
PASS Deployment notes/tests/deployment_test.yaml
PASS Ingress notes/tests/ingress_test.yaml
PASS Schema notes/tests/schema_test.yaml
Tests: 13 passed, 13 total
FAIL Deployment ../tag17/notes/tests/deployment_test.yaml
- erlaubt null Replikas
- asserts[0] `equal` fail
Tests: 1 failed, 12 passed, 13 total
helm-unittest checks the schema just like helm install
does – failedTemplate also catches schema errors. And the
typo from Drill 2 is caught by the test
erlaubt null Replikas (allows zero replicas): it looks for
spec.replicas and does not find it.
Save your progress? Sign up for free
Drill 8: Snapshots and the tests in the package
matchSnapshot stores the whole rendering and compares
against it from then on – in the copy:
# on prod
cd ~/helm/tag17
sed -i 's/^ replica:/ replicas:/' notes/templates/deployment.yaml
cat > notes/tests/snapshot_test.yaml <<'EOF'
# notes/tests/snapshot_test.yaml – Stand Tag 17
suite: Snapshot
templates:
- templates/deployment.yaml
- templates/config.yaml
set:
apiKey.existingSecret: notes-api-key
tests:
- it: bleibt wie gespeichert
template: templates/deployment.yaml
asserts:
- matchSnapshot: {}
EOF
helm unittest notes | grep -E '^(Tests|Snapshot):'
ls notes/tests/__snapshot__
sed -i 's/^version: .*/version: 0.12.1/' notes/Chart.yaml
helm unittest notes 2>&1 | grep -E 'FAIL|^\s+[-+] ' | cut -c1-70
helm unittest notes -u | grep -E '^(Tests|Snapshot):'Expected:
Tests: 14 passed, 14 total
Snapshot: 1 passed, 1 total
snapshot_test.yaml.snap
FAIL Snapshot notes/tests/snapshot_test.yaml
- helm.sh/chart: notes-0.12.0
+ helm.sh/chart: notes-0.12.1
- checksum/config: a186697cb32d9f9aaa5ec92fcf56373635ad021e
+ checksum/config: b065edf6dee5e70d94d5b95a3c9cb8f762285970
- helm.sh/chart: notes-0.12.0
+ helm.sh/chart: notes-0.12.1
Tests: 14 passed, 14 total
Snapshot: 1 passed, 1 total
The trap: every new chart version changes labels and the checksum,
the snapshot fires, and after the third time everyone runs
-u by reflex – and then the test checks nothing anymore.
Use snapshots only for small, stable parts; test behavior with
equal and contains. The real chart has no
snapshot.
The suites should not end up in the package. First attempt:
# on prod
cd ~/helm/charts
sed -i '1s/Stand Tag 02/Stand Tag 17/' notes/.helmignore
printf 'tests/\n' >> notes/.helmignore
helm template notes ./notes -f values/prod.yaml | grep -c '^kind: Pod'
sed -i 's#^tests/$#/tests/#' notes/.helmignore
helm template notes ./notes -f values/prod.yaml | grep -c '^kind: Pod'
helm package notes -d /tmp >/dev/null && tar -tzf /tmp/notes-0.12.0.tgz | grep tests/
rm /tmp/notes-0.12.0.tgz
git add notes/tests notes/.helmignore values/dev.yaml values/staging.yaml
git commit -qm "Tag 17: Unit-Tests für notes, dev/staging mit existingSecret"
git log --oneline -1Expected:
0
1
notes/templates/tests/api-test.yaml
45ef9c8 Tag 17: Unit-Tests für notes, dev/staging mit existingSecret
tests/ matches every folder with that name – including
templates/tests/, and the chart test from Day 11 was
suddenly gone. /tests/ means only the folder in the chart
root. The chart version deliberately stays at 0.12.0; Day 18 shows who
notices.
Save your progress? Sign up for free
Exercise: Speed Drills
- How many tests does the Ingress suite have? Target time: 15 s
- Check the staging rendering against the schema of Kubernetes 1.37.0. Target time: 30 s
- How many HIGH/CRITICAL findings does
prod.yamlhave? As a number. Target time: 30 s - Does the stored manifest of
notescontain outdated APIs? Target time: 20 s
Solution
# on prod
helm unittest notes -f tests/ingress_test.yaml | grep '^Tests:'
helm template notes ./notes -f values/staging.yaml \
| kubeconform -strict -summary -kubernetes-version 1.37.0 2>&1 | tail -1
trivy config --quiet --severity HIGH,CRITICAL --format json ~/helm/tag17/prod.yaml \
| jq '[.Results[].Misconfigurations[]?] | length'
helm get manifest notes -n notes | pluto detect - ; echo "Exit: $?"Expected:
Tests: 4 passed, 4 total
Summary: 6 resources found parsing stdin - Valid: 6, Invalid: 0, Errors: 0, Skipped: 0
3
There were no resources found with known deprecated apiVersions.
Exit: 0
Save your progress? Sign up for free
Checkpoint
# on prod
cd ~/helm/charts
helm unittest notes | grep '^Tests:'Expected:
Tests: 13 passed, 13 total (15 after the
challenge).
# on prod
helm template notes ./notes -f values/dev.yaml | kubeconform -strict -summaryExpected:
Summary: 6 resources found … Valid: 6, Invalid: 0 …
# on prod
helm test notes -n notes | grep PhaseExpected: Phase: Succeeded –
the chart test is still there.
Challenge
According to the comment in values.yaml,
replicaCount: null counts as “default 2”, and a
nodeSelector is passed through unchanged. Pin down both in
tests and commit.
Hint: set: in helm-unittest understands
null and maps; equal also compares whole
objects.
Solution
# on prod
cat >> notes/tests/deployment_test.yaml <<'EOF'
- it: nimmt bei null den Standard 2
template: templates/deployment.yaml
set:
replicaCount: null
asserts:
- equal:
path: spec.replicas
value: 2
- it: reicht den nodeSelector durch
template: templates/deployment.yaml
set:
nodeSelector:
kubernetes.io/arch: arm64
asserts:
- equal:
path: spec.template.spec.nodeSelector
value:
kubernetes.io/arch: arm64
EOF
helm unittest notes | grep -E 'PASS|FAIL|^Tests:'
git add notes/tests
git commit -qm "Tag 17 Challenge: Tests für replicaCount null und nodeSelector"
git log --oneline -1Expected:
PASS Deployment notes/tests/deployment_test.yaml
PASS Ingress notes/tests/ingress_test.yaml
PASS Schema notes/tests/schema_test.yaml
Tests: 15 passed, 15 total
a469b3a Tag 17 Challenge: Tests für replicaCount null und nodeSelector
null deletes the key (Day 3), so hasKey is
false, and the ternary from Day 5 picks 2. A test that pins
down documented behavior is the best documentation.
Save your progress? Sign up for free
Cleanup
# on prod
kubectl delete namespace tag17Expected: namespace "tag17" deleted
Interview Note
- What does
helm lintcheck, and what not? Chart structure, values againstvalues.schema.json, template syntax. Not the Kubernetes schema of the objects – for that usekubeconform -strictor a server dry run. - How do you test a chart without a cluster? helm-unittest
with one test per condition (
equal,contains,notExists,failedTemplate), plushelm template | kubeconformfor every values file,trivy configandpluto. - What is problematic about snapshot tests? They break on every version or label change and then get updated blindly.
Enterprise Note
set -o pipefailin every CI script; a check that reports “0 resources found” must be red.- Mirror kubeconform schemas and trivy rules (air gap) and pin them to the version of the target clusters; generate CRD schemas from your own operators.
- Assess trivy findings properly once and maintain justified
exceptions in
.trivyignore– otherwise the team will soon ignore all of them. - Run
pluto detect-helmregularly against all clusters, and before every Kubernetes upgrade with--target-versionsset to the new version. - Unit tests belong in the review rules: a new condition in the template without a test = no merge.