GKE Deployment must verify container can connect to the database and run a graceful shutdown script if connectivity fails. How should you configure the Deployment?
Choose an answer
Tap an option to check your answer.
Correct answer: Add a livenessProbe that fails when the container can't reach the database, and configure a PreStop lifecycle handler to run the shutdown script..
Why this is the answer
The correct approach is to use a livenessProbe and a PreStop lifecycle handler. A livenessProbe is designed to detect if an application inside a container is still running correctly. If the probe fails (e.g., due to a database connection issue), Kubernetes will restart the container, effectively addressing the connectivity problem. The PreStop lifecycle hook is executed immediately before a container is terminated due to an API request or a management event such as a liveness probe failure. This is the ideal place to run a graceful shutdown script, ensuring resources are released properly. Incorrect options: Creating two Jobs is inefficient and not how Kubernetes manages application health and graceful shutdowns within a Deployment. Jobs are typically for one-off or batch tasks. A PostStart handler runs immediately after a container is created, not when it's failing, so it's unsuitable for checking ongoing service availability or reacting to failures. An initContainer runs to completion before the main application container starts. It's good for initial setup but cannot continuously monitor service availability or react to runtime failures.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed