Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is that possible to schedule DaemonSet with podAffinity? [closed]

Tags:

kubernetes

I'd like to schedule the DaemonSet on specific Nodes where some particular Pod/Service are located. My thoughts are I can label the specific label 'app.type=with-aemon' on the Pods, then I can specify the PodAffinity in daemoSet as below:

    spec:
      affinity:
        podAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app.type
                operator: In
                values:
                - with-daemon
            topologyKey: "kubernetes.io/hostname"

I do see the DaemonSet Pod is running in the specific node, but I also see k8s try to schedule DaemonSet Pods in all other nodes, so these Pod status are always Pending.

Does k8s support to schedule DaemonSet with podAffinity? Is my above usage a common usage?

like image 892
Samuel MA Avatar asked Oct 19 '25 19:10

Samuel MA


1 Answers

Generally, Daemon set default behaviour is to schedule on all Nodes available except there is Taint set.

i am using taint + node affinity to schedule POD on specific node types but would be better to use Deployment in that case instead of using the Daemonset.

It's on your use case you can use Pod affinity, or Anti-affinity if want specific POD to run with Specific types of PODs.

For example : you want to spread out PODs across nodes and run on nodes that have GPU attached in that case you can use multiple options of Node Affinity + taints + POD anti-affinity.

But using Daemonset would be a bad idea, unless you have a requirement to run on all available Nodes or new joining during scaling up or so.

like image 121
Harsh Manvar Avatar answered Oct 22 '25 12:10

Harsh Manvar