terminationGracePeriodSeconds
The pod setting for how long Kubernetes waits after sending SIGTERM before killing the container with SIGKILL, 30 seconds by default.
In more detail
If shutdown takes longer than this, in-flight requests are cut off. Set it longer than your slowest request plus the readiness propagation delay.
Example
Go: server.Shutdown with a context deadline shorter than the grace periodRelated terms
- SIGTERM — The signal that politely asks a process to finish its work and exit.
- graceful shutdown — Stopping a service in an orderly way: finish current work, close connections, then exit.
- Pod — The smallest unit Kubernetes runs: one or more containers scheduled together on the same machine.
- SIGKILL — The signal that ends a process immediately; it cannot be caught or ignored.
- Server.Shutdown — The http.Server method that stops accepting new connections and waits for active requests to finish, up to the deadline of the context you pass.
Taught in
- Health Probes & Graceful Shutdown: Kubernetes Lifecycles — Production Full-Stack Engineering
- Graceful Shutdown on SIGTERM — Concurrent Systems Programming with Go