A pattern I've often seen in Helm charts (e.g.) is to set a boolean value to default to true
unless some overriding value is provided:
feature_enabled_in_k8s_resource: {{ default true .Values.foo_feature_enabled }}
That is - "if foo_feature_enabled
is set to any value in the inputs to Helm (via --set
, values.yaml
, etc.), set feature_enabled_in_k8s_resource
to that value - else (if it is unset), set feature_enabled_in_k8s_resource
to true
"
However, I'm not able to override that value as I would expect - both setting a false
value in values.yaml
, and/or passing --set foo_feature_enabled=false
as an argument, still result in the template holding a value of true
.
I suspect that this is because false
is a "falsy" value, and so default
parses it as "needing replacement".
Passing a string value ("false"
in values.yaml
, or --set-string foo_feature_enabled=false
) does appear (from helm template [...]
output) to set feature_enabled_in_k8s_resource
to "false"
- but it's not clear whether that will be correctly interpreted by the actual application which results from the Kubernetes (that is - it might interpret a non-empty string as "truthy", setting us right back to the original default behaviour). Even if this works, it feels hacky in a way that suggests that I'm missing the "proper" solution.
(Presumably, the actual fix would be Helm charts to never default
to true
- but that doesn't help me when working with charts that I don't control!)
replicas: {{ .Values.replicas | default 1 }}
doesn't allow an operator to disable a Deployment by specifying zero replicas at deploy time. – Korykorzybski