How to deploy DaemonSets Service in Kubernetes (K8s)?
๐ช๐๐๐๐ ๐๐๐ ๐ซ๐๐๐ถ๐๐ ๐ป๐๐๐ ๐ช๐๐๐๐๐๐๐๐ || ๐ท๐๐๐ซ๐๐๐ถ๐๐๐ฎ๐๐ ๐ค https://t.me/prodevopsguy ๐ Hi there! We are ProDevOpsGuy, a passionate DevOps enthusiast Tech Community with a strong belief in the power of automation and collaboration to drive innovation. ๐ I thrive in bridging the gap between development and operations, creating seamless and efficient software delivery pipelines. My journey in the world of DevOps has allowed me to blend my technical skills with a knack for problem-solving, enabling me to contribute effectively to agile and dynamic environments. ๐ก With a keen interest in continuous integration, continuous delivery (CI/CD), containerization, and orchestration, I've had the privilege to explore cutting-edge technologies like Docker, Kubernetes, Jenkins, and Ansible. I find joy in designing scalable and resilient infrastructures that enable teams to deploy applications faster and with greater confidence. ๐ Beyond the tech realm, I'm an advocate for DevOps culture, emphasizing collaboration, communication, and a relentless pursuit of improvement. I'm always eager to connect with fellow professionals, exchange insights, and explore opportunities to collaborate on exciting projects. ๐ When I'm not tinkering with the latest DevOps tools, you can find me indulging in books on technology trends, hiking to rejuvenate, and occasionally experimenting with new coding challenges. ๐ Let's connect! Whether you're looking to discuss DevOps methodologies, explore partnership opportunities, or simply share experiences, feel free to reach out. I'm excited to be part of the DevOps journey, driving excellence together.

DaemonSets in Kubernetes Cluster
Like other controllers, DaemonSets manage groups of replicated Pods.
However, DaemonSet ensures that all or selected Worker Nodes run a copy of a Pod (one-Pod-per-node).
As you add nodes, DaemonSets automatically add Pods to the new nodes. As the nodes are removed from the cluster, those Pods are garbage collected.
Here is the manifest of DaemonSet:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: fluentd
namespace: kube-system
labels:
k8s-app: fluentd
spec:
selector:
matchLabels:
name: fluentd
template:
metadata:
labels:
name: fluentd
spec:
containers:
- name: fluentd
image: fluentd:latest
Create a daemonset:
kubectl create -f daemonset.yamldaemonset.apps "fluentd" created
Check the pod running:
kubectl get pods -n kube-systemNAME READY STATUS RESTARTS AGE
fluentd-7svlj 1/1 Running 0 58s
fluentd-kwm4x 1/1 Running 0 58s
fluentd-q64wf 1/1 Running 0 58s
Check no. of nodes:
kubectl get nodes
NAME STATUS ROLES AGE VERSION
gke-cluster-1-default-pool-a6a57f2a-77wb Ready < none > 6h v1.11.6-gke.2
gke-cluster-1-default-pool-a6a57f2a-xkgz Ready < none > 6h v1.11.6-gke.2
gke-cluster-1-default-pool-a6a57f2a-z2bx Ready < none > 6h v1.11.6-gke.2
Display your daemon sets:
kubectl get daemonsets
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE AGE
fluentd 3 3 3 3 3 5m
Get details of a daemonset:
kubectl describe daemonset fluentd
Edit a daemonset:
kubectl edit daemonset fluentd
Delete a daemonset:
kubectl delete daemonset fluentd
daemonset.apps โfluentdโ deleted
Some uses of a DaemonSet are:
running a cluster storage daemon, such as glusterd, ceph, on each node.
running a logs collection daemon on every node, such as fluentd or logstash.
running a node monitoring daemon on every node, such as Prometheus Node Exporter, AppDynamics Agent, Datadog agent, New Relic agent, etc.
Running Pods on Only Some Nodes
If you specify a .spec.template.spec.mode selector, then the DaemonSet controller will create Pods on nodes which match that node selector.
spec:
nodeSelector:
environment: prod
Now, If you mention a .spec.template.spec.affinity, then DaemonSet controller will be creating the Pods on nodes which will be matching the node affinity.
spec:
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
In case you will not specify anything, then the controller will be creating Pods on every node of the cluster.
For Reference






