GitOpsHelm
Helm charts: rules for charts you can maintain
Helm's best practices guide, its chart documentation and its linter give concrete rules for a chart. These are the ones on values, schemas, helpers, labels, templates, versions and registries, with examples from the Helm documentation or run on Helm 4.

Documented values with safe defaults
The Helm best practices say every defined property in values.yaml should be documented. Each comment begins with the name of the property it describes, so that documentation tools can match comments to parameters:
# serverHost is the host name for the webserver
serverHost: example
# serverPort is the HTTP listener port for the webserver
serverPort: 9191Names begin with a lowercase letter and use camelCase. For values that users override with --set, the same page prefers maps to lists: --set servers.foo.port=80 stays correct when the order of the servers changes.
The chart that helm create mychart generates shows what its defaults look like. It sets ingress.enabled: false, autoscaling.enabled: false, service.type: ClusterIP and an empty image.tag, which the template replaces with the chart's appVersion. Follow that pattern, and leave off by default anything that exposes the application.
A schema for the values
A chart can carry a values.schema.json file that holds a JSON Schema. Helm applies it on helm install, helm upgrade, helm lint and helm template. This one fits two values of the generated chart. Write yours for your own values.
{
"$schema": "https://json-schema.org/draft-07/schema#",
"type": "object",
"required": ["image"],
"properties": {
"replicaCount": { "type": "integer", "minimum": 1 },
"image": {
"type": "object",
"required": ["repository"],
"properties": {
"repository": { "type": "string" },
"tag": { "type": "string" }
}
}
}
}The schema is applied to the final .Values object, so values passed with --set are checked too. With this file in place, helm template mychart ./mychart --set replicaCount=abc stops with the message at '/replicaCount': got string, want integer.
Helpers and the recommended labels
Files in templates/ whose names begin with an underscore are assumed to hold no manifest, and _helpers.tpl is the default location for named templates. Template names are global, so the named templates guide prefixes each one with the chart name. These two helpers are in the _helpers.tpl that helm create mychart generates:
{{- define "mychart.labels" -}}
helm.sh/chart: {{ include "mychart.chart" . }}
{{ include "mychart.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{- define "mychart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "mychart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}Together they set the four labels the best practices mark as recommended: helm.sh/chart, app.kubernetes.io/name, app.kubernetes.io/instance and app.kubernetes.io/managed-by. app.kubernetes.io/version is marked optional. The generated Deployment uses the full set for its labels and the second helper for its selector:
metadata:
name: {{ include "mychart.fullname" . }}
labels:
{{- include "mychart.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "mychart.selectorLabels" . | nindent 6 }}The guide prefers include over template, so that the output formatting can be handled for YAML documents, as nindent does here.
Templates light on logic
The best practices carry these rules for templates and the values they read:
- Favor flat values over nested ones, except where many related variables read better nested. Every layer of nesting needs an existence check in the template.
- Put each resource definition in its own template file, and let the file name reflect the resource kind.
- Document a defined template with a template comment. Template comments are left out of the output of
helm install --debug, and YAML comments are kept. - Use a fixed tag or the SHA of a container image. The pods page rules out floating tags such as
latest.
Lint and render in CI
helm lint ./mychart --strict
helm template mychart ./mychart --values ci-values.yaml > rendered.yamlhelm lint puts the chart through a series of tests that verify it is well-formed. --strict fails on lint warnings.
helm template renders the templates locally. Values that would be looked up in the cluster are faked, and none of the server-side testing of chart validity is done, such as whether an API is supported. --kube-version and --api-versions set the capabilities to render for. --dry-run=server validates on the server and requires cluster connectivity. ci-values.yaml stands for a values file of your own.
Chart version, appVersion and OCI registries
Every chart must have a version in Chart.yaml, and it should follow SemVer 2. Packages in repositories are identified by name plus version. appVersion specifies the version of the application. It only informs: chart version calculations ignore it. The documentation highly recommends quotes around it, because YAML reads 1.0 as a floating point value.
The documentation recommends container registries with OCI support for storing and sharing chart packages:
helm package ./mychart
helm registry login -u myuser localhost:5000
helm push mychart-0.1.0.tgz oci://localhost:5000/helm-chartsThe user and the registry address come from the documentation's example. Put your own in their place. helm push only accepts a .tgz file created with helm package. The reference starts with oci:// and must not contain the chart name or the tag, which are inferred from the chart's name and version.
Secrets stay out of values
The Using Helm page says overrides specified with --set are persisted in a Secret, and can be viewed for a release with helm get values <release-name>. By default Helm stores release information in Secrets in the namespace of the release. Keep passwords out of values. Have the chart take the name of a Secret that already exists, and reference it.
Helm 4 checks for chart authors
The current Helm documentation covers Helm 4. Its overview says v2 charts continue to work unchanged, and lists changes to check in pipelines and release scripts:
--atomicis renamed--rollback-on-failure, and--forceis renamed--force-replace. The old flags remain and emit a deprecation warning.helm registry logintakes the registry hostname only, with an optional port. A scheme or a path is not allowed.- Helm 4 defaults to server-side apply when it installs a new release. Releases created by Helm 3 keep client-side apply unless
--server-sideis set. - Post-renderers are implemented as plugins. Passing an executable directly is no longer possible.
- Charts v3 is experimental, for testing and feedback only.
Sources
Want a second pair of eyes on yours? We do this work for a living.
More guides

Helm or Kustomize: which one for which job
GitOps · 4 min read
Templating or patching, packaging, rollback and when to use the two tools together.

Kustomize overlays: one base for many environments
GitOps · 3 min read
A base, an overlay for each environment, the fields to use and the deprecated ones to replace.

Secrets in GitOps: Sealed Secrets, SOPS or External Secrets Operator
GitOps · 4 min read
Sealed Secrets, SOPS and External Secrets Operator, with the documented facts for each side by side.