{{- $settings := fromYaml (include "keycloak.settings" .) }} {{- $replicas := int (include "keycloak.replicas" (dict "scaleDown" .Values.scaleDown "replicas" .Values.keycloak.replicas)) }} {{- /* THE FIRST PodDisruptionBudget IN THIS REPOSITORY, and the convention it sets is in README ("Pod disruption budgets") and in the wiki style guide. WHY IT EXISTS HERE: with two replicas, a node drain is otherwise free to take both pods at once - and a drain is the most common reason a pod moves, because it is what a node upgrade does. Without this object the second replica buys nothing against the failure it was added for. minAvailable rather than maxUnavailable, because the guarantee wanted is about the service: at least one node answers logins throughout the drain. AND WHY IT IS NOT RENDERED BELOW TWO REPLICAS - the trap that makes a PDB worth a condition rather than an unconditional object: minAvailable: 1 with exactly ONE replica forbids every voluntary eviction, so `kubectl drain` blocks forever on a pod nothing is allowed to move. The message then names the PDB and not the replica count, which sends the reader to the wrong file. The same applies to scaleDown: true, where there are no pods at all and the object would only describe a promise about nothing. So: rendered when the effective replica count is >= 2, skipped otherwise, and NOTES.txt prints which of the two happened so that an operator does not have to guess from `kubectl get pdb`. */ -}} {{- if and $settings.podDisruptionBudget.enabled (ge $replicas 2) }} apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: {{ .Release.Name }}-{{ .Chart.Name }}-pdb labels: app: {{ .Release.Name }}-{{ .Chart.Name }}-deployment spec: minAvailable: {{ $settings.podDisruptionBudget.minAvailable | int64 }} selector: matchLabels: app: {{ .Release.Name }}-{{ .Chart.Name }}-deployment {{- end }}