{{- /* Tri-state activation for the app PDB: - enabled: true → force on - enabled: false → force off (explicit opt-out, even on HA) - enabled: null → auto-enable when the workload is HA — either a static replicaCount > 1, or HPA enabled with minReplicas > 1 (HPA owns spec.replicas so replicaCount alone is not authoritative under autoscaling). */ -}} {{- $pdbEnabled := .Values.podDisruptionBudget.enabled -}} {{- $hpaMin := 0 -}} {{- if .Values.autoscaling.enabled -}} {{- $hpaMin = int (default 1 .Values.autoscaling.minReplicas) -}} {{- end -}} {{- $pdbAuto := and (kindIs "invalid" $pdbEnabled) (or (gt (int .Values.app.replicaCount) 1) (gt $hpaMin 1)) -}} {{- if and .Values.app.enabled (or (eq $pdbEnabled true) $pdbAuto) }} {{- with .Values.podDisruptionBudget }} --- apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: {{ include "sim.fullname" $ }}-app-pdb namespace: {{ $.Release.Namespace }} labels: {{- include "sim.app.labels" $ | nindent 4 }} spec: {{- if .minAvailable }} minAvailable: {{ .minAvailable }} {{- else if .maxUnavailable }} maxUnavailable: {{ .maxUnavailable }} {{- else }} minAvailable: 1 {{- end }} {{- if .unhealthyPodEvictionPolicy }} unhealthyPodEvictionPolicy: {{ .unhealthyPodEvictionPolicy }} {{- end }} selector: matchLabels: {{- include "sim.app.selectorLabels" $ | nindent 6 }} {{- end }} {{- end }} {{- $rtPdbAuto := and (kindIs "invalid" .Values.podDisruptionBudget.enabled) (or (gt (int .Values.realtime.replicaCount) 1) (gt $hpaMin 1)) -}} {{- if and .Values.realtime.enabled (or (eq .Values.podDisruptionBudget.enabled true) $rtPdbAuto) }} {{- with .Values.podDisruptionBudget }} --- apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: {{ include "sim.fullname" $ }}-realtime-pdb namespace: {{ $.Release.Namespace }} labels: {{- include "sim.realtime.labels" $ | nindent 4 }} spec: {{- if .minAvailable }} minAvailable: {{ .minAvailable }} {{- else if .maxUnavailable }} maxUnavailable: {{ .maxUnavailable }} {{- else }} minAvailable: 1 {{- end }} {{- if .unhealthyPodEvictionPolicy }} unhealthyPodEvictionPolicy: {{ .unhealthyPodEvictionPolicy }} {{- end }} selector: matchLabels: {{- include "sim.realtime.selectorLabels" $ | nindent 6 }} {{- end }} {{- end }} {{- if and .Values.copilot.enabled .Values.copilot.server.podDisruptionBudget.enabled }} {{- with .Values.copilot.server.podDisruptionBudget }} --- apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: {{ include "sim.fullname" $ }}-copilot-pdb namespace: {{ $.Release.Namespace }} labels: {{- include "sim.copilot.labels" $ | nindent 4 }} spec: {{- if .minAvailable }} minAvailable: {{ .minAvailable }} {{- else if .maxUnavailable }} maxUnavailable: {{ .maxUnavailable }} {{- else }} maxUnavailable: 1 {{- end }} {{- if .unhealthyPodEvictionPolicy }} unhealthyPodEvictionPolicy: {{ .unhealthyPodEvictionPolicy }} {{- end }} selector: matchLabels: {{- include "sim.copilot.selectorLabels" $ | nindent 6 }} {{- end }} {{- end }}