Overview of DaemonSets
Kubernetes DaemonSet is one of the controllers which are at the Kubernetes Master node.
A DaemonSet ensures that all or some nodes run a Pod
As nodes are added to the Kubernetes cluster, Pods have added accordingly for each node as per the DaemonSet defined.
As nodes are removed or drained from the Kubernetes cluster, they are GC. Deleting a DaemonSet will clean up those Pods it created on each node
The DaemonSet Controller creating pods on each nodes |
Where we can use this DaemonSet?
When a Kubernetes cluster running many microservices with multi-nodes there will be a need for Monitoring the system resources with collecting metrics and Logging should be enabled for the application level or database level to collect respective access and server-specific logs.
Some example daemon pods can be:
- Collectd, Node exporter -- Monitoring daemon on nodes for Prometheus
- Fluentd, logstash – log collection daemon for ELK, EFK stacks
- Ceph, glusterd – Storage daemon for Cloud storages
kubectl get nodes
Creating DaemonSet
apiVersion: apps/v1 kind: DaemonSet metadata: name: fluentd-ds spec: selector: matchLabels: name: fluentd template: metadata: labels: name: fluentd spec: tolerations: # Tolerations - key: node-role.kubernetes.io/master effect: NoSchedule containers: - name: fluentd-con image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
kubectl create -f fluentd-daemonset.yaml
List the pods with wide option
kubectl get po -o wide
Get the DaemonSet object
kubectl get daemonset -o wideThe output of the above command is:
Observe that DaemonSet created pod ControlledBy line it will be under control of DaemonSet.
kubectl describe ds
Describe the DaemonSet |
Cleanup DaemonSet
kubectl delete ds fluentd-ds
Confirm that DaemonSet is detleted by checking the list ds
kubectl get ds
No comments:
Post a Comment