Skip to content

Helm Testing and Validation

Overview

Gate chart changes with helm lint, helm template, dry-run installs, and optional helm test hooks before merge.

Never discover template typos in production. CI should lint + render for every env values file. --debug --dry-run shows manifests without apply (still contacts the cluster for some lookups).

This is a core tutorial in Module 8 · Testing & Validation of the REBASH Academy Helm for Kubernetes Engineers series — written for Cloud, DevOps, Platform, and SRE engineers.

Prerequisites

Learning Objectives

By the end of this tutorial, you will be able to:

  • helm lint
  • helm template for review
  • Dry-run upgrade
  • Outline chart tests (templates/tests/)

Architecture

This topic’s control points and relationships are shown below.

Template rendering

Theory

What it is

Testing and validation for Helm means proving a chart renders correctly and behaves as intended before it changes production. The core tools are helm lint (static checks), helm template (render manifests for review), install/upgrade dry-runs, and optional chart tests — Jobs or Pods under templates/tests/ that helm test runs against a live release.

Tool What it catches
helm lint Structural issues, common chart mistakes
helm template Render errors, bad YAML shape, values holes
--dry-run Server-side interactions (partial); still careful
helm test Post-install smoke checks via test hooks

Why it matters

Template typos and wrong values should fail in CI, not at Friday deploy. A pipeline that lints and renders every environment values file turns chart PRs into reviewable artefacts. Chart tests add a lightweight smoke layer after install (for example, hitting a Service endpoint). Together they reduce mean time to detect packaging defects and protect GitOps from merging broken desired state.

How it works

Recommended gate order:

  1. helm lint ./chart — fail the build on errors.
  2. helm template release ./chart -f values-dev.yaml (repeat for stage/prod files) — store or diff rendered output in CI.
  3. Optionally helm upgrade --install --dry-run --debug when you need cluster lookups (note: dry-run still contacts the API for some behaviour; prefer helm template for pure render checks).
  4. After a real install in a test cluster, helm test RELEASE executes hooks annotated as tests.
  5. Keep test Pods ephemeral; they should not leave lasting side effects.

Treat rendered YAML as a review surface: reviewers skim Deployments, probes, and Service selectors the same way they review application code.

Key concepts and comparisons

Layer Offline? Cluster needed?
Lint Yes No
Template render Yes No
Dry-run install Mostly Often yes
helm test No Yes (release installed)

Unit-testing frameworks (for example chart-testing/ct, or snapshot tests of helm template output) extend the same idea for teams with many charts.

Common pitfalls

  • Relying only on lint — lint will not prove your prod values file renders a valid Ingress host.
  • Assuming --dry-run never talks to the cluster.
  • Chart tests that require manual cleanup or depend on flaky external networks.
  • Skipping render for “tiny” values changes that alter nested maps and break templates.

Hands-on Lab

Create a workspace for this tutorial.

mkdir -p ~/rebash-helm/module-08 && cd ~/rebash-helm/module-08

Focus: Validate charts with lint, template, and helm test hooks

Step 1 – Add a simple test Pod hook

kubectl create namespace rebash-helm
helm create test-demo
mkdir -p test-demo/templates/tests
python3 - <<'PY'
from pathlib import Path
Path('test-demo/templates/tests/test-connection.yaml').write_text('''apiVersion: v1
kind: Pod
metadata:
  name: "{{ include "test-demo.fullname" . }}-test-connection"
  labels:
    {{- include "test-demo.labels" . | nindent 4 }}
  annotations:
    "helm.sh/hook": test
spec:
  containers:
  - name: wget
    image: busybox:1.36
    command: ['wget']
    args: ['{{ include "test-demo.fullname" . }}:{{ .Values.service.port }}']
  restartPolicy: Never
''')
PY
helm lint test-demo
helm template demo ./test-demo -n rebash-helm >/dev/null

Step 2 – Install and run helm test

helm upgrade --install demo ./test-demo -n rebash-helm
kubectl -n rebash-helm rollout status deploy -l app.kubernetes.io/instance=demo --timeout=90s || kubectl -n rebash-helm get deploy
helm -n rebash-helm test demo --logs || true

Final step – Cleanup note

helm uninstall demo -n rebash-helm --ignore-not-found || true
kubectl delete namespace rebash-helm --ignore-not-found
# Workspace kept for notes; remove with: rm -rf "$(pwd)" when finished

Validation

  • Lab commands run under ~/rebash-helm/module-08/
  • You can explain each Theory section in your own words
  • You used modern tooling where it applies to this topic
  • You can describe one production failure mode for this topic

Code Walkthrough

Production practice for Helm Testing and Validation always combines:

  1. Inspect before you change (status, plan, logs, dry-run)
  2. Prefer reversible, documented changes (Git, IaC, drop-ins, version pins)
  3. Capture evidence (command output, pipeline logs) for handovers
  4. Prefer current tools and APIs over legacy shortcuts
  5. Least privilege — escalate credentials only when required

Keep runbooks short enough to follow under pressure. Automate checks; keep humans for judgement.

Security Considerations

  • Treat credentials and tokens for helm as privileged — never commit them
  • Prefer short-lived auth (OIDC, roles, SSO) over long-lived keys
  • Validate blast radius before apply/deploy/delete operations
  • Restrict who can approve production changes
  • Collect audit logs; limit who can read sensitive traces

Common Mistakes

Relying only on lint — lint will not prove your prod values file renders a valid Ingress h

Validate assumptions against the Theory section and official docs before changing production.

Assuming --dry-run never talks to the cluster.

Lab shortcuts (open security groups, admin roles, skip approvals) must not ship unchanged.

Changing production without a rollback path

Always know how to revert (previous artefact, prior release, state rollback, DNS failback).

Best Practices

  • Encode Helm Testing and Validation changes as code and review them in pull requests
  • Pin versions (images, modules, actions, provider plugins)
  • Separate environments with clear promotion gates
  • Alert on symptoms with runbooks attached
  • Destroy lab resources; tag everything with owner and expiry where possible

Troubleshooting

Symptom Likely cause Fix
Auth / permission denied Wrong identity, policy, or scope Check caller identity, roles, and least-privilege policies
Timeout / no route Network, DNS, security group, or endpoint Trace path, DNS, and allow-lists before retrying
Drift / unexpected plan Manual change or wrong state/workspace Reconcile desired vs actual; avoid click-ops on managed resources
Pipeline/job red Flaky step, cache, or missing secret Read failing step logs; bisect recent workflow/config changes
Cost spike Idle load balancer, NAT, oversized compute Inventory billable resources; stop/delete labs promptly

Summary

Helm Testing and Validation is essential for Cloud and DevOps engineers working with helm. Practise the lab until the inspection and change path is muscle memory, then continue the track.

Interview Questions

  1. What does helm lint check?
  2. How do Helm test hooks differ from unit-testing templates?
  3. Why run helm template in CI before allowing merges?
  4. What security benefit comes from validating rendered manifests against policies?
  5. When can helm test pass while production still fails?

Sample answer — question 2

template in CI catches render errors and lets policy engines scan YAML without touching a cluster. It is a cheap gate before install.

Sample answer — question 4

Policy checks (for example Pod Security) catch privileged defaults that lint may miss. Preventing those charts from shipping reduces cluster compromise risk.

References