Lab: Working With Kubernetes Daemonsets: Objective

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Lab: Working with Kubernetes DaemonSets

Introduction
A Kubernetes DaemonSet is a container tool that ensures that all nodes (or a specific subset of
them, but we’ll get to that later) are running exactly one copy of a pod. DaemonSets will even
create the pod on new nodes that are added to your cluster!
When using Kubernetes, most of the time you don’t care where your pods are running, but
sometimes you want to run a single pod on all your nodes
In this Lab, you will learn below items:

Objective:
• Create DaemonSet
• Verify Daemonset
• Cleanup

Note: Ensure you have running cluster deployed


1. Ensure that you have logged-in as root user with password as linux on kube-master node.

1.1 Let us clone the git repository which contains manifests required for this exercise, by executing the
below command.

# git clone https://github.com/EyesOnCloud/k8s-daemonset.git

Output:

Student Material – Do Not Re-distribute. For any queries contact:


[email protected] or https://www.linkedin.com/in/naushadpasha/
1.2 Let us view the manifest file.

# cat -n ~/k8s-daemonset/daemonset.yaml
Output:

1.3 Let us create the daemonset, by executing the below command.


# kubectl create -f ~/k8s-daemonset/daemonset.yaml
Output:

1.4 Let’s see verify the DaemonSet is created and ready, by executing below command.

# kubectl get ds webserver


Output:

Student Material – Do Not Re-distribute. For any queries contact:


[email protected] or https://www.linkedin.com/in/naushadpasha/
1.5 Let’s verify the pods are created on all the nodes, by executing the below command.

# kubectl get pods -l name=webserver -o wide


Output:

Note: Daemonset by design schedules at least one pod running on each node of the cluster. If
we add another node to the cluster, then a pod will be scheduled in the new node. Due to
limitation of this demo cluster, we won’t be able to show this functionality.
1.6 Let’s clean up by deleting the DaemonSet, by executing the below command.

# kubectl delete -f ~/k8s-daemonset


Output:

Student Material – Do Not Re-distribute. For any queries contact:


[email protected] or https://www.linkedin.com/in/naushadpasha/

You might also like