Skip to content

Commit 7d77f57

Browse files
committed
feat: add zero-downtime deployment infrastructure
Adds PodDisruptionBudget, RollingUpdate strategy (maxUnavailable: 0), preStop lifecycle hook, and startup probe support for zero-downtime deployments. - PodDisruptionBudget: Ensures sufficient pods remain available during disruptions - RollingUpdate maxUnavailable: 0: Prevents pod unavailability during updates - preStop lifecycle hook: Allows graceful connection draining (10s delay) - Startup probe: Gives slow-starting containers time to initialize (150s total)
1 parent 157f3bf commit 7d77f57

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

helm/eagle-api/templates/deployment.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ spec:
1212
{{- if not .Values.autoscaling.enabled }}
1313
replicas: {{ .Values.replicaCount }}
1414
{{- end }}
15+
strategy:
16+
type: RollingUpdate
17+
rollingUpdate:
18+
maxUnavailable: 0 # Never terminate pods until new ones are ready
19+
maxSurge: 1 # Create one new pod at a time
1520
selector:
1621
matchLabels:
1722
{{- include "eagle-api.selectorLabels" . | nindent 6 }}
@@ -47,6 +52,18 @@ spec:
4752
initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }}
4853
periodSeconds: {{ .Values.probes.readiness.periodSeconds }}
4954
timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }}
55+
{{- if .Values.probes.startup }}
56+
startupProbe:
57+
httpGet:
58+
path: {{ .Values.probes.startup.path }}
59+
port: http
60+
failureThreshold: {{ .Values.probes.startup.failureThreshold }}
61+
periodSeconds: {{ .Values.probes.startup.periodSeconds }}
62+
{{- end }}
63+
lifecycle:
64+
preStop:
65+
exec:
66+
command: ["sh", "-c", "sleep 10"] # Grace period for load balancer to drain
5067
resources:
5168
{{- toYaml .Values.resources | nindent 12 }}
5269
env:

helm/eagle-api/templates/pdb.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{- if gt (int .Values.replicaCount) 1 }}
2+
apiVersion: policy/v1
3+
kind: PodDisruptionBudget
4+
metadata:
5+
name: {{ include "eagle-api.fullname" . }}
6+
namespace: {{ .Values.namespace }}
7+
labels:
8+
{{- include "eagle-api.labels" . | nindent 4 }}
9+
spec:
10+
minAvailable: {{ .Values.podDisruptionBudget.minAvailable | default 2 }}
11+
selector:
12+
matchLabels:
13+
{{- include "eagle-api.selectorLabels" . | nindent 6 }}
14+
{{- end }}

helm/eagle-api/values-prod.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ keycloak:
3434
persistence:
3535
size: 50Gi
3636

37+
# Pod Disruption Budget - ensure at least 2 pods during disruptions
38+
podDisruptionBudget:
39+
minAvailable: 2
40+
3741
autoscaling:
3842
enabled: true
3943
minReplicas: 3

helm/eagle-api/values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ probes:
4747
initialDelaySeconds: 10
4848
periodSeconds: 10
4949
timeoutSeconds: 10
50+
# Startup probe for slow-starting containers (optional, enable in prod)
51+
startup:
52+
path: /api/docs
53+
failureThreshold: 30
54+
periodSeconds: 5
55+
56+
# Pod Disruption Budget
57+
podDisruptionBudget:
58+
minAvailable: 1 # Minimum pods available during disruptions
5059

5160
# Persistent Volume Claim for document uploads
5261
persistence:

0 commit comments

Comments
 (0)