liveBook · Manning

Pod identity

As explained in Kubernetes in Action, Second Edition

A pod identity is the stable name-based identity that distinguishes a StatefulSet pod from other pod instances.

A pod identity is the stable, name-based identity that distinguishes one StatefulSet pod from another. StatefulSets use ordinal names such as quiz-0, quiz-1, and quiz-2; because two pods with the same name cannot exist in one namespace simultaneously, each identity supports at-most-one execution. section 16.2.2

This matters during node failures. Unlike a ReplicaSet, a StatefulSet does not immediately create a replacement while the original pod with the same identity may still be running. After quiz-1 is force-deleted, the replacement keeps the quiz-1 identity while it is rescheduled. section 16.2.2

Following quiz-1 after a node failure

A failed node leaves quiz-1 Terminating. Force deletion removes the API object, and kubectl get pod quiz-1 then shows the same identity Pending or ContainerCreating on another node. Scheduling can still be delayed by taints, volume node affinity, or an attached volume. section 16.2.2

$ kubectl get pods -l app=quiz
NAME     READY   STATUS        RESTARTS   AGE
quiz-0   2/2     Running       0          12m
quiz-1   2/2     Terminating   0          7m39s     #1
quiz-2   2/2     Running       0          12m

Inspect the StatefulSet pod list to see ordinal identities and the original quiz-1 pod entering Terminating. section 16.2.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains ordinal naming, at-most-one semantics, node failure behavior, force deletion, rescheduling, and volume-related delays.
Examples
Uses quiz-0, quiz-1, and quiz-2, including quiz-1 transitioning through Terminating, Pending, and ContainerCreating.
What it assumes
Assumes familiarity with pods and controllers while teaching StatefulSet identity through ordinal names and a node-failure scenario.
What you can do after
Diagnose StatefulSet replacement behavior with kubectl during node failures and distinguish identity preservation from immediate ReplicaSet replacement.
How it connects
Connects StatefulSet identity with ReplicaSet replacement, Kubernetes nodes, pod lifecycle, scheduling, and persistent volumes.

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.