liveBook · Manning

Graceful shutdown

As explained in Kubernetes in Action, Second Edition

A graceful shutdown is an orderly termination procedure that stops accepting new work and allows in-progress work to complete before exit.

Graceful shutdown stops accepting new work, lets in-progress work finish, and then exits. In Kubernetes, a pre-stop hook can begin this process before the container receives SIGTERM. section 6.3.2

Gracefully stopping Nginx

Nginx normally closes open connections immediately when it receives SIGTERM. Running nginx -s quit instead stops new connections, waits for in-flight requests, and then exits. A pre-stop hook can run this command before Kubernetes sends SIGTERM. section 6.3.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains the pre-stop and SIGTERM sequence, demonstrates Nginx behavior, and notes that hook failure does not prevent termination.
Examples
Demonstrates nginx -s quit and a YAML preStop exec hook for an Nginx container.
What it assumes
Assumes familiarity with Kubernetes Pods, containers, termination, and lifecycle hooks.
What you can do after
Operate/configure Nginx containers to stop accepting connections and complete in-flight requests before exit.
How it connects
Connects graceful shutdown with Kubernetes, containers, lifecycle hooks, SIGTERM, Nginx, and in-flight requests.

Also explained in

Compare how 4 books explain graceful shutdown →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.