Kubernetes DaemonSets: Explained and Guide to Create One
- Last Updated On: March 10, 2024
- By: Aswin Vijayan
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
![Command to list the daemonset pods](https://scriptcrunch.com/wp-content/uploads/2024/03/image-1024x338.png)
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
![command to list the nodes in which the demonset pod is running](https://scriptcrunch.com/wp-content/uploads/2024/03/image-1.png)
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
![command to list the nodes in which the nginx demonset pod is running](https://scriptcrunch.com/wp-content/uploads/2024/03/image-2.png)
Conclusion
In summary, we have learned about DaemonSets and how to create one.
I believe this blog gives you a basic understanding of DaemonSets.
Aswin Vijayan
Other Interesting Blogs
![Exclusive Linux Foundation Coupon Codes](https://scriptcrunch.com/wp-content/uploads/2023/11/linux-foundation-coupon-300x176.png)
Linux Foundation Coupon for July 2024
Hi Techies, I wanted to let you know about a pretty sweet deal with the Linux Foundation Coupon that is running now.
![Exclusive Linux Foundation Coupon Codes](https://scriptcrunch.com/wp-content/uploads/2023/11/linux-foundation-coupon.png)
![CKA Exam Guide](https://scriptcrunch.com/wp-content/uploads/2020/09/cka-exam-guide--300x176.png)
CKA Exam Study Guide: Certified Kubernetes Administrator
This comprehensive CKA certification exam study guide covers all the important aspects of the Certified Kubernetes Administrator exam and useful resources. Passing
![CKA Exam Guide](https://scriptcrunch.com/wp-content/uploads/2020/09/cka-exam-guide-.png)
![Linux Foundation LFCA & LFCS](https://scriptcrunch.com/wp-content/uploads/2022/07/lfcs-lfca-300x176.png)
[40% OFF] Linux Foundation LFCA, LFCS & LFCT Exam Voucher Codes
Linux Foundation has announced up to a $284 discount on its Linux certification programs Linux Foundation Certified IT Associate (LFCA) and Linux
![Linux Foundation LFCA & LFCS](https://scriptcrunch.com/wp-content/uploads/2022/07/lfcs-lfca.png)