Kubernetes DaemonSet (ds)

 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 

Running your DaemonSet

First, check that how many nodes in the cluster and what are their status.

  kubectl get nodes

Creating DaemonSet


Defining the DaemonSet in YAML for fluentd Image.
 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 wide
The output of the above command is:
ds



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

References:

Comments

Popular posts from this blog

Ansible 11 The uri module with examples

Jenkins Active choices parameter - Dynamic input

DevOps Weapons