When templating, explicitly distinguish three states: missing, explicit false, and null. Relying on truthiness can silently drop intended configuration.
Apply two patterns:
1) Preserve explicit false (boolean fields)
with / truthy checks for booleans if false must still render.{{/* BAD: with treats false as empty */}}
{{- with .Values.serviceMonitor.honorLabels }}
honorLabels: {{ . }}
{{- end }}
{{/* GOOD: preserves explicit false */}}
{{- if hasKey .Values.serviceMonitor "honorLabels" }}
honorLabels: {{ .Values.serviceMonitor.honorLabels }}
{{- end }}
2) Omit fields via real null (Helm values)
null (and confirm rendered output).helm template to verify that runAsUser: null / fsGroup: null (or similar) do not appear in manifests.# values.yaml override example
podSecurityContext:
runAsUser: null
fsGroup: null
securityContext:
runAsUser: null
Rule of thumb:
false must be honored → check hasKey.null and verify with helm template.Enter the URL of a public GitHub repository