DEV Community

Cover image for Part-93: 🚀 To Implement the K8s DaemonSets in Google Kubernetes Engine (GCP)
Latchu@DevOps
Latchu@DevOps

Posted on

Part-93: 🚀 To Implement the K8s DaemonSets in Google Kubernetes Engine (GCP)

If you’ve been working with Deployments in Kubernetes, you know they’re great for running workloads across multiple Pods.
But what if you need one Pod running on every Node in your cluster? 🤔

That’s where DaemonSets come in.


🔹 What is a DaemonSet?

A DaemonSet ensures that:

  • Every Node in your cluster runs a copy of a specific Pod
  • When new Nodes are added, Kubernetes automatically places the Pod on them
  • When Nodes are removed, those Pods are also removed
  • Deleting a DaemonSet cleans up all Pods it created

d1

Think of a DaemonSet as:

👉 “One Pod per Node — always.”


🔹 Real-World Use Cases of DaemonSets

DaemonSets are not for running user apps. Instead, they’re used for cluster-level tasks such as:

  • 📦 Storage Daemons

Example: Run a storage agent like Ceph or GlusterFS on every node.

  • 📜 Log Collection Daemons

Example: Run Fluentd, Logstash, or Filebeat on every node to collect and ship logs.

  • 📊 Monitoring Daemons

Example: Run Prometheus Node Exporter or Datadog Agent on every node to collect CPU, memory, and disk metrics.


Implement DaemonSets

Step-01: 📌 Create a file: daemonset.yaml

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: myapp1-daemonset
  namespace: default
  labels:
    app: myapp
spec:  
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: myapp-container
        image: ghcr.io/stacksimplify/kubenginx:1.0.0
Enter fullscreen mode Exit fullscreen mode

Step-02: Deploy and Verify

# Deploy Kubernetes Resources
kubectl apply -f kube-manifests/daemonset.yaml

# Verify DaemonSet
kubectl get daemonset
kubectl get ds

# Verify Pods
kubectl get pods -o wide

Observation: 
1. Verify if pods got scheduled on Nodes created for NodePool:linuxapps-nodepool
NodePool:default
Enter fullscreen mode Exit fullscreen mode

d2


Step-3: Clean-Up

# Delete Kubernetes Resources
kubectl delete -f kube-manifests/daemonset.yaml

# Delete Node pool 
gcloud container node-pools delete "linuxapps-nodepool" \
  --cluster "standard-public-cluster-1" \
  --location "us-central1"
Enter fullscreen mode Exit fullscreen mode

d3


🔹 Quick Recap

  • DaemonSets ensure Pods run on every Node in your cluster.
  • Great for system-level services like logging, monitoring, and storage.
  • Automatically scale with your cluster (add/remove nodes).

✅ That’s it! Now you know when and why to use DaemonSets in Kubernetes.


🌟 Thanks for reading! If this post added value, a like ❤️, follow, or share would encourage me to keep creating more content.


— Latchu | Senior DevOps & Cloud Engineer

☁️ AWS | GCP | ☸️ Kubernetes | 🔐 Security | ⚡ Automation
📌 Sharing hands-on guides, best practices & real-world cloud solutions

Top comments (0)