The Kubernetes Series - DaemonSets

The Kubernetes Series - DaemonSets

(Photo by Oleg Sergeichik on Unsplash)

In the previous post we explored the kube-scheduler. Let's look at the one deployment type that's a bit different with regards to scheduling in particular, the DaemonSet.

A DaemonSet is similar to ReplicaSets in that it runs multiple instances of Pods on multiple nodes. Except that it runs an instance of the DaemonSet Pod on every node. Thus, every node created in a particular namespace on your cluster will run an instance of the defined DaemonSet Pods by default.

Why would you want to do this? Well, some application helper services would need to be included with every deployment, like for instance logging applications. And remember the kube-proxy discussed in the post on Worker Nodes? That is a DaemonSet too. If you recall, it handles the networking between nodes and pods in your cluster, and would thus need a service touch-point on each node.

We can create DaemonSets in a similar way to ReplicaSets, ala with a YAML definition file. Let's look at deamonset.yml;

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: logging-daemon
spec:
  selector:
    matchLabels:
      app: logging-app
  template:
    metadata:
      labels:
        app: logging-app
    spec:
      containers:
      - name: logging-container
        image: logging-image

And there you have a logging DaemonSet running on very node.

Conclusion

We had a look at what a DaemonSet is and how to create one. In the next post we'll be returning to the scheduling theme, and look at the creation of Static Pods and Multiple Schedulers.

Show Comments
👇 Get $100 in credit DigitalOcean Referral Badge