<p>I am practicing making PV and PVC with Minikube. But I encountered an error that my InfluxDB deployment couldn't find <code>influxdb-pvc</code> and I can't solve it.</p>
<p>I check the message at the top of the event, I can see that my PVC cannot be found. Therefore, I checked the status of PersistentVolumeClaim.</p>
<p>As far as I know, if the <strong>STATUS</strong> of <code>influxdb-pv</code> and <code>influxdb-pvc</code> is <strong>Bound</strong>, it is normally created and Deployment should be able to find <code>influxdb-pvc</code>. I don't know what's going on... Please help me 😢</p>
<hr />
<p>The following is a description of Pod:</p>
<pre><code>&gt; kubectl describe pod influxdb-5b769454b8-pksss

Name:         influxdb-5b769454b8-pksss
Namespace:    ft-services
Priority:     0
Node:         minikube/192.168.49.2
Start Time:   Thu, 25 Feb 2021 01:14:25 +0900
Labels:       app=influxdb
              pod-template-hash=5b769454b8
Annotations:  &lt;none&gt;
Status:       Running
IP:           172.17.0.5
IPs:
  IP:           172.17.0.5
Controlled By:  ReplicaSet/influxdb-5b769454b8
Containers:
  influxdb:
    Container ID:   docker://be2eec32cca22ea84f4a0034f42668c971fefe62e361f2a4d1a74d92bfbf4d78
    Image:          service_influxdb
    Image ID:       docker://sha256:50693dcc4dda172f82c0dcd5ff1db01d6d90268ad2b0bd424e616cb84da64c6b
    Port:           8086/TCP
    Host Port:      0/TCP
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Thu, 25 Feb 2021 01:30:40 +0900
      Finished:     Thu, 25 Feb 2021 01:30:40 +0900
    Ready:          False
    Restart Count:  8
    Environment Variables from:
      influxdb-secret  Secret  Optional: false
    Environment:       &lt;none&gt;
    Mounts:
      /var/lib/influxdb from var-lib-influxdb (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-lfzz9 (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  var-lib-influxdb:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  influxdb-pvc
    ReadOnly:   false
  default-token-lfzz9:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-lfzz9
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  &lt;none&gt;
Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                 node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason            Age                 From               Message
  ----     ------            ----                ----               -------
  Warning  FailedScheduling  20m (x2 over 20m)   default-scheduler  0/1 nodes are available: 1 persistentvolumeclaim &quot;influxdb-pvc&quot; not found.
  Normal   Scheduled         20m                 default-scheduler  Successfully assigned ft-services/influxdb-5b769454b8-pksss to minikube
  Normal   Pulled            19m (x5 over 20m)   kubelet            Container image &quot;service_influxdb&quot; already present on machine
  Normal   Created           19m (x5 over 20m)   kubelet            Created container influxdb
  Normal   Started           19m (x5 over 20m)   kubelet            Started container influxdb
  Warning  BackOff           43s (x93 over 20m)  kubelet            Back-off restarting failed container
</code></pre>
<p>The following is status information for PV and PVC:</p>
<pre><code>&gt; kubectl get pv,pvc
NAME                           CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM                      STORAGECLASS   REASON   AGE
persistentvolume/influxdb-pv   10Gi       RWO            Recycle          Bound       ft-services/influxdb-pvc   influxdb                104m

NAME                                 STATUS   VOLUME        CAPACITY   ACCESS MODES   STORAGECLASS   AGE
persistentvolumeclaim/influxdb-pvc   Bound    influxdb-pv   10Gi       RWO            influxdb       13m
</code></pre>
<hr />
<h2>I proceeded with the setting in the following order.</h2>
<ol>
<li>Create a namespace.</li>
</ol>
<pre><code>kubectl create namespace ft-services
kubectl config set-context --current --namespace=ft-services
</code></pre>
<ol start="2">
<li>Apply my config files: <code>influxdb-deployment.yaml</code>, <code>influxdb-secret.yaml</code>, <code>influxdb-service.yaml</code>, <code>influxdb-volume.yaml</code></li>
</ol>
<p><em>influxdb-deployment.yaml:</em></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: influxdb
  labels:
    app: influxdb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: influxdb
  template:
    metadata:
      labels:
        app: influxdb
    spec:
      containers:
      - name: influxdb
        image: service_influxdb
        imagePullPolicy: Never
        ports:
        - containerPort: 8086
        envFrom:
        - secretRef:
            name: influxdb-secret
        volumeMounts:
        - mountPath: /var/lib/influxdb
          name: var-lib-influxdb
      volumes:
      - name: var-lib-influxdb
        persistentVolumeClaim:
          claimName: influxdb-pvc
</code></pre>
<p><em>influxdb-volume.yaml</em></p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: influxdb-pv
  labels:
    app: influxdb
spec:
  storageClassName: influxdb
  claimRef:
    namespace: ft-services
    name: influxdb-pvc
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  hostPath:
    path: &quot;/mnt/influxdb&quot;
    type: DirectoryOrCreate
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: influxdb-pvc
  labels:
    app: influxdb
spec:
  storageClassName: influxdb
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
</code></pre>
<ol start="3">
<li>Build my docker image: <code>service_influxdb</code></li>
</ol>
<p><em>Dockerfile:</em></p>
<pre><code>FROM alpine:3.13.1

RUN apk update &amp;&amp; apk upgrade --ignore busybox &amp;&amp; \
    apk add \
        influxdb &amp;&amp; \
    sed -i &quot;247s/  #/  /&quot; /etc/influxdb.conf &amp;&amp; \
    sed -i &quot;256s/  #/  /&quot; /etc/influxdb.conf

EXPOSE 8086

ENTRYPOINT influxd &amp; /bin/sh
</code></pre>
<ol start="4">
<li>Check my minikube with dashboard</li>
</ol>
<pre><code>&gt; minikube dashboard

0/1 nodes are available: 1 persistentvolumeclaim &quot;influxdb-pvc&quot; not found.
Back-off restarting failed container

</code></pre>

seheon
<p>I've tested your YAMLs on my Minikube cluster.</p>
<p>Your configuration is correct, however you missed one small detail. Container based on <code>alpine</code> needs to <strong>&quot;do something&quot;</strong> inside, otherwise container exits when its main process exits. Once container did all what was expected/configured, <code>pod</code> will be in <code>Completed</code> status.</p>
<p>Your pod is crashing because it starts up then immediately exits, thus Kubernetes restarts and the cycle continues. For more details please check <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/" rel="nofollow noreferrer">Pod Lifecycle</a> Documentation.</p>
<p><strong>Examples</strong></p>
<p><em>Alpine example:</em></p>
<pre><code>$ kubectl get po alipne-test -w
NAME          READY   STATUS      RESTARTS   AGE
alipne-test   0/1     Completed   2          36s
alipne-test   0/1     CrashLoopBackOff   2          36s
alipne-test   0/1     Completed          3          54s
alipne-test   0/1     CrashLoopBackOff   3          55s
alipne-test   0/1     Completed          4          101s
alipne-test   0/1     CrashLoopBackOff   4          113s
</code></pre>
<p><em>Nginx example:</em></p>
<pre><code>$ kubectl get po nginx
NAME    READY   STATUS    RESTARTS   AGE
nginx   1/1     Running   0          5m23s
</code></pre>
<p>Nginx is a webserver based container so it does not need additional <code>sleep</code> command.</p>
<p><strong>Your Current Configuration</strong></p>
<p>Your pod with influx is created, has nothing to do and exits.</p>
<pre><code>$ kubectl get po -w
NAME                       READY   STATUS             RESTARTS   AGE
influxdb-96bfd697d-wbkt7   0/1     CrashLoopBackOff   4          2m28s
influxdb-96bfd697d-wbkt7   0/1     Completed          5          3m8s
influxdb-96bfd697d-wbkt7   0/1     CrashLoopBackOff   5          3m19s
</code></pre>
<p><strong>Solution</strong></p>
<p>You just need add for example <code>sleep command</code> to keep container alive. For test I've used <code>sleep 60</code> to keep container alive for 60 seconds using below configuration:</p>
<pre><code>    spec:
      containers:
      - name: influxdb
        image: service_influxdb
        imagePullPolicy: Never
        ports:
        - containerPort: 8086
        envFrom:
        - secretRef:
            name: influxdb-secret
        volumeMounts:
        - mountPath: /var/lib/influxdb
          name: var-lib-influxdb
        command: [&quot;/bin/sh&quot;]               # additional command
        args: [&quot;-c&quot;, &quot;sleep 60&quot;]           # args to use sleep 60 command
</code></pre>
<p>And output below:</p>
<pre><code>$ kubectl get po -w
NAME                        READY   STATUS    RESTARTS   AGE
influxdb-65dc56f8df-9v76p   1/1     Running   0          7s
influxdb-65dc56f8df-9v76p   0/1     Completed   0          62s
influxdb-65dc56f8df-9v76p   1/1     Running     1          63s
</code></pre>
<p>It was running for 60 seconds, as <code>sleep</code> command was set to <code>60</code>. As container fulfill all configured commands inside, it exit and status changed to <code>Completed</code>. If you will use commands to keep this container alive, you don't need to use <code>sleep</code>.</p>
<p><strong>PV issues</strong></p>
<p>As last part you mention about issue in <code>Minikube Dashboard</code>. I was not able to replicate it, but it might be some leftovers from your previous test.</p>
<p>Please let me know if you still have issue.</p>
