Sobes.tech
Senior

Which resource should be used to run a container on each node of a Kubernetes cluster?

sobes.tech AI

Answer from AI

The resource DaemonSet is used to run a container on each node of a Kubernetes cluster. It ensures that an instance of a pod with the required container is running on each node. This is convenient for monitoring agents, logging, network proxies, and other system services.

Example of a DaemonSet manifest:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: example-daemonset
spec:
  selector:
    matchLabels:
      name: example
  template:
    metadata:
      labels:
        name: example
    spec:
      containers:
      - name: example-container
        image: your-image:tag

DaemonSet automatically creates one pod on each node, including new nodes added to the cluster.