Create and Manage Kubernetes DaemonSets¶
Let's see how you can create and manage kubernetes Daemonsets. For this demonstration, let's assume there is a need to run an nginx server on each node. In the real world, your requirements might differ depending on your use case.
Step 1: Create DaemonSet Manifest¶
First, we need to write the DaemonSet manifest as follows:
Required fields:
apiVersion
- Which version of the Kubernetes API you're using to create this object.kind
- What kind of object you want to create.metadata
- Data that helps uniquely identify the object, including a name string, UID , and - optional namespace.spec
- What state you desire for the object.
Step 2: Create DaemonSet¶
Let's use kubectl apply
to apply the manifest and create the DaemonSet:
Step 3: List DaemonSets and Pods¶
Note
daemonset
is abbreviated as ds
.
Also, list pods and verify if they are running on all the nodes in the cluster:
You'll that a copy of the pod is running on all the nodes in the cluster.
Step 4: Delete DaemonSet¶
This will delete the DaemonSet and pods managed by the DaemonSet.
References: