
Answer-first summary for fast verification
Answer: Update your code to process a received SIGTERM signal to gracefully disconnect from the database.
The correct approach is to handle the SIGTERM signal in the application. When Kubernetes terminates a Pod, it sends a SIGTERM signal to allow the application to shut down gracefully. Updating the code to catch this signal (Option A) ensures the application closes the database connection and performs cleanup before termination. - **Option B** (PodDisruptionBudget) is irrelevant here, as it controls voluntary disruptions during maintenance, not graceful shutdowns. - **Option C** (increase terminationGracePeriod) provides more time for shutdown but doesn't fix the root issue if the app doesn't handle SIGTERM. - **Option D** (PreStop hook) can initiate shutdown but is redundant if the app already handles SIGTERM. Since the question allows updating the application, handling SIGTERM (Option A) is the most direct and standard solution.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
How can you modify your application to ensure a graceful shutdown during a deployment update in Google Kubernetes Engine, particularly to properly close database connections before termination?
A
Update your code to process a received SIGTERM signal to gracefully disconnect from the database.
B
Configure a PodDisruptionBudget to prevent the Pod from being forcefully shut down.
C
Increase the terminationGracePeriodSeconds for your application.
D
Configure a PreStop hook to shut down your application.
No comments yet.