Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can we mention more than one node label in single nodeSelector in kubernetes

i want to schedule 10 pods in two specific node(total 15 nodes in our kube cluster).

so in replication-controller file i am mentioning two values in nodeSelector like below.

nodeSelector:  
  app: node1  
  app: node2  

problem is that all the time it's taking only node2.whatever sequence i am mentioning, it's taking last node only.

note: node1 and node2 are lables of node.

like image 979
Prakash Avatar asked Jan 23 '26 02:01

Prakash


1 Answers

The better way is in using something like this:

  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: kubernetes.io/hostname
            operator: In
            values:
            - node1
            - node2
like image 71
Alexey Yakunin Avatar answered Jan 25 '26 19:01

Alexey Yakunin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!