Testing Charts

Linting and Testing a Chart Before Release

Check a chart three ways: helm 29,435 lint, a server-side dry run that validates every rendered object against the API server's schemas, and helm test, which runs Pods annotated helm.sh/hook: test in a live release; BookNest's fetches the book list through the front end:

Lint, validate against the API server, test the live releaseShell
helm lint helm/booknest --strict | tail -1
helm template check helm/booknest -n booknest-helm --skip-tests \
  | kubectl apply --dry-run=server -n booknest-helm -f - \
  | sed 's/ created (server dry run)//' | paste -sd' ' | fold -s -w 95
helm test booknest -n booknest-helm --logs | tail -3
Output
1 chart(s) linted, 0 chart(s) failed
secret/check-db configmap/check-api service/check-postgres service/check-api service/check-web
deployment.apps/check-api deployment.apps/check-web statefulset.apps/check-postgres
configmap/check-migrations job.batch/check-migrate
POD LOGS: booknest-test-api
6 books through booknest-web

Then publish. Any OCI registry stores charts beside images, including BookNest's registry:3 (Image Registries) on localhost:33500, which needs --plain-http:

Packaging the chart and pushing it to the registry as an OCI artifactShell
helm package helm/booknest -d ~/charts >/dev/null
helm push ~/charts/booknest-0.1.0.tgz oci://localhost:33500/charts --plain-http
printf 'helm/*/charts/*.tgz\n' >> .gitignore
git add .gitignore helm && git commit -qm "Package BookNest as a Helm chart"
Output
Pushed: localhost:33500/charts/booknest:0.1.0
Digest: sha256:e132e54f4f22ba68b19ed1df38b725b928bae5ce8486ac0442907515f0086111

The registry stores it as an OCI manifest with config media type application/vnd.cncf.helm.config.v1+json, and any machine that reaches it can run helm install booknest oci://localhost:33500/charts/booknest --version 0.1.0. Treat chart versions as immutable. In CI, add chart-testing 1,643 (github.com/helm/chart-testing (https://github.com/helm/chart-testing 1,643 ), Apache-2.0) to lint and install only the charts a pull request changed, helm-unittest 1,394 (github.com/helm-unittest/helm-unittest (https://github.com/helm-unittest/helm-unittest 1,394 ), MIT) to assert on rendered output, and kubeconform 3,204 (github.com/yannh/kubeconform (https://github.com/yannh/kubeconform 3,204 ), Apache-2.0) to validate manifests offline.