DaemonSet is a very important topic in CKA certification.
In this blog, we will learn about a basic understanding of Kubernetes DaemonSets and how to create DaemonSets on Kubernetes.
What is DaemonSets?
DaemonSet is an object of Kubernetes, which is deployed in every cluster node. When a pod is deployed as a DaemonSet, the pod deploys a copy of it in every available node in the cluster.
Some examples of DaemonSets are kube-proxy, and any logging or monitoring agent installed in the cluster.
You can list the available DaemonSets in your cluster using the following command
kubectl get daemonset -A
This command will list the available DaemonSets on all namespaces as shown below

And if you want to list the nodes the DaemonSet pod is running on, run the following command
kubectl get pods -l k8s-app=kube-proxy -o wide -n kube-system
This command will list the nodes in which the DaemonSet pod kube-proxy is running as shown below

How to Create DaemonSet
First, create a manifest file daemonset.yaml and copy the content given below
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: nginx-daemonset
labels:
app: nginx
spec:
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx-container
image: nginx:latest
This file will deploy a DaemonSet of Nginx on the default namespace on all available nodes.
Run the following command to deploy the DaemonSet
kubectl apply -f daemonset.yaml
Once it is deployed you can verify if it’s deployed as DaemonSet using the command
kubectl get po -o wide

Conclusion
In summary, we have learned about DaemonSets and how to create one.
I believe this blog gives you a basic understanding of DaemonSets.