-
Notifications
You must be signed in to change notification settings - Fork 16
minAvailable: 0 in PodDisruptionBudget renders as N/A due to Go template falsy-zero check #218
Description
Setting podDisruptionBudget.minAvailable: 0 (either in defaults or at the component level) results in a PDB with neither minAvailable nor maxUnavailable in the spec. Kubernetes shows N/A / N/A for both fields, and ALLOWED DISRUPTIONS: 0 — effectively blocking all voluntary evictions instead of allowing them.
Root Cause:
In templates/_helpers.tpl, the cloudzero-agent.generatePodDisruptionBudget template uses truthiness checks to conditionally render PDB fields:
{{- if $pdb.minAvailable }}
minAvailable: {{ $pdb.minAvailable }}
{{- end }}
{{- if $pdb.maxUnavailable }}
maxUnavailable: {{ $pdb.maxUnavailable }}
{{- end }}
In Go templates, the integer 0 is falsy, so {{- if 0 }} evaluates to false. The minAvailable line is never rendered, even though minAvailable: 0 is a valid Kubernetes PDB value.
Steps to Reproduce:
Set PDB configuration in values override:
defaults:
podDisruptionBudget:
enabled: true
minAvailable: 0
Or at component level:
components:
aggregator:
podDisruptionBudget:
enabled: true
minAvailable: 0
Deploy the chart.
Check PDBs:
kubectl get pdb -n cloudzero
Expected Result:
NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS
cloudzero-cz-aggregator 0 N/A 3
Actual Result:
NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS
cloudzero-cz-aggregator N/A N/A 0
Note: The bundled kube-state-metrics subchart (from prometheus-community) does not have this issue because its pdb.yaml uses {{ toYaml .Values.podDisruptionBudget | indent 2 }} without individual field conditionals.
Workaround:
Use maxUnavailable: "100%" instead of minAvailable: 0 to achieve the same effect.