What is a DaemonSet
Create a daemon set in Kubernetes
A DaemonSet ensures that a copy of a pod is running on all nodes in the Kubernetes cluster. Each node has a copy of the pod. When nodes are added to the cluster, pods are added to them, and when nodes are removed from the cluster, the pods are removed. When we delete a DaemonSet, the Pods it created are cleaned up.
A DaemonSet ensures that all nodes are running a copy of a Pod. Usually the node on which a pod runs is selected by the planner, but DaemonSet pods are created and scheduled by the DaemonSet controller.
Daemon set can be used:
- To run cluster storage on each node, such as: glusterd, ceph
- How to run the log collection on each node, e.g. E.g .: fluentd, logstash
- How to run node monitoring on every note; B: Prometheus Node Exporter, Collective, Datadog Agent
To learn more about Daemonset, visit kubernetes.io, the official Kubernetes documentation.
In this article we will create a daemon set of "fluentd_elasticsearch". This will create fluentd_elasticsearch pods on each node in the cluster. Our daemon set definition file will contain the Toleration for Taint of the master node so that the pod can also be scheduled on the master node.
- Kubernetes cluster with at least 1 worker node.
If you want to learn how to create a Kubernetes cluster, click here. This guide will help you create a Kubernetes cluster with 1 master and 2 worker nodes on AWS Ubuntu 18.04 EC2 instances.
What we gonna do?
- Create a daemon set
Create a daemon set
Check whether a daemon set exists in the standard namespace and in all namespaces.kubectl get daemonsets #Get daemonsets from the default namespace kubectl get daemonsets --all-namespaces #Get daemonsets from all namespace using --all-namespace option
In the screenshot above, you can see that a few daemon sets are available. All of these daemon sets are for cluster components.
Now get pods that belong to the namespace "kube-system".kubectl get pods -n kube-system #Get pods from the "kube-system" namespace
All of these pods, which can be seen in the screenshot above, belong to the daemon set of the cluster components.
Obtain a list of proxy pods.kubectl get pods -n kube-system | grep proxy # Get pods from the "kube-system" namespace and grep for proxy
Check what is controlling proxy pods.kubectl describe pod kube-proxy-s5vzp -n kube-system #Describe the pod from the "kube-system" namespace
Get details of the daemon set that controls the proxy pods.kubectl describe daemonset kube-proxy -n kube-system #Describe the daemonset from the "kube-system" namespace
Create a file with the following daemon set definition in it.vim my-daemonset.ymlapiVersion: apps / v1 kind: DaemonSet metadata: name: my-fluentd-elasticsearch-daemonset namespace: kube-system labels: k8s-app: fluentd-logging spec: selector: matchLabels: name: fluentd-elasticsearch template : metadata: labels: name: fluentd-elasticsearch spec: tolerations: - key: node-role.kubernetes.io/master effect: NoSchedule containers: - name: fluentd-elasticsearch image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2 resources: limits: memory: 200Mi requests: cpu: 100m memory: 200Mi volumeMounts: - name: varlog mountPath: / var / log - name: varlibdockercontainers mountPath: / var / lib / docker / containers readOnly: true terminationGracePeriodSeconds: 30 volumes: - name: varlog hostPath: path: / var / log - name: varlibdockerconta iners hostPath: path: / var / lib / docker / containers
In the definition above we have a toleration to the taint of the master node. This will also place the pod on the master node.
Create a daemon set using the definition file created in the step above.kubectl create -f my-daemonset.yml #Create a daemonset kubectl get daemonset -n kube-system # Get daemonset from the "kube-system" namespace
This daemon set was created in the namespace "kube-system".
Describe the daemon set we just created in the kube-system namespace.kubectl describe daemonset my-fluentd-elasticsearch-daemonset -n kube-system #Describe the daemonset from the "kube-system" namespace
The screenshot above shows that the pods have been deployed on 2 nodes.
Now we can get details about the pods that were deployed as daemon sets on 2 nodes.kubectl get pods -n kube-system | grep my-fluentd-elasticsearch-daemonset #Get pods from the "kube-system" namespace and grepkubectl describe pod my-fluentd-elasticsearch-daemonset-4t9vs -n kube-system | grep Node #Describe the pods from the "kube-system" namespace and grepkubectl describe pod my-fluentd-elasticsearch-daemonset-kxfjj -n kube-system | grep Node # Describe the pod from the "kube-system" namespace and grep
In the above figure you can see that the pods were deployed on the worker node "node01" and on the master node "master". The reason the pods were deployed on the master node is because of tolerance to the load on the master node.
In this article, we saw the steps to create a daemon set and saw how the pods in the daemon set are deployed on each node in the Kubernetes cluster.
- How do headaches work
- Can Indian public sector banks be liquidated?
- Do you want to leave Quora sometimes?
- What is the characteristic of baking soda
- Which brand makes the best sparkling water
- What can I join the Air Force
- Why water is denser than ice
- Who will kill Iblis
- In which city should I live
- Do people develop 1
- Wisdom teeth would cause jaw pain
- What is dynamic keto
- What will help you achieve your goals
- Why is Africa not being developed?
- What is the melting point of polycarbonate
- Why does goodwill levy sales tax?
- What does stub mean in programming
- Should college be a free essay
- Is there an ongoing scholarship in Nigeria
- What exactly does the word irreplaceable mean?
- Are parents allowed in SRM freshmen orientation?
- Is watercolor good for treating depression
- Why is heterochromatin transcriptionally inactive
- Who did your ex leave you for
- Where do you apply contour and bronzer
- How's the Amway business going?
- Why do people think linearly
- What is Bostrom's superintelligence talking about
- What is a Boolean value in Python
- How did slim fit clothing become popular
- What are some good music suggestion apps
- Netflix effectively killed the TV pilot
- How can I practice my Spanish?
- Are there Sphynx cats