<p>I am reading Core Kubernetes by Vyas and Love. This is the YAML file from page 141, section 7.3.</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: dynamic1
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 100k
---
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - image: busybox
    name: busybox
    volumeMounts:
      - mountPath: /shared
        name: shared
  - image: nginx
    imagePullPolicy: Always
    name: nginx
    ports:
    - containerPort: 80
      protocol: TCP
    volumeMounts:
      - mountPath: /var/www
        name: dynamic1
      - mountPath: /shared
        name: shared
  volumes:
  - name: dynamic1
    persistentVolumeClaim:
      claimName: dynamic1
  - name: shared
    emptyDir: {}
</code></pre>
<p>I run <code>kubectl create</code> on this file, and then <code>kubectl get pods --all-namespaces</code>.  It shows the <code>nginx</code> pod is having status <code>CrashLoopBackOff</code>.  Using <code>kubectl describe pods nginx</code> shows:</p>
<pre><code>Warning  FailedScheduling  105s                default-scheduler  0/1 nodes are available: 1 pod has unbound immediate PersistentVolumeClaims.
Normal   Scheduled         104s                default-scheduler  Successfully assigned default/nginx to minikube
Normal   Pulling           101s                kubelet            Pulling image &quot;nginx&quot;
Normal   Pulled            101s                kubelet            Successfully pulled image &quot;busybox&quot; in 2.289652482s
Normal   Pulled            99s                 kubelet            Successfully pulled image &quot;nginx&quot; in 2.219896558s
Normal   Created           98s                 kubelet            Created container nginx
Normal   Started           98s                 kubelet            Started container nginx
Normal   Pulled            96s                 kubelet            Successfully pulled image &quot;busybox&quot; in 2.23260066s
Normal   Pulled            78s                 kubelet            Successfully pulled image &quot;busybox&quot; in 2.245476487s
Normal   Pulling           49s (x4 over 103s)  kubelet            Pulling image &quot;busybox&quot;
Normal   Created           47s (x4 over 101s)  kubelet            Created container busybox
Normal   Pulled            47s                 kubelet            Successfully pulled image &quot;busybox&quot; in 2.287877562s
Warning  BackOff           46s (x5 over 95s)   kubelet            Back-off restarting failed container
Normal   Started           46s (x4 over 101s)  kubelet            Started container busybox
</code></pre>
<p>Running <code>kubectl logs nginx nginx</code> shows:</p>
<pre><code>/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2022/12/08 14:37:51 [notice] 1#1: using the &quot;epoll&quot; event method
2022/12/08 14:37:51 [notice] 1#1: nginx/1.23.2
2022/12/08 14:37:51 [notice] 1#1: built by gcc 10.2.1 20210110 (Debian 10.2.1-6) 
2022/12/08 14:37:51 [notice] 1#1: OS: Linux 5.15.0-56-generic
2022/12/08 14:37:51 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2022/12/08 14:37:51 [notice] 1#1: start worker processes
2022/12/08 14:37:51 [notice] 1#1: start worker process 30
2022/12/08 14:37:51 [notice] 1#1: start worker process 31
2022/12/08 14:37:51 [notice] 1#1: start worker process 32
2022/12/08 14:37:51 [notice] 1#1: start worker process 33
2022/12/08 14:37:51 [notice] 1#1: start worker process 34
2022/12/08 14:37:51 [notice] 1#1: start worker process 35
2022/12/08 14:37:51 [notice] 1#1: start worker process 36
2022/12/08 14:37:51 [notice] 1#1: start worker process 37
</code></pre>
<p>Running <code>kubectl logs nginx busybox</code> shows nothing.  I then comment out the <code>busybox</code> container inside the <code>nginx</code> pod, it works fine.  When I comment out the 'nginx' container inside the <code>nginx</code> pod, it runs into the error again.  I wonder why this container is causing this problem?  Any insight is appreciated.</p>
<p>Addendum:</p>
<p>Running <code>kubectl get sc</code> shows:</p>
<pre><code>NAME                 PROVISIONER                RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
standard (default)   k8s.io/minikube-hostpath   Delete          Immediate           false                  35h
</code></pre>
<p>Running <code>kubectl get event</code> shows:</p>
<pre><code>LAST SEEN   TYPE      REASON    OBJECT      MESSAGE
2m12s       Warning   BackOff   pod/nginx   Back-off restarting failed container
</code></pre>

CaTx
<p>Googling around, I find this <a href="https://github.com/josedom24/kubernetes/blob/master/ejemplos/busybox/busybox.yaml" rel="nofollow noreferrer">busybox.yaml</a> file which has the <code>sleep</code> command.  I add that to the <code>busybox</code> container as follows:</p>
<pre><code>  - image: busybox
    name: busybox
    command:
      - sleep
      - &quot;3600&quot;
    volumeMounts:
      - mountPath: /shared
        name: shared
</code></pre>
<p>Now the yaml file works.  I guess this is related to Sreepada Jayanthi's answer.  This Reddit <a href="https://www.reddit.com/r/kubernetes/comments/jp2ia9/crashloopbackoff_status_using_busybox_images/" rel="nofollow noreferrer">post</a> also explains the details.</p>
