liveBook · Manning

Ordinal-based naming scheme

As explained in Kubernetes in Action, Second Edition

An ordinal-based naming scheme assigns sequential ordinal identifiers to related pods to provide stable names and identities.

An ordinal-based naming scheme gives related StatefulSet pods sequential names such as quiz-0, quiz-1, and quiz-2. Each ordinal identifies one pod, helping StatefulSets enforce at-most-one semantics: two pods with the same identity cannot run concurrently in one namespace. section 16.2.2

During a node failure, the naming scheme supports strict identity handling:

  • A disconnected node becomes NotReady while its original pod may still be running. section 16.2.2
  • The StatefulSet does not immediately create another pod with the same ordinal identity. section 16.2.2
  • After the original pod is forcibly removed, the same ordinal, such as quiz-1, can be recreated elsewhere. section 16.2.2

Inspecting ordinal identities

Running kubectl get pods -l app=quiz can show quiz-0, quiz-1, and quiz-2. After quiz-1 is removed, Kubernetes recreates quiz-1 rather than assigning an unrelated name. section 16.2.2

How Kubernetes in Action, Second Edition covers it

How deep it goes
Defines the identity guarantee and demonstrates failure handling, but does not detail the naming implementation.
Examples
Uses quiz-0, quiz-1, and quiz-2 pod listings, including quiz-1 during termination and recreation.
What you can do after
Evaluate StatefulSet identity during node failure by inspecting ordinal pod names and statuses with kubectl.
How it connects
Connects pod identity with StatefulSets, ReplicaSets, node failures, and persistent volumes.

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.