A Deployment update in GKE force-terminated your app before it closed its database connection. How should you modify the application to ensure a graceful shutdown?
Choose an answer
Tap an option to check your answer.
Correct answer: Update your code to process a received SIGTERM signal to gracefully disconnect from the database..
Why this is the answer
The correct answer is to update your code to process a received SIGTERM signal. When Kubernetes terminates a Pod, it sends a SIGTERM signal to the containers, giving them a chance to perform graceful shutdown procedures, such as closing database connections, before being forcibly terminated. By handling this signal in your application code, you ensure that resources are properly released. Configuring a PodDisruptionBudget (PDB) prevents voluntary disruptions from dropping the number of available Pods below a certain threshold, but it doesn't address graceful shutdown of individual Pods during an update. Increasing terminationGracePeriodSeconds gives the Pod more time to shut down, but without code to handle the SIGTERM, it won't automatically close connections. A PreStop hook executes before the container is terminated, but it's generally used for cleanup tasks that don't involve the application itself, or as a last resort if the application cannot handle SIGTERM directly. The primary and most robust solution is for the application to respond to SIGTERM.
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