liveBook · Manning

Container recreation

As explained in Kubernetes in Action, Second Edition

Container recreation is the replacement of a terminated container by discarding it and creating a new container.

Container recreation replaces a terminated container by discarding it and creating a new one. Kubernetes commonly calls this process a container restart, but the original container is not reused. Files written to its filesystem disappear, while other containers in the pod continue running. section 6.2.1

A pod-level restart policy controls when recreation occurs:

  • Never does not recreate it, even after failure. The policy applies to every container in the pod. section 6.2.1

Observe a recreated container

Watch the pod, terminate the Envoy container, and observe readiness change before recovery: kubectl get po -w; curl -X POST http://localhost:9901/quitquitquit. The RESTARTS count increases, and events report that the container was created and started again. Repeated failures can produce CrashLoopBackOff through increasing restart delays.

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains replacement, filesystem loss, pod-wide policies, init-container behavior, and back-off without detailing implementation internals.
Examples
Uses an Envoy shutdown endpoint, pod watches, restart counts, and Kubernetes events to demonstrate recreation.
What it assumes
Assumes a pod containing containers and teaches the distinction between container restart terminology and actual recreation.
What you can do after
Operate/configure container recovery by inspecting pod status and events and selecting a pod restart policy.
How it connects
Ties container recreation to pods, restart policies, storage volumes, init containers, and CrashLoopBackOff.

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.