<p>I am trying to set up a <code>Mongo DB</code>on a specific node on <code>GKE</code>. I upgraded my current cluster using</p>
<pre><code> gcloud container node-pools create mongo --cluster drogo --num-nodes 1 --region us-east1
</code></pre>
<p>It created a new node-pool in the cluster with the name <code>mongo</code>. I have the following <code>Deployment</code>, <code>Volume</code> and <code>Service</code> file.</p>
<h1>Deployment.YAML</h1>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongo
spec:
  selector:
    matchLabels:
      app: mongo
  template:
    metadata:
      labels:
        app: mongo
    spec:
      nodeSelector:
        cloud.google.com/gke-nodepool: mongo
      containers:
        - name: mongo
          image: mongo:3.6.17-xenial
          ports:
            - containerPort: 27017
          volumeMounts:
            - name: storage
              mountPath: /data/db
      volumes:
        - name: storage
          persistentVolumeClaim:
            claimName: mongo-pvc
</code></pre>
<p>In the above file, I provided the <code>nodeSelector</code> cloud.google.com/gke-nodepool: mongo (as mentioned <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/node-pools#deploy" rel="nofollow noreferrer">here</a>)</p>
<h1>Volume.YAML</h1>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mongo-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi
</code></pre>
<h1>Service.YAML</h1>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: mongo
spec:
  selector:
    app: mongo
  ports:
    - port: 27017
      targetPort: 27017
</code></pre>
<p>When I check my pod error it says:</p>
<pre><code>Can’t schedule this Pod because no nodes match the nodeSelector.
Cannot schedule pods: node(s) had volume node affinity conflict.
</code></pre>
<p>What am I doing wrong here? Any help would be appreciable.</p>
<p>This is how I set up <code>Kubernetes Label</code> into a node pool</p>
<p><a href="https://i.stack.imgur.com/mBvx5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mBvx5.png" alt="enter image description here" /></a></p>
<p>I ran <code> gcloud container node-pools describe node  --cluster=drogo --region us-east1</code> and in the response I can see:</p>
<pre><code>autoscaling: {}
config:
  diskSizeGb: 20
  diskType: pd-standard
  imageType: COS_CONTAINERD
  labels:
    mongo: mongo
  machineType: e2-medium
</code></pre>

Amit Pal
<p>There were two issues with the deployment setup:</p>
<p>The <code>nodeSelector</code> specified in the Deployment manifest was using wrong label</p>
<pre><code>  nodeSelector:
    cloud.google.com/gke-nodepool: mongo
</code></pre>
<p>Whereas the created node had a label pair <code>mongo: mongo</code>. Either changing the node label to <code>cloud.google.com/gke-nodepool: mongo</code> or the deployment nodeSelector to <code>mongo: mongo</code> works.</p>
<p>The following issue was that the available <code>persistentVolume</code> lived in AZ <code>us-east1-c</code> whereas the available node was in <code>us-east1-d</code>. Therefore kubernetes scheduler couldn't find a match of requested <code>nodeSelector</code> + <code>PersistentVolume</code> within the same AZ. Issue was solved by adding a new node with the same configuration in AZ <code>us-east1-c</code></p>
