Difficulty: beginner
Estimated Time: 10-15 minutes

Overview

A DaemonSet ensures that all (or some) Nodes run a copy of a Pod. As nodes are added to the cluster, Pods are added to them. As nodes are removed from the cluster, those Pods are garbage collected. Deleting a DaemonSet will clean up the Pods it created.

Some typical uses of a DaemonSet are:

  • running a cluster storage daemon, such as glusterd and ceph, on each node.
  • running a logs collection daemon on every node, such as fluentd or logstash.
  • running a node monitoring daemon on every node, such as Prometheus Node Exporter (node_exporter), collectd, Datadog agent, New Relic agent, or Ganglia gmond.

In a simple case, one DaemonSet, covering all nodes, would be used for each type of daemon. A more complex setup might use multiple DaemonSets for a single type of daemon, but with different flags and/or different memory and cpu requests for different hardware types.

Congratulations. You've now created, manipulated and deleted a DaemonSet. Continue onto the next scenario in this course.

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Manage DaemonSets

Step 1 of 4

Create a DaemonSet

In this scenario, we're going to be creating an nginx DaemonSet. Initially, we'll run this on our worker nodes (node01), but then we will manipulate the DaemonSet to get it running on the master node too.

nginx DaemonSet

In your terminal, you'll see a file named nginx-daemonset.yaml. This is the DaemonSet which we will be using to run nginx across both of our nodes.

First, let's create all the prerequisites needed for this DaemonSet to run:

kubectl create -f nginx-ds-prereqs.yaml

Now we've created the namespace (and other prerequisites), let's inspect the manifest for the nginx DaemonSet:

cat nginx-daemonset.yaml; echo

As you can see, we're running a basic DaemonSet - in the contino namespace - which exposes port 80 inside the container.

Create it:

kubectl create -f nginx-daemonset.yaml

Now check the status of the DaemonSet:

kubectl get daemonsets -n contino

Terminal Host 2