Toolkit: Helmfile, helm-diff, chart-testing & More
The course's sessions used Helm, Kustomize, kubectl, kubeconform and yq. Around them is an ecosystem of tools that fill specific gaps: managing many releases, previewing upgrades, testing charts, enforcing policy. This lesson maps it. Tools that aren't in the course image appear as configuration and non-run commands.
What this course's image contains
helm version --short
kustomize version
kubectl version --client | head -1
echo "kubeconform $(kubeconform -v)"
flux --version
yq --version | sed 's/.*version /yq /'
for tool in helmfile ct helm-docs kube-linter polaris kyverno conftest pluto argocd; do
command -v "$tool" >/dev/null || echo "not installed: $tool"
donev4.3.1+gc0d08d0
v5.8.3
Client Version: v1.37.1
kubeconform v0.8.0
flux version 2.10.0
yq v4.54.1
not installed: helmfile
not installed: ct
not installed: helm-docs
not installed: kube-linter
not installed: polaris
not installed: kyverno
not installed: conftest
not installed: pluto
not installed: argocd
The landscape
| Need | Tools | Notes |
|---|---|---|
| many releases, declared in one file | Helmfile | below |
| preview what an upgrade changes | helm-diff plugin; kubectl diff -k; Argo CD/Flux diff views |
below |
| test charts in CI | chart-testing (ct): lint changed charts, install them in kind, run helm test, check version bumps |
below |
| unit-test templates | helm-unittest plugin | below |
| document values | helm-docs (README tables from values.yaml comments) |
generates the values table every chart README needs |
| generate a values schema | helm-values-schema-json plugin | Validating Values with a Schema |
| schema validation | kubeconform | its lesson |
| best practices / policy | kube-linter, Polaris, Kyverno CLI (kyverno apply), Conftest (Rego) |
"limits set", "no latest", "runs as non-root" |
| deprecated APIs | Pluto, kubeconform with your target version | before every cluster upgrade |
| other ways to generate YAML | Jsonnet/Tanka, CUE/Timoni, Carvel ytt, cdk8s | real languages instead of templates |
| GitOps delivery | Argo CD, Flux | the planned GitOps course |
Helmfile
Helmfile declares a set of releases (charts, versions, values per environment) in one file and applies them with helmfile apply, which runs helm-diff first and only upgrades what changed. It's a good fit for a platform team that installs a dozen add-ons per cluster without a GitOps controller.
# helmfile.yaml (sample)
environments:
staging:
values: [env/staging.yaml]
production:
values: [env/production.yaml]
---
releases:
- name: linkly
namespace: linkly-{{ .Environment.Name }}
chart: oci://ghcr.io/acme/charts/linkly
version: 1.0.3
values:
- values/linkly.yaml.gotmplhelmfile -e staging diff
helmfile -e production applyhelm-diff
The helm-diff plugin renders an upgrade and diffs it against the live release, so you see exactly which objects and fields change before you run it:
helm plugin install https://github.com/databus23/helm-diff --verify=false # Helm 4 verifies only .tgz plugins; a git URL needs --verify=false
helm diff upgrade web oci://ghcr.io/acme/charts/linkly --version 1.0.3 -n linkly -f values-prod.yamllinkly, web, Deployment (apps) has changed:
# Source: linkly/templates/deployment.yaml
...
- image: "ghcr.io/acme/linkly:1.4.0"
+ image: "ghcr.io/acme/linkly:1.4.1"Without a cluster, the render-and-diff approach gives reviewers the same information.
chart-testing (ct)
ct is built for repositories that hold charts. It finds the charts changed in a pull request, checks that their version was bumped, lints them with helm lint and yamllint, and (ct install) installs each in a throwaway cluster, typically kind, and runs helm test:
# ct.yaml (sample)
target-branch: main
chart-dirs: [charts]
validate-maintainers: false
check-version-increment: truect lint --config ct.yaml
ct install --config ct.yaml # needs a cluster: kind in CIhelm-unittest
Unit tests assert on rendered output for given values, without a cluster, and run in milliseconds:
# charts/linkly/tests/hpa_test.yaml (sample)
suite: autoscaling
templates: [templates/deployment.yaml, templates/hpa.yaml]
tests:
- it: drops fixed replicas when autoscaling is on
template: templates/deployment.yaml
set:
autoscaling.enabled: true
asserts:
- notExists:
path: spec.replicas
- it: renders no HPA by default
template: templates/hpa.yaml
asserts:
- hasDocuments:
count: 0helm plugin install https://github.com/helm-unittest/helm-unittest --verify=false
helm unittest charts/linklyA GitOps preview: Flux objects for a chart
GitOps controllers install charts from inside the cluster. The Flux CLI in the image can write the objects without a cluster (--export), and kubeconform validates them with the Flux CRD schemas:
flux create source oci linkly-chart --url=oci://ghcr.io/acme/charts/linkly --tag=1.0.3 --interval=10m --export > flux.yaml
printf 'replicaCount: 4\n' > values-prod.yaml
flux create helmrelease linkly --chart-ref=OCIRepository/linkly-chart \
--target-namespace=linkly-prod --values=values-prod.yaml --export >> flux.yaml
cat flux.yaml
kubeconform -strict -summary flux.yaml---
apiVersion: source.toolkit.fluxcd.io/v1
kind: OCIRepository
metadata:
name: linkly-chart
namespace: flux-system
spec:
interval: 10m0s
provider: generic
ref:
tag: 1.0.3
url: oci://ghcr.io/acme/charts/linkly
---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: linkly
namespace: flux-system
spec:
chartRef:
kind: OCIRepository
name: linkly-chart
interval: 1m0s
storageNamespace: linkly-prod
targetNamespace: linkly-prod
values:
replicaCount: 4
Summary: 2 resources found in 1 file - Valid: 2, Invalid: 0, Errors: 0, Skipped: 0
The OCIRepository points at the chart in the registry; the HelmRelease tells Flux's helm-controller to install it with these values and keep it reconciled. The planned GitOps course takes it from here.
Test yourself
Which tool checks that a changed chart's version was bumped and installs it in a test cluster?
- helm-docs
- chart-testing (ct)
- kubeconform
- Pluto
What does helm-unittest need to run?
- A kind cluster
- Only the chart: it asserts on rendered templates
- Argo CD
- A registry
Which tool would you use to find manifests using APIs removed in the next Kubernetes version?
- helm-docs
- Pluto (or kubeconform with the target version)
- Helmfile
- helm-diff