How do you set graceful shutdown right?
BeginnerProductionReliability & Rollouts
Answer
Handle SIGTERM in the app (stop accepting, finish in-flight requests), set terminationGracePeriodSeconds longer than the longest request, and add a preStop sleep of 5-15 s so endpoint removal propagates to load balancers before shutdown starts.
lifecycle:
preStop:
exec: { command: ["sleep", "10"] }
terminationGracePeriodSeconds: 45
More on Reliability & Rollouts
What are the must-have settings for a production Deployment?BeginnerWhy use image digests or immutable tags instead of `latest`?BeginnerWhat does a PodDisruptionBudget protect and how do you size it?BeginnerWhy do rollouts sometimes cause brief 502/503 errors?BeginnerHow many replicas should you run and how do you spread them?BeginnerWhat should a readiness probe check?Beginner