<p>I  have the following code for pod creation. I have two nodes one master and another node is worker node, I am creating two pods I need one pod to be scheduled on the master and the other pod on the worker node. I have not specified for pod second testing1 to be scheduled on a worker node because by default pods are scheduled on worker nodes. But the second pod testing1 is also scheduled on the master node.</p>
<p>Yaml file:</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
   name: test
   labels:
      app: test
spec:
   containers:
     - name: test
       image: test:latest
       command: [&quot;sleep&quot;]
       args: [&quot;infinity&quot;]
       imagePullPolicy: Never
       ports:
         - containerPort: 8080
    nodeSelector:
      node_type: master_node
    tolerations:
     - key: node-role.kubernetes.io/master
       effect: NoSchedule

kind: Pod
metadata:
   name: testing1
   labels:
      app: testing1
spec:
   containers:
     - name: testing1
       image: testing1:latest
       command: [&quot;sleep&quot;]
       args: [&quot;infinity&quot;]
       imagePullPolicy: Never
</code></pre>
<p>Thanks help is highly appreciated in solving this issue.</p>
<p>Help is highly appreciated. Thanks</p>

Mazia
<p>You can use nodeAffinity / antiAffinity to solve this.</p>
<p>Why would you assign pods to a master node?</p>
<p>The master nodes are the control plane for your k8s cluster which may cause a negative impact if the pods you schedule on the master node consume too much resources.</p>
<p>If you really want to assign a pod to a master node I recommend you untaint 1 master node and remove the NoSchedule taint and then assign a nodeAffinity to this single master node unless you really need to run this on all your master nodes .</p>
