17 Deploying Per-Node Workloads with DaemonSets

 

This chapter covers

  • Running an agent Pod on each cluster node
  • Running agent Pods on a subset of nodes
  • Allowing Pods to access the host node’s resources
  • Assigning a priority class to a Pod
  • Communicating with the local agent Pod

In the previous chapters, you learned how to use Deployments or StatefulSets to distribute multiple replicas of a workload across the nodes of your cluster. But what if you want to run exactly one replica on each node? For example, you might want each node to run an agent or daemon that provides a system service such as metrics collection or log aggregation for that node. To deploy these types of workloads in Kubernetes, you use a DaemonSet.

Before you begin, create the kiada Namespace, change to the Chapter17/ directory, and apply all manifests in the SETUP/ directory by running the following commands:

$ kubectl create ns kiada
$ kubectl config set-context --current --namespace kiada
$ kubectl apply -f SETUP -R
NOTE

17.1 Introducing DaemonSets

A DaemonSet is an API object that ensures that exactly one replica of a Pod is running on each cluster node. By default, daemon Pods are deployed on every node, but you can use a node selector to restrict deployment to some of the nodes.

17.1.1 Understanding the DaemonSet object

17.1.2 Deploying Pods with a DaemonSet

17.1.3 Deploying to a subset of Nodes with a node selector

17.1.4 Updating a DaemonSet

17.1.5 Deleting the DaemonSet

17.2 Special features in Pods running node agents and daemons

17.2.1 Giving containers access to the OS kernel

17.2.2 Accessing the node’s filesystem

17.2.3 Using the node’s network and other namespaces

17.2.4 Marking daemon Pods as critical

17.3 Communicating with the local daemon Pod

17.3.1 Binding directly to a host port

17.3.2 Using the node’s network stack

17.3.3 Using a local Service

17.4 Summary