PROFESSIONAL-CLOUD-DEVELOPER · Question #228
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 w
The correct answer is B. Create the Deployment with a livenessProbe for the container that will fail if the container can't. A livenessProbe continuously checks whether a running container is still healthy. Configuring it to test database connectivity means Kubernetes will detect the failure. To run a graceful shutdown script before the container is terminated, you add a preStop lifecycle hook - Kubern
Question
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?
Options
- ACreate two jobs: one that checks whether the container can connect to the database, and another
- BCreate the Deployment with a livenessProbe for the container that will fail if the container can't
- CCreate the Deployment with a PostStart lifecycle handler that checks the service availability.
- DCreate the Deployment with an initContainer that checks the service availability. Configure a
How the community answered
(60 responses)- A12% (7)
- B80% (48)
- C5% (3)
- D3% (2)
Explanation
A livenessProbe continuously checks whether a running container is still healthy. Configuring it to test database connectivity means Kubernetes will detect the failure. To run a graceful shutdown script before the container is terminated, you add a preStop lifecycle hook - Kubernetes executes this hook before sending SIGTERM, giving the application time to clean up. This combination directly satisfies both requirements. Jobs (A) are for batch workloads and not suited for continuous health monitoring. A postStart handler (C) runs immediately after container start and is not re-evaluated during the container's lifetime. An initContainer (D) runs only once before the main container starts and cannot continuously monitor a live connection.
Topics
Community Discussion
No community discussion yet for this question.