<p>I tried to follow <a href="https://medium.com/@dilipkumar/standalone-mongodb-on-kubernetes-cluster-19e7b5896b27" rel="nofollow noreferrer">this link</a> about Kubernetes MongoDB with persistent volume (exactly same).</p>

<p>but aftrer I deploy everything and take a look on the pod, I got these errors:</p>

<pre><code>Name:           mongodb-standalone-0
Namespace:      default
Priority:       0
Node:           &lt;none&gt;
Labels:         app=database
                controller-revision-hash=mongodb-standalone-7688499856
                selector=mongodb-standalone
                statefulset.kubernetes.io/pod-name=mongodb-standalone-0
Annotations:    &lt;none&gt;
Status:         Pending
IP:             
IPs:            &lt;none&gt;
Controlled By:  StatefulSet/mongodb-standalone
Containers:
  mongodb-standalone:
    Image:      mongo:4.0.8
    Port:       &lt;none&gt;
    Host Port:  &lt;none&gt;
    Environment:
      MONGO_INITDB_ROOT_USERNAME_FILE:  /etc/k8-training/admin/MONGO_ROOT_USERNAME
      MONGO_INITDB_ROOT_PASSWORD_FILE:  /etc/k8-training/admin/MONGO_ROOT_PASSWORD
    Mounts:
      /config from mongodb-conf (ro)
      /data/db from mongodb-data (rw)
      /docker-entrypoint-initdb.d from mongodb-scripts (ro)
      /etc/k8-training from k8-training (ro)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-xbl5z (ro)
Conditions:
  Type           Status
  PodScheduled   False 
Volumes:
  k8-training:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  k8-training
    Optional:    false
  mongodb-scripts:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      mongodb-standalone
    Optional:  false
  mongodb-conf:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      mongodb-standalone
    Optional:  false
  mongodb-data:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  mongodb-standalone
    ReadOnly:   false
  default-token-xbl5z:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-xbl5z
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  kubernetes.io/hostname=mongodb-node
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason            Age        From               Message
  ----     ------            ----       ----               -------
  Warning  FailedScheduling  &lt;unknown&gt;  default-scheduler  0/1 nodes are available: 1 node(s) didn't match node selector.
  Warning  FailedScheduling  &lt;unknown&gt;  default-scheduler  0/1 nodes are available: 1 node(s) didn't match node selector.
</code></pre>

<p>Result of <code>kubectl get nodes --show-labels</code>:</p>

<pre><code>minikube   Ready    master   43h   v1.17.0   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=minikube,kubernetes.io/os=linux,node-role.kubernetes.io/master=
</code></pre>

<p>I've tried to find a way to debug this issue, got nothing..</p>

<p>I successfully run my MongoDB with my apps in Kubernetes, but the problem is I want to have persistent volume for my data and so far I couldn't find the right approach to make it works.
I appreciate any help, thank you.</p>

<hr>

<h2>UPDATE</h2>

<p>I have followed to change the nodeSelector, but still got same error:</p>

<pre><code>Name:           mongodb-standalone-0
Namespace:      default
Priority:       0
Node:           &lt;none&gt;
Labels:         app=database
                controller-revision-hash=mongodb-standalone-74895d955f
                selector=mongodb-standalone
                statefulset.kubernetes.io/pod-name=mongodb-standalone-0
Annotations:    &lt;none&gt;
Status:         Pending
IP:             
IPs:            &lt;none&gt;
Controlled By:  StatefulSet/mongodb-standalone
Containers:
  mongodb-standalone:
    Image:      mongo:4.0.8
    Port:       &lt;none&gt;
    Host Port:  &lt;none&gt;
    Environment:
      MONGO_INITDB_ROOT_USERNAME_FILE:  /etc/k8-training/admin/MONGO_ROOT_USERNAME
      MONGO_INITDB_ROOT_PASSWORD_FILE:  /etc/k8-training/admin/MONGO_ROOT_PASSWORD
    Mounts:
      /config from mongodb-conf (ro)
      /data/db from mongodb-data (rw)
      /docker-entrypoint-initdb.d from mongodb-scripts (ro)
      /etc/k8-training from k8-training (ro)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-xbl5z (ro)
Conditions:
  Type           Status
  PodScheduled   False 
Volumes:
  k8-training:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  k8-training
    Optional:    false
  mongodb-scripts:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      mongodb-standalone
    Optional:  false
  mongodb-conf:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      mongodb-standalone
    Optional:  false
  mongodb-data:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  mongodb-standalone
    ReadOnly:   false
  default-token-xbl5z:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-xbl5z
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  kubernetes.io/hostname=minikube
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason            Age        From               Message
  ----     ------            ----       ----               -------
  Warning  FailedScheduling  &lt;unknown&gt;  default-scheduler  0/1 nodes are available: 1 node(s) didn't find available persistent volumes to bind.
  Warning  FailedScheduling  &lt;unknown&gt;  default-scheduler  0/1 nodes are available: 1 node(s) didn't find available persistent volumes to bind.
</code></pre>

Darryl RN
<p>I guess you are missing label <code>kubernetes.io/hostname: mongodb-node</code> on your node.</p>

<ul>
<li>you can remove nodeSelector from your yaml:</li>
</ul>

<pre><code>      nodeSelector:
        kubernetes.io/hostname: mongodb-node
</code></pre>

<ul>
<li>you can label your node with <code>kubectl label node &lt;your_node_name&gt; kubernetes.io/hostname=mongodb-node --overwrite</code> but I do not recommend the this approach.</li>
<li>you can change <code>nodeSelector</code> to a proper one, juest check your <code>kubernetes.io/hostname</code> with <code>kubectl get no --show-labels</code></li>
</ul>
