Shashikant shah

Thursday, 25 April 2024

What is a DaemonSet in Kubernetes.

 

What is a daemonSet ?

Guaranteed Placement: DaemonSets are used to ensure that some or all nodes run a copy of a pod. This is useful for pods that provide node-level services, like log collectors or monitoring agents.

One Pod Per Node: Typically, a DaemonSet will create exactly one instance of a pod on each node in the cluster. This ensures that each node runs the specified pod.

Auto Scaling: When nodes are added to the cluster, DaemonSets automatically create pods on those nodes. Conversely, when nodes are removed, DaemonSets remove the corresponding pods.

Update Strategy: DaemonSets support various update strategies like rolling updates, allowing for controlled updates of the pods across the cluster.

Node Selector: DaemonSets can be configured to run on specific nodes based on node selectors, ensuring that they run only on nodes with certain labels.

Use Cases: DaemonSets are commonly used for cluster-wide services such as logging, monitoring, or networking components that must run on each node.

An example of daemonset is : kube-proxy

Anti-virus pods run each node.


2. What is the difference between Daemonset and Multi Container (sidecar, Adapter, Ambassador) and Static pods?

 DaemonSets ensures that a specific pod runs on each node in the cluster.

Multi Container (sidecar, Adapter, Ambassador) enhances the functionality of the main application container within the same pod. Application container and multi-container will be in the same pods.

Static POD: Created by the kubelet and Deploy control plane components as static  pods,  Ignored by the kube-Scheduler.


apiVersion: apps/v1

kind: DaemonSet

metadata:

  name: my-daemonset

spec:

  selector:

    matchLabels:

      app: my-app

  template:

    metadata:

      labels:

        app: my-app

    spec:

      containers:

      - name: my-container

        image: nginx:latest

 

# kubectl apply -f first.yaml

Get DaemonSets: To view all DaemonSets in the cluster:

# kubectl get ds -o wide

# kubectl get pods -o wide --show-labels

Describe a DaemonSet: To get detailed information about a specific DaemonSet:

# kubectl describe daemonset my-daemonset


Delete a DaemonSet: To delete a DaemonSet:

# kubectl delete -f first.yaml

# kubectl delete ds my-daemonset


No comments:

Post a Comment