<p>I have created a GKE Kubernetes cluster and two workloads deployed on that cluster, There are separate node pools for each workload. The node pool for celery workload is tainted with 
<code>celery-node-pool=true</code>. 
The pod's spec has the following toleration:</p>

<pre><code>tolerations:
- key: "celery-node-pool"
  operator: "Exists"
  effect: "NoSchedule"    
</code></pre>

<p>Despite having the node taint and toleration some of the pods from celery workload are deployed to the non-tainted node. Why is this happening and am I doing something wrong? What other taints and tolerations should I add to keep the pods on specific nodes?</p>

Rao Anees
<p><strong>Using Taints:</strong></p>

<p>Taints allow a node to repel a set of pods.You have not specified the effect in the taint. It should be <code>node-pool=true:NoSchedule</code>. Also your other node need to repel this pod so you need to add a different taint to other nodes and not have that toleration in the pod.</p>

<p><strong>Using Node Selector:</strong></p>

<p>You can constrain a Pod to only be able to run on particular Node(s) , or to prefer to run on particular nodes.</p>

<p>You can label the node </p>

<pre><code>kubectl label nodes kubernetes-foo-node-1.c.a-robinson.internal node-pool=true
</code></pre>

<p>Add node selector in the pod spec:</p>

<pre><code>kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  nodeSelector:
    node-pool: true
</code></pre>

<p><strong>Using Node Affinity</strong></p>

<p><code>nodeSelector</code> provides a very simple way to constrain pods to nodes with particular labels. The affinity/anti-affinity feature, greatly expands the types of constraints you can express.</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: with-node-affinity
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: node-pool
            operator: In
            values:
            - true
  containers:
  - name: with-node-affinity
    image: k8s.gcr.io/pause:2.0
</code></pre>
