Skip to content

Commit 234d281

Browse files
committed
feat: enable zero-downtime deployments with Helm and PodDisruptionBudget
- Add PodDisruptionBudget template with minAvailable: 1 - Fix RollingUpdate strategy: maxUnavailable: 0, maxSurge: 1 - Enable PDB in production values - Update prod workflow to use helm upgrade instead of oc rollout restart
1 parent d1f5b23 commit 234d281

File tree

5 files changed

+46
-5
lines changed

5 files changed

+46
-5
lines changed

.github/workflows/deploy-to-prod.yaml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ jobs:
4747
needs: validate
4848
runs-on: ubuntu-latest
4949
steps:
50+
- name: Checkout repository at version tag
51+
uses: actions/checkout@v4
52+
with:
53+
ref: ${{ inputs.version }}
54+
5055
- name: Install OpenShift CLI
5156
uses: redhat-actions/openshift-tools-installer@v1
5257
with:
@@ -74,10 +79,23 @@ jobs:
7479
oc -n ${{ env.OPENSHIFT_NAMESPACE_TOOLS }} tag \
7580
${{ env.IMAGE_NAME }}:${{ inputs.version }} ${{ env.IMAGE_NAME }}:prod
7681
77-
- name: Deploy to prod
82+
- name: Install Helm
83+
run: |
84+
curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
85+
helm version
86+
87+
- name: Deploy with Helm
7888
run: |
79-
oc -n ${{ env.OPENSHIFT_NAMESPACE_PROD }} rollout restart deployment/${{ env.APP_NAME }}
80-
oc -n ${{ env.OPENSHIFT_NAMESPACE_PROD }} rollout status deployment/${{ env.APP_NAME }} --timeout=5m
89+
helm upgrade --install ${{ env.APP_NAME }} ./helm/${{ env.APP_NAME }} \
90+
--namespace ${{ env.OPENSHIFT_NAMESPACE_PROD }} \
91+
--values ./helm/${{ env.APP_NAME }}/values-prod.yaml \
92+
--set image.tag=prod \
93+
--wait --timeout=5m
94+
95+
- name: Verify deployment
96+
run: |
97+
echo "Deployment successful!"
98+
oc get pods -n ${{ env.OPENSHIFT_NAMESPACE_PROD }} -l app.kubernetes.io/name=${{ env.APP_NAME }}
8199
82100
echo "Deployment successful!"
83101
oc get pods -n ${{ env.OPENSHIFT_NAMESPACE_PROD }} -l app.kubernetes.io/name=${{ env.APP_NAME }}

helm/eagle-admin/templates/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ spec:
1818
strategy:
1919
type: RollingUpdate
2020
rollingUpdate:
21-
maxSurge: 25%
22-
maxUnavailable: 25%
21+
maxSurge: 1
22+
maxUnavailable: 0
2323
template:
2424
metadata:
2525
{{- with .Values.podAnnotations }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if and .Values.podDisruptionBudget.enabled (gt (int .Values.replicaCount) 1) }}
2+
apiVersion: policy/v1
3+
kind: PodDisruptionBudget
4+
metadata:
5+
name: {{ include "eagle-admin.fullname" . }}
6+
labels:
7+
{{- include "eagle-admin.labels" . | nindent 4 }}
8+
spec:
9+
minAvailable: {{ .Values.podDisruptionBudget.minAvailable | default 1 }}
10+
selector:
11+
matchLabels:
12+
{{- include "eagle-admin.selectorLabels" . | nindent 6 }}
13+
{{- end }}

helm/eagle-admin/values-prod.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ resources:
1515
cpu: 100m
1616
memory: 256Mi
1717

18+
# Pod Disruption Budget - ensure at least 1 pod during disruptions
19+
podDisruptionBudget:
20+
enabled: true
21+
minAvailable: 1
22+
1823
env:
1924
DEPLOYMENT_ENVIRONMENT: "prod"
2025
BANNER_COLOUR: ""

helm/eagle-admin/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,8 @@ autoscaling:
8080
minReplicas: 2
8181
maxReplicas: 4
8282
targetCPUUtilizationPercentage: 80
83+
84+
# Pod Disruption Budget
85+
podDisruptionBudget:
86+
enabled: false
87+
minAvailable: 1

0 commit comments

Comments
 (0)