Workload Controller Kinds
Six built-in kinds manage Pods for you, so which one does a workload want? Three questions separate them: whether a replica needs a stable identity, which is the StatefulSet, whether the count follows the matching Node set rather than a number you set, which is the DaemonSet, and whether the work ends, which is the Job. A Deployment reaches its Pods through a ReplicaSet and a CronJob through a Job, and Deployment replaces the legacy ReplicationController.
Play the animation 6 steps, animated, best on a wide screen
Workload Controller Kinds, step by step
-
Six built-in kinds manage Pods for you, and each one of them ends at the same thing, a Pod. Four create Pods directly. The other two create another controller instead, so their Pods always arrive through something else.
Play from step 1 -
A Deployment is the common case for a stateless app. It creates a ReplicaSet and the ReplicaSet creates the Pods, which is why you rarely write a ReplicaSet yourself. Those replicas are interchangeable and how many there are is a number you set.
Play from step 2 -
First question, does a replica need an identity. A StatefulSet names each Pod after itself and an ordinal, so ordinal 0 of a StatefulSet called web is web-0 and a replacement comes back under that name. A Deployment promises none of it.
Play from step 3 -
Second question, does the count follow the Nodes. A DaemonSet carries no replica number at all. It places one Pod on each Node that matches, so a matching Node joining the cluster gains a Pod and a Node leaving takes one away.
Play from step 4 -
Third question, does the work end. A Job runs Pods until the work is finished or it gives up, and then stops, where a ReplicaSet, a StatefulSet and a DaemonSet are each meant to keep running. That is the line between a workload you keep up and a task you want finished.
Play from step 5 -
A CronJob answers when rather than what. On each tick of its schedule it creates a Job, about one per tick and not exactly one, and that Job creates the Pods, so a CronJob reaches a Pod through a second controller.
Play from step 6