Created
November 2, 2025 22:05
-
-
Save aojea/14800bece6f35958875fc638cf7171a4 to your computer and use it in GitHub Desktop.
KCD Porto 2025 - Achieving Zero-Downtime Deployments in Kubernetes"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apiVersion: apps/v1 | |
| kind: Deployment | |
| metadata: | |
| name: server-deployment | |
| labels: | |
| app: MyApp | |
| spec: | |
| replicas: 2 | |
| selector: | |
| matchLabels: | |
| app: MyApp | |
| template: | |
| metadata: | |
| labels: | |
| app: MyApp | |
| spec: | |
| # This ensures pods try to run on different nodes for high availability | |
| affinity: | |
| podAntiAffinity: | |
| preferredDuringSchedulingIgnoredDuringExecution: | |
| - weight: 100 | |
| podAffinityTerm: | |
| labelSelector: | |
| matchExpressions: | |
| - key: app | |
| operator: In | |
| values: | |
| - MyApp | |
| topologyKey: "kubernetes.io/hostname" | |
| # This tells the pod it has 30 seconds to finish requests before being killed | |
| terminationGracePeriodSeconds: 30 | |
| containers: | |
| - name: agnhost | |
| # This is the image that will be running | |
| image: k8s.gcr.io/e2e-test-images/agnhost:2.39 | |
| args: | |
| - netexec | |
| - --http-port=80 | |
| # This tells the app to wait 30s before exiting, to use the grace period | |
| - --delay-shutdown=30 | |
| ports: | |
| - containerPort: 80 | |
| # This Readiness Probe is critical for zero-downtime | |
| readinessProbe: | |
| httpGet: | |
| path: / | |
| port: 80 | |
| initialDelaySeconds: 5 | |
| periodSeconds: 5 | |
| --- | |
| apiVersion: v1 | |
| kind: Service | |
| metadata: | |
| name: lb-service | |
| spec: | |
| type: LoadBalancer | |
| # This setting is good for preserving client IPs | |
| externalTrafficPolicy: Local | |
| selector: | |
| app: MyApp | |
| ports: | |
| - protocol: TCP | |
| port: 80 | |
| targetPort: 80 | |
| --- | |
| apiVersion: policy/v1 | |
| kind: PodDisruptionBudget | |
| metadata: | |
| name: myapp-pdb | |
| spec: | |
| # You can also use minAvailable: 1 | |
| maxUnavailable: 1 | |
| selector: | |
| matchLabels: | |
| app: MyApp |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
watch "kubectl get pods -l app=MyApp -o wide && echo '---' && kubectl get pdb myapp-pdb && echo '---' && kubectl get replicaset"