Skip to content

Helm chart examples ​

Encyclopedia home · Search machine-readable catalog

CF-036 ​

Chart metadata

Copy to helm/web/Chart.yaml.

yaml
apiVersion: v2
name: web
description: Lab health service
type: application
version: 0.1.0
appVersion: "1.0.0"

Verification. Keep chart and package versions explicit. Run helm lint after adding templates.

Validation syntax-validated. Official reference

CF-037 ​

Chart values defaults

Copy to helm/web/values.yaml.

yaml
replicaCount: 2
image:
  repository: registry.example.com/lab/web
  digest: sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
service: {port: 80}

Verification. Replace repository/digest before deploying. Use separate staging overrides.

Validation syntax-validated. Official reference

CF-038 ​

Chart values validation

Copy to helm/web/values.schema.json.

json
{"type":"object","required":["image"],"properties":{"image":{"type":"object","required":["repository","digest"],"properties":{"repository":{"type":"string","minLength":1},"digest":{"type":"string","pattern":"^sha256:[a-f0-9]{64}$"}}}}}

Verification. Test invalid digest with helm lint and expect validation failure.

Validation syntax-validated. Official reference

CF-039 ​

Release label helper

Copy to helm/web/templates/_helpers.tpl.

gotemplate
{{- define "web.selector" -}}
app.kubernetes.io/name: web
app.kubernetes.io/instance: {{ .Release.Name | quote }}
{{- end -}}

Verification. Render labels with include and nindent to guarantee selector consistency.

Validation untested. Official reference

CF-040 ​

Digest-required deployment container

Copy to helm/web/templates/deployment.yaml fragment.

gotemplate
image: {{ printf "%s@%s" .Values.image.repository (required "image.digest is required" .Values.image.digest) | quote }}

Verification. Merge under the container. Render and check output uses repository@digest.

Validation untested. Official reference

CF-041 ​

Service templates with selector helper

Copy to helm/web/templates/service.yaml.

gotemplate
apiVersion: v1
kind: Service
metadata:
  name: {{ .Release.Name | quote }}
spec:
  selector:
    {{- include "web.selector" . | nindent 4 }}
  ports: [{port: {{ .Values.service.port }}, targetPort: 8000}]

Verification. Include CF example selector helper and verify selectors match deployment.

Validation untested. Official reference

CF-042 ​

ConfigMap release fixtures

Copy to helm/web/templates/configmap.yaml.

gotemplate
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ printf "%s-config" .Release.Name | quote }}
data:
  MODE: {{ .Values.mode | default "lab" | quote }}

Verification. Render with MODE override. Keep secrets out of ConfigMaps.

Validation untested. Official reference

CF-043 ​

Force a rollout on config change

Copy to deployment Pod-template annotations fragment.

gotemplate
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}

Verification. Change ConfigMap values and verify the Pod template hash changes.

Validation untested. Official reference

CF-044 ​

One-shot Helm service smoke test

Copy to helm/web/templates/tests/smoke.yaml.

gotemplate
apiVersion: v1
kind: Pod
metadata:
  name: {{ printf "%s-smoke" .Release.Name | quote }}
  annotations: {"helm.sh/hook": test, "helm.sh/hook-delete-policy": "before-hook-creation,hook-succeeded"}
spec:
  restartPolicy: Never
  containers:
    - name: check
      image: curlimages/curl:8.12.1
      args: ["--fail","--max-time","5",{{ printf "http://%s/healthz" .Release.Name | quote }}]

Verification. Use helm test --logs. In production pin image digest and set security context.

Validation untested. Official reference

CF-045 ​

Staging override

Copy to helm/values-staging.yaml.

yaml
replicaCount: 1
mode: staging
service: {port: 80}

Verification. Check override order and verify only intended environment values change.

Validation syntax-validated. Official reference