When you run the same Helm releases against five environments — production, staging, QA, dev, sandbox — and the only differences are values overrides and a few enabled/disabled flags, you want one source of truth that diffs cleanly per environment. Helmfile is the orchestrator that handles this: a Go-templated YAML file that declares releases, with environment-scoped values, helpers, and selectors. This article covers the repo shape we use for clients with many environments, the layered values pattern, and the CI pipeline.
How to verify
helmfile --version
helmfile -e prod diff
helmfile -e prod apply
helmfile -e prod list
helmfile -e prod template > /tmp/prod-rendered.yaml
helmfile -e prod --selector tier=platform sync
helmfile diff requires helm-diff plugin (helm plugin install https://github.com/databus23/helm-diff); install it once on the host that runs Helmfile. The output is per-release and color-coded; in CI, pass --no-color for clean logs.
What’s happening
Helmfile is a Go binary that reads helmfile.yaml (or helmfile.yaml.gotmpl for template support), expands the templates with the selected environment’s values, and invokes helm install/upgrade/template/diff for each release. Unlike Helmsman, Helmfile is template-first: every value in helmfile.yaml can be a Go template that references environment values, env vars, files, or helper functions.
The four primitives:
environments:— named environments with their own values (environments.prod.values: [values/prod.yaml]).releases:— the list of Helm releases. Each has aname,namespace,chart,version, andvalues(which can be inline or file references).helmfiles:— sub-helmfiles included from the root. Used to split a monolith into per-team or per-tier files.- Selectors.
--selector tier=platformfilters the release list by label. This is how you sync just the ingress and DNS layer without touching applications.
The reason teams pick Helmfile over Helmsman: Go templates. Templating is real Go template syntax ({{ .Values.foo }}), with sprig functions, conditionals, ranges, and the ability to compute values from other values. Helmsman’s state file is largely declarative with limited substitution.
The procedure
-
Layout.
helmfile/ helmfile.yaml.gotmpl # root, includes per-tier sub-helmfiles environments/ prod.yaml.gotmpl staging.yaml.gotmpl dev.yaml.gotmpl tiers/ platform.yaml.gotmpl # ingress, dns, cert-manager observability.yaml.gotmpl # prom, grafana, loki apps.yaml.gotmpl # tenant workloads values/ ingress-nginx/{base,prod,staging,dev}.yaml.gotmpl kps/{base,prod,staging,dev}.yaml.gotmpl -
Root
helmfile.yaml.gotmpl:environments: prod: kubeContext: prod-us-east-1 values: - environments/prod.yaml.gotmpl staging: kubeContext: staging-us-east-1 values: - environments/staging.yaml.gotmpl dev: kubeContext: dev-us-east-1 values: - environments/dev.yaml.gotmpl --- helmfiles: - path: tiers/platform.yaml.gotmpl - path: tiers/observability.yaml.gotmpl - path: tiers/apps.yaml.gotmpl -
Tier file (
tiers/platform.yaml.gotmpl):bases: - environments/{{ .Environment.Name }}.yaml.gotmpl --- repositories: - name: ingress-nginx url: https://kubernetes.github.io/ingress-nginx - name: jetstack url: https://charts.jetstack.io releases: - name: ingress-nginx namespace: ingress chart: ingress-nginx/ingress-nginx version: {{ .Values.versions.ingressNginx | quote }} labels: { tier: platform } values: - ../values/ingress-nginx/base.yaml.gotmpl - ../values/ingress-nginx/{{ .Environment.Name }}.yaml.gotmpl - name: cert-manager namespace: cert-manager chart: jetstack/cert-manager version: {{ .Values.versions.certManager | quote }} labels: { tier: platform } set: - name: installCRDs value: true -
Environment values (
environments/prod.yaml.gotmpl):versions: ingressNginx: "4.10.1" certManager: "v1.14.5" kps: "59.0.0" replicaCount: ingressNginx: 3 tolerations: ingressNginx: - { key: dedicated, operator: Equal, value: ingress, effect: NoSchedule } -
Layered values file (
values/ingress-nginx/base.yaml.gotmpl):controller: ingressClassResource: name: nginx default: true metrics: enabled: true resources: requests: { cpu: 100m, memory: 256Mi } limits: { memory: 512Mi } tolerations: {{ .Values.tolerations.ingressNginx | toYaml | nindent 6 }}The pattern:
base.yaml.gotmplcarries the shape; the per-env file overrides the deltas. -
CI invocation.
# PR check helmfile -e $ENV diff --no-color --include-tests # main merge helmfile -e $ENV apply --skip-deps --include-tests -
Selectors for partial syncs. When you bump only the observability tier:
helmfile -e prod --selector tier=observability applyThis lets the apps tier stay untouched even if its values changed at the same time.
-
Sub-helmfile per team. If a team owns its own releases, give them their own
tiers/team-foo.yaml.gotmpland pointhelmfiles:to it. The team can edit just their tier file; the root and other tiers are untouched.
Common pitfalls
{{ .Values.foo }}without the value defined. Helmfile errors on render. Use{{ .Values.foo | default "x" }}.- Two environments, divergent base values. “base.yaml” plus “prod.yaml” works when prod is base + overrides. When prod is genuinely different shape, fork the values file — don’t pile up
{{ if eq .Environment.Name "prod" }}blocks. helmfile syncvsapply.syncrunshelm installeven if no diff (re-installs);applyruns only when there’s a diff. Default toapply.--skip-depsin dev. Skipshelm dependency build. Saves time but means sub-charts may be stale. Run without--skip-depsoccasionally to refresh.- Mixing repositories with chart bundles. A chart referenced by name+version from a Helm repo is one thing; a chart referenced by path is another. Pick one model per release.
We run Helmfile for clients with three-or-more Kubernetes environments where the same release set lives in each. The repo layout, the layered values pattern, the CI gates, and the on-call playbook for “diff is huge on staging, what changed” are part of /en/services/managed-operations/. For organizations that want continuous reconciliation from a git commit rather than a CI job, the FluxCD HelmRelease pattern at /en/knowledge-base/fluxcd-helmrelease-deep/ is the alternative we’d deploy.