Skip to main content
Kubernetes coreLesson 4 of 13

Workload Types

A Pod is the smallest unit of execution, but users rarely create Pods directly. Usually you create a managing resource (a workload) that decides "how and how many Pods to run", and that resource creates the Pods for you. Compare how three managers handle Pods differently.

Workload in viewDeployment
Pod name—
What sets the countreplicas value
DeploymentManages versionsReplicaSetKeeps the countweb-x2kqpPodweb-9fz7mPodStatefulSetFixed name · storagedb-0PodOwn volumedata-db-0DaemonSetOne per nodeCollectornode-1Collectornode-2Create, manage
RequestAppears in a later step

What you will learn

  • The Deployment → ReplicaSet → Pod ownership chain
  • A recreated Pod gets a new name and IP
  • StatefulSet fixed names and dedicated volumes
  • A DaemonSet's count is set by the number of nodes

When to use what​

If the application isWorkload to useWhat sets the count
Like a web front end or API server, where any of several copies can take a requestDeploymentReplica count
Like a database or message queue, where each copy holds its own dataStatefulSetReplica count (ordinal names)
A collector or agent that must run on every nodeDaemonSetNode count
A migration or computation that runs once and endsJobNumber of required successes
A task repeated at set times daily or weeklyCronJobOne Job per schedule

The Job and CronJob flow continues in Run Once and Finish (Job · CronJob), and Deployment version changes in Zero-Downtime Deploys (Rolling Update).

Try it yourself​

kubectl get deploy,rs,pod -n <namespace> # Deployment → ReplicaSet → Pod chain
kubectl get pod <pod> -o jsonpath='{.metadata.ownerReferences[0].kind}{"\n"}' # Who created this Pod
kubectl get statefulset,pvc -n <namespace> # Ordinal Pods and their volumes
kubectl get daemonset -A # DESIRED/READY vs node count
kubectl logs deploy/<name> # Logs by the higher resource name

Check yourself

  1. Pod db-0 of a StatefulSet is deleted and recreated. What comes back?
  2. You need a log collector on every node, including nodes that join later. Which workload fits?
  3. A script saved the IP of a Deployment Pod, and it broke after the next deploy. Why, and what should it use instead?

Further reading: Workloads (Kubernetes docs) · Deployments · StatefulSets · DaemonSet