Skip to content

Commit 2da7a67

Browse files
authored
feat(helm): added pdb to helm (#1617)
* feat(helm): added pdb to helm * add additional config
1 parent 1e81cd6 commit 2da7a67

File tree

6 files changed

+76
-8
lines changed

6 files changed

+76
-8
lines changed

helm/sim/examples/values-aws.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ ingress:
200200
# Pod disruption budget for high availability
201201
podDisruptionBudget:
202202
enabled: true
203-
minAvailable: 1
204-
203+
minAvailable: null
204+
maxUnavailable: 1
205+
unhealthyPodEvictionPolicy: AlwaysAllow
205206
# Network policies
206207
networkPolicy:
207208
enabled: true

helm/sim/examples/values-external-db.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ autoscaling:
122122

123123
podDisruptionBudget:
124124
enabled: true
125-
minAvailable: 1
126-
125+
minAvailable: null
126+
maxUnavailable: 1
127+
unhealthyPodEvictionPolicy: AlwaysAllow
127128
monitoring:
128129
serviceMonitor:
129130
enabled: true

helm/sim/examples/values-gcp.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,9 @@ ingress:
201201
# Pod disruption budget for high availability
202202
podDisruptionBudget:
203203
enabled: true
204-
minAvailable: 1
205-
204+
minAvailable: null
205+
maxUnavailable: 1
206+
unhealthyPodEvictionPolicy: AlwaysAllow
206207
# Network policies
207208
networkPolicy:
208209
enabled: true

helm/sim/examples/values-production.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ autoscaling:
165165
# Pod disruption budget (ensures minimum availability during cluster maintenance)
166166
podDisruptionBudget:
167167
enabled: true
168-
minAvailable: 1
168+
minAvailable: null
169+
maxUnavailable: 1
170+
unhealthyPodEvictionPolicy: AlwaysAllow
169171

170172
# Monitoring integration with Prometheus
171173
monitoring:
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{{- if and .Values.podDisruptionBudget.enabled .Values.app.enabled }}
2+
{{- with .Values.podDisruptionBudget }}
3+
---
4+
apiVersion: policy/v1
5+
kind: PodDisruptionBudget
6+
metadata:
7+
name: {{ include "sim.fullname" $ }}-app-pdb
8+
namespace: {{ $.Release.Namespace }}
9+
labels:
10+
{{- include "sim.app.labels" $ | nindent 4 }}
11+
spec:
12+
{{- if .minAvailable }}
13+
minAvailable: {{ .minAvailable }}
14+
{{- else if .maxUnavailable }}
15+
maxUnavailable: {{ .maxUnavailable }}
16+
{{- else }}
17+
maxUnavailable: 1
18+
{{- end }}
19+
{{- if .unhealthyPodEvictionPolicy }}
20+
unhealthyPodEvictionPolicy: {{ .unhealthyPodEvictionPolicy }}
21+
{{- end }}
22+
selector:
23+
matchLabels:
24+
{{- include "sim.app.selectorLabels" $ | nindent 6 }}
25+
{{- end }}
26+
{{- end }}
27+
{{- if and .Values.podDisruptionBudget.enabled .Values.realtime.enabled }}
28+
{{- with .Values.podDisruptionBudget }}
29+
---
30+
apiVersion: policy/v1
31+
kind: PodDisruptionBudget
32+
metadata:
33+
name: {{ include "sim.fullname" $ }}-realtime-pdb
34+
namespace: {{ $.Release.Namespace }}
35+
labels:
36+
{{- include "sim.realtime.labels" $ | nindent 4 }}
37+
spec:
38+
{{- if .minAvailable }}
39+
minAvailable: {{ .minAvailable }}
40+
{{- else if .maxUnavailable }}
41+
maxUnavailable: {{ .maxUnavailable }}
42+
{{- else }}
43+
maxUnavailable: 1
44+
{{- end }}
45+
{{- if .unhealthyPodEvictionPolicy }}
46+
unhealthyPodEvictionPolicy: {{ .unhealthyPodEvictionPolicy }}
47+
{{- end }}
48+
selector:
49+
matchLabels:
50+
{{- include "sim.realtime.selectorLabels" $ | nindent 6 }}
51+
{{- end }}
52+
{{- end }}

helm/sim/values.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,20 @@ autoscaling:
495495
behavior: {}
496496

497497
# Pod disruption budget
498+
# Note: PDBs only protect against voluntary disruptions (node drains, autoscaler)
499+
# They do NOT affect rolling updates - use deployment.strategy.rollingUpdate for that
498500
podDisruptionBudget:
499501
enabled: false
500-
minAvailable: 1
502+
# Use either minAvailable or maxUnavailable (not both)
503+
# Recommendation: Use maxUnavailable as it scales better with HPA
504+
# - minAvailable: minimum pods that must remain available (e.g., 1, "50%")
505+
# - maxUnavailable: maximum pods that can be unavailable (e.g., 1, "25%")
506+
minAvailable: null
507+
maxUnavailable: 1
508+
# unhealthyPodEvictionPolicy: allows eviction of unhealthy pods during node drains
509+
# Options: IfHealthyBudget (default) | AlwaysAllow (recommended for production)
510+
# Set to null to use K8s default (IfHealthyBudget)
511+
unhealthyPodEvictionPolicy: null
501512

502513
# Monitoring configuration
503514
monitoring:

0 commit comments

Comments
 (0)