Google Professional Cloud DevOps Engineer Question 112
Select 3Google Cloud PlatformYour team is deploying a new version of a critical web application hosted on Google Kubernetes Engine (GKE). To ensure a smooth rollout, you need to safely drain traffic from the existing pods while redirecting traffic to the newly deployed pods. Which steps should you take to achieve this without causing downtime?
- A
Set the
maxSurgeandmaxUnavailableparameters in the deployment's rollingUpdate strategy to control the replacement of pods. - B
Use a preStop hook in the pod's lifecycle to handle cleanup tasks before the pod is terminated.
- C
Manually delete old pods to ensure new pods serve traffic immediately.
- D
Update the Service's selector to point to the new pods and leave the old pods running.
- E
Configure a readiness probe in the new pod specification to ensure traffic is redirected only after the new pods are ready.
Show answer and explanation
Correct answers: A, B, E
Explanation
To safely drain traffic and redirect it to new pods during a deployment, you should leverage Kubernetes-native features such as rolling updates (maxSurge and maxUnavailable), preStop hooks for graceful termination, and readiness probes to ensure new pods are ready before serving traffic. These steps ensure seamless traffic redirection without causing downtime.
- A. Correct.
Setting
maxSurgeandmaxUnavailableallows you to control how many pods are created or taken down during a rolling update, ensuring a controlled traffic shift. - B. Correct.
Using a preStop hook ensures that any necessary cleanup or graceful shutdown operations occur before the pod is terminated, helping prevent service disruptions.
- C. Incorrect.
Manually deleting old pods can cause abrupt disruptions in traffic and risks creating downtime, as it bypasses the rolling update mechanisms.
- D. Incorrect.
Updating the Service's selector to point only to the new pods may leave existing traffic stranded if the old pods are still receiving requests. This is not a recommended method for draining traffic.
- E. Correct.
A readiness probe ensures that new pods do not receive traffic until they are fully initialized and ready to serve requests, preventing disruptions during the transition.