Helm charts: 10 best practices to keep your deployments under control
Safe defaults, versioning, schema validation, and testing: how to write charts the rest of your team can maintain.
Kubernetes$ helm upgrade --install api ./chart▍Helm is still the most popular way to package applications for Kubernetes. But a poorly written chart quickly turns into a black box of templates. These practices help keep everything readable.
1. Safe default values
values.yaml should work out of the box and securely: resources defined, securityContext with runAsNonRoot: true, and probes configured.
2. Validate with JSON Schema
A values.schema.json stops someone from passing replicas: "three" and only finding out at deploy time.
3. Use helpers for names and labels
{{- define "api.labels" -}}
app.kubernetes.io/name: {{ include "api.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
4. Version the chart and the application separately
version is the chart version; appVersion is the application version. Bump both following SemVer.
5. Lint and test in CI
helm lint ./chart
helm template ./chart | kubeconform -strict -summary
6. Avoid too much logic in templates
If a template has five levels of if, maybe it’s really two different charts — or a case for Kustomize.
7. Document your values
Comments in values.yaml and a README generated automatically with helm-docs.
8. Don’t store secrets in values
Reference existing Secrets or use External Secrets.
9. Use --atomic for deployments
With helm upgrade --install --atomic, a failure triggers an automatic rollback.
10. Publish to an OCI registry
Charts can be stored in the same registry as your images, which simplifies permissions and distribution.