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.

  • How to add Zend Guard Loader support in docker php official image instance?
  • How to cusomize docker0 in Docker for different IP range?
  • Pass environment variable from linux to docker container
  • Manage docker environment for Swarm running cluster with UPC
  • Issues with Running Flask and SQLAlchemy app through Docker
  • Swift Perfect compile command failed for linux environment
  • 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.

  • Lucee 5, Nginx, and Docker Compose not finding sample index.cfm file
  • return from docker-compose up in jenkins
  • Multiple docker images from SBT
  • How to dockerize Ruby on Rails for production?
  • How to manage code changes in rails with docker
  • Can't access docker container on port 80 on OSX
  • 2 Solutions collect form web for “can we mention more than one node label in single nodeSelector in kubernetes”

    Yes, you can.

    If you want the pods to be scheduled to either node1 or node2, you may label both nodes with the same label(s) (for example, app=node), and then add app=node as your nodeSelector. You can add as many labels as you want, but like CJ mentioned, nodeSelector is a map with key and value pairs so it can’t have the same key with different values.

    The pods can be scheduled on any of the nodes that satisfy that nodeSelector.

    For more information, read Assigning Pods to Nodes. Note that there’s a new feature called nodeAffinity that you might also want to try.

    The nodeSelector on a PodSpec is just a map[string]string (instead of the more featureful NodeSelector type that is used in the NodeAffinity object).That means that the key “app” can only have one value, and it ends up being overwritten as “node2”.

    You can accomplish the scheduling between node1 and node2 by applying a common label (e.g. scheduling-group: foo), and then have your replicationController use that label as the nodeSelector.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.