exam questions

Exam Professional Cloud Developer All Questions

View all questions & answers for the Professional Cloud Developer exam

Exam Professional Cloud Developer topic 1 question 211 discussion

Actual exam question from Google's Professional Cloud Developer
Question #: 211
Topic #: 1
[All Professional Cloud Developer Questions]

You need to configure a Deployment on Google Kubernetes Engine (GKE). You want to include a check that verifies that the containers can connect to the database. If the Pod is failing to connect, you want a script on the container to run to complete a graceful shutdown. How should you configure the Deployment?

  • A. Create two jobs: one that checks whether the container can connect to the database, and another that runs the shutdown script if the Pod is failing.
  • B. Create the Deployment with a livenessProbe for the container that will fail if the container can't connect to the database. Configure a Prestop lifecycle handler that runs the shutdown script if the container is failing.
  • C. Create the Deployment with a PostStart lifecycle handler that checks the service availability. Configure a PreStop lifecycle handler that runs the shutdown script if the container is failing.
  • D. Create the Deployment with an initContainer that checks the service availability. Configure a Prestop lifecycle handler that runs the shutdown script if the Pod is failing.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
TNT87
Highly Voted 1 year, 7 months ago
Selected Answer: B
https://cloud.google.com/architecture/best-practices-for-running-cost-effective-kubernetes-applications-on-gke#make_sure_your_applications_are_shutting_down_in_accordance_with_kubernetes_expectations
upvoted 6 times
...
alpha_canary
Most Recent 2 months, 2 weeks ago
Selected Answer: B
"Most programs don't stop accepting requests right away. However, if you're using third-party code or are managing a system that you don't have control over, such as nginx, the preStop hook is a good option for triggering a graceful shutdown without modifying the application. One common strategy is to execute, in the preStop hook, a sleep of a few seconds to postpone the SIGTERM. This gives Kubernetes extra time to finish the Pod deletion process, and reduces connection errors on the client side." https://cloud.google.com/architecture/best-practices-for-running-cost-effective-kubernetes-applications-on-gke#:~:text=If%20your%20application%20doesn%27t%20follow%20the%20preceding%20practice%2C%20use%20the%20preStop%20hook https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks
upvoted 1 times
...
purushi
10 months, 4 weeks ago
Selected Answer: B
I go with B, that is liveness probe and if failed for max retries then call prestop hook to gracefully shutdown the container. D is also very close, but it used init container to check for the database connectivity first. I am not sure whether we can prestop hook if initContainer fails to starts.
upvoted 1 times
...
Pime13
1 year, 4 months ago
Selected Answer: B
https://cloud.google.com/architecture/best-practices-for-running-cost-effective-kubernetes-applications-on-gke#make_sure_your_applications_are_shutting_down_in_accordance_with_kubernetes_expectations -> the preStop hook is a good option for triggering a graceful shutdown without modifying the application. https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#hook-details -> This hook is called immediately before a container is terminated due to an API request or management event such as a liveness/startup probe failure, preemption, resource contention and others. A call to the PreStop hook fails if the container is already in a terminated or completed state and the hook must complete before the TERM signal to stop the container can be sent. The Pod's termination grace period countdown begins before the PreStop hook is executed, so regardless of the outcome of the handler, the container will eventually terminate within the Pod's termination grace period. No parameters are passed to the handler.
upvoted 1 times
...
telp
1 year, 5 months ago
Selected Answer: B
Answer B
upvoted 1 times
...
zellck
1 year, 6 months ago
Selected Answer: B
B is the answer.
upvoted 2 times
...
kisswd
1 year, 7 months ago
Selected Answer: D
D could be the right answer
upvoted 2 times
[Removed]
1 year, 6 months ago
The answer is definitely D. Anytime you need to do some work before a container can be considered ready, you use init containers. With a liveness probe we would need to add an endpoint that checks whether we can connect to the database, with init containers we can separate this logic.
upvoted 1 times
[Removed]
1 year, 6 months ago
Liveness probe also supports other methods to do work beside http, but I hope you understand my message. Here's more on init containers btw: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
upvoted 1 times
zellck
1 year, 6 months ago
initContainer requires separate container to run in addition to the application container, but the question asked for script to be run in the same container.
upvoted 1 times
...
...
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago