Workload Controller Kinds

Deployment, ReplicaSet, StatefulSet, DaemonSet, Job and CronJob manage Pods for you, and at first they seem to do the same thing. Which one does your workload need, and which questions narrow it to one?

Play the animation 6 steps, animated, plays on a computer or a tablet

Workload Controller Kinds diagram: Six workload controller kinds over one row of Pods, where a Deployment creates a

Workload Controller Kinds, step by step

  1. Six main 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 that controller.

    Play from step 1
  2. 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
  3. First question, does a replica need an identity. A StatefulSet names each Pod after itself and an ordinal, so in a StatefulSet called web the Pod with ordinal 0 is web-0, and a replacement comes back under that name. A Deployment promises none of it.

    Play from step 3
  4. Second question, does the Pod 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 its Pod away.

    Play from step 4
  5. Third question, does the work end. A Job runs Pods until the work is done or the Job gives up, and then it stops. A ReplicaSet, a StatefulSet and a DaemonSet are each meant to keep running.

    Play from step 5
  6. A CronJob adds a schedule. On each tick it creates about one Job, not exactly one, and that Job creates the Pods. So a CronJob reaches a Pod through a second controller.

    Play from step 6

Sources