Skip to content

Commit e2e5a75

Browse files
committed
feat(cloudnative-pg): Setup optional PDB
Signed-off-by: Pat Riehecky <[email protected]>
1 parent 8ba8bee commit e2e5a75

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- if .Values.podDisruptionBudget.enabled -}}
2+
apiVersion: policy/v1
3+
kind: PodDisruptionBudget
4+
metadata:
5+
name: {{ include "cloudnative-pg.fullname" . }}
6+
spec:
7+
selector:
8+
matchLabels:
9+
{{- include "cloudnative-pg.selectorLabels" . | nindent 6 }}
10+
{{- if .Values.podDisruptionBudget.minAvailable }}
11+
minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
12+
{{- end }}
13+
{{- if .Values.podDisruptionBudget.maxUnavailable }}
14+
maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
15+
{{- end }}
16+
{{- if (semverCompare ">= 1.27-0" .Capabilities.KubeVersion.Version) }}
17+
unhealthyPodEvictionPolicy: {{ .Values.podDisruptionBudget.unhealthyPodEvictionPolicy }}
18+
{{- end }}
19+
{{- end }}

charts/cloudnative-pg/values.schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"affinity": {
1212
"type": "object"
1313
},
14+
"podDisruptionBudget": {
15+
"type": "object"
16+
},
1417
"commonAnnotations": {
1518
"type": "object"
1619
},

charts/cloudnative-pg/values.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,32 @@ tolerations: []
173173
# -- Affinity for the operator to be installed.
174174
affinity: {}
175175

176+
# -- Setup podDisruptionBudget for the operator
177+
# https://kubernetes.io/docs/tasks/run-application/configure-pdb/
178+
podDisruptionBudget:
179+
180+
# -- Specifies whether the PDB shoudl be enabled
181+
enabled: false
182+
# The PDB definition three attributes to control the availability requirements:
183+
# minAvailable or maxUnavailable (mutually exclusive).
184+
# unhealthyPodEvictionPolicy
185+
#
186+
# Field maxUnavailable tells how many pods can be down and minAvailable tells how many pods must be running in a cluster.
187+
188+
# The pdb template will check values according to below order
189+
#
190+
# {{- if .Values.podDisruptionBudget.minAvailable }}
191+
# minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
192+
# {{- end }}
193+
# {{- if .Values.podDisruptionBudget.maxUnavailable }}
194+
# maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
195+
# {{- end }}
196+
#
197+
# If both values are set, the template will use the first one and ignore the second one. currently by default minAvailable is set to 1
198+
minAvailable: 1
199+
maxUnavailable:
200+
unhealthyPodEvictionPolicy: IfHealthyBudget
201+
176202
monitoring:
177203

178204
# -- Specifies whether the monitoring should be enabled. Requires Prometheus Operator CRDs.

0 commit comments

Comments
 (0)