Interview Prep/Kubernetes/Reliability & Rollouts

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
All Kubernetes questions

More on Reliability & Rollouts