
For a beginner Kubernetes (k8s) user the variety of objects that you should be aware of can be overwhelming a little bit. In this article I would like to give you an overview of pod controllers object.
But what is the pod? This is a most elementary object. It defines, how our singular work unit will look like. It contains definitions of container(s), configuration, secrets, volumes, health checks definition. Pod can be deployed directly to the cluster. But never (or hardly ever) do it. There are pod controller that you can take advantage of. Here’s a basic overview of most common used.
When to use | Persistent Volume Support | Scaling support | Self healing | Updating Strategies | |
---|---|---|---|---|---|
Deployment | Stateless Applications | Same volume for all replicas | Yes | Yes | Rolling Updates (order of recreation is not guaranteed), Recreate (kills all pods before creating new ones) |
StatefulSet | Stateful Applications | Each replica has its own volume | Yes | Yes | Rolling Update (order of recreation is guaranteed),
OnDelete |
DaemonSet | Need to install application on each kubernetes node | Yes (there is only one replica) | No | Yes | Rolling Update |
In addition to the above, you can take advantage of TTL Controller, Job, CronJob, GarbageCollection.
Being honest, things are a little bit more complicated than described. There are some intermediate object in hierarchy (like ReplicationController), but it should not be used directly as well. You should also be aware that more sophisticated strategies of updating (canary, blue green) workload can be achieved by using some external tool (Istio, Spinnaker, community based canary operators and many others).