Ultimate access to all questions.
Your application is deployed in a Google Kubernetes Engine (GKE) cluster. When releasing a new version, your CI/CD pipeline updates the spec.template.spec.containers[0].image
field to point to the new Docker image. You want to ensure that at least one replica of the new version is deployed while keeping the old replicas running until the new replica becomes healthy.
What modification should you apply to the following GKE Deployment configuration?
apiVersion: apps/v1
kind: Deployment
metadata:
name: ecommerce-frontend-deployment
spec:
replicas: 3
selector:
matchLabels:
app: ecommerce-frontend
template:
metadata:
labels:
app: ecommerce-frontend
spec:
containers:
- name: ecommerce-frontend-webapp
image: ecommerce-frontend-webapp:1.7.9
ports:
- containerPort: 80
Explanation:
The question requires maintaining previous replicas until the new replica is healthy. The RollingUpdate strategy allows gradual replacement. maxSurge=1 permits creating 1 extra pod (total 4: 3 old + 1 new), ensuring the new pod is added before old ones are removed. maxUnavailable=0 prevents any pod from being unavailable during the update, thus keeping old replicas until the new one is ready. Options C and D use Recreate, which terminates all old pods first. Option A (maxSurge=0) would require removing old pods first, violating the requirement.