<p>I use Google Cloud Platform for my project.<br>
Now, I have a cluster with 4 node pools:<br>
- "micro-pool": with minimal machines for managing the cluster<br>
- "cpu-pool": with cpu-only machines for processes that don't need a GPU<br>
- 2 "gpu-pools": two pools with machines that have GPUs attached.  </p>

<p>Now, what I need is for my CPU processes to never work on a GPU machine because they take so much time and doing that on a GPU machine is just costing money for nothing.<br>
I run my pods using the<br>
<code>kubectl run dc-1 --image={image-name} --replicas=1 --restart=Never --limits="nvidia.com/gpu=0,cpu=4000m,memory=2Gi" -- bash -c "command to execute"</code>    </p>

<p>Now, this works fine if there were no "GPU-machines" created from previous GPU runs. But if there was a very recent GPU run, this command will run on that instance because it has the minimum cpu and memory requirements. I thought the <code>--limits="nvidia.com/gpu=0</code> would do the trick but obviously it didn't.  </p>

<p>What should I do? </p>

Ahmedn1
<p>if you want to assign the pod on particular instance or node you can use the kubernetes node selector</p>

<p>for example :</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  nodeSelector:
    disktype: ssd
</code></pre>

<p>here it will assign pod based on the node selector which is disk type.</p>

<p>you can also check this url for further documentation : <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/configuration/assign-pod-node</a></p>

<p><strong>Edit 1</strong> : </p>

<p>as you are on GCP you can use this way also :</p>

<pre><code>nodeSelector:
        #&lt;labelname&gt;:value
        cloud.google.com/gke-nodepool: pool-highcpu8 (poolname)
</code></pre>

<p><strong>Edit 2</strong> : </p>

<p>if you have knowledge of <code>affinity</code> and <code>anity-affinity</code> you can implement it also.</p>

<pre><code>spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: kubernetes.io/node-type
            operator: In
            values:
            - gpu
</code></pre>

<p>For cpu :</p>

<pre><code>spec:
  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
      - weight: 100
        podAffinityTerm:
          labelSelector:
            matchExpressions:
            - key: resources
              operator: In
              values:
              - cpu-only
</code></pre>
