VBoi
VBoi

Reputation: 399

Kubernetes DaemonSet only on master nodes

Is there a way to run a Kubernetes DaemonSet only on master nodes? I know this is possible with deployments but can this behaviour be replicated with DaemonSets?

Upvotes: 1

Views: 4400

Answers (4)

VBoi
VBoi

Reputation: 399

I used a mix of nodeSelector and tolerations to achieve this. Here's the code -

  tolerations:
  - key: node-role.kubernetes.io/master
    operator: Exists
    effect: NoSchedule

  nodeSelector:
    kubernetes.io/role: master

Upvotes: 5

Subramanian Manickam
Subramanian Manickam

Reputation: 1349

You can use tolerations and node affinity in DaemonSet manifest files.

 Ex:
 ......
 tolerations:
 - key: "node-role.kubernetes.io/master"
   operator: Exists
 affinity:
   nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: "node-role.kubernetes.io/master"
            operator: Exists
   .....

Upvotes: 3

Anmol Agrawal
Anmol Agrawal

Reputation: 904

You can add a nodeSelector (similar to deployments) which selects only master nodes in daemonset.

Upvotes: 1

BMW
BMW

Reputation: 45223

Yes, it is called Static pod.

https://kubernetes.io/docs/tasks/configure-pod-container/static-pod/

Put the related kubernetes yaml file to Master's StaticPath (normally it is /etc/kubernetes/manifests)

when the master started, these pods will be run automatically as daemonSet

Upvotes: 0

Related Questions