LeetQuiz Logo
Privacy Policy•contact@leetquiz.com
© 2025 LeetQuiz All rights reserved.
Google Professional Cloud Developer

Google Professional Cloud Developer

Get started today

Ultimate access to all questions.


How should you configure a Deployment in Google Kubernetes Engine (GKE) to include a database connection check and ensure a graceful shutdown with a container script if the connection fails?

(Optionally include a corrected code block if the original contained syntax errors or typos related to liveness/readiness probes or lifecycle hooks.)

Exam-Like



Explanation:

The correct approach is to use a livenessProbe to check database connectivity and a PreStop lifecycle handler for graceful shutdown. The livenessProbe continuously verifies if the container can connect to the database. If it fails, Kubernetes triggers a restart. Before termination, the PreStop hook executes the shutdown script, ensuring a graceful exit. Option C's PostStart is a one-time check at startup, not ongoing. Option D's initContainer only checks during initialization, not runtime. Option A uses Jobs, which are unrelated to the pod lifecycle. Thus, option B is correct.

Powered ByGPT-5