<p>I'm trying to fix an issue within a Kubernetes pod and am unsure how to proceed. I've tried using different commands to look into what is causing the &quot;Init:CrashLoopBackOff&quot; issue, but not sure what to do.</p>
<p>Here are the commands I've done and the results:
kubectl get pods -n staging-jhub</p>
<pre><code>    NAME                                 READY   STATUS                  RESTARTS         AGE
continuous-image-puller-5bcwt        1/1     Running                 0                19d
continuous-image-puller-rlrtq        1/1     Running                 1 (16d ago)      19d
hub-5655445674-f2xnd                 0/1     Init:CrashLoopBackOff   4671 (84s ago)   16d
hub-5655445674-sxwvs                 0/1     Terminating             865              19d
jupyter-rauyeki-40ucdavis-2eedu      0/1     Terminating             0                25d
jupyter-timstewart-40ucdavis-2eedu   0/1     Terminating             0                49d
jupyter-timstewartj-40gmail-2ecom    0/1     Terminating             0                43d
ngshare-586b877ff5-kg64v             1/1     Running                 0                16d
ngshare-586b877ff5-wg8sq             0/1     Terminating             0                49d
proxy-85c45c65ff-fcdfv               1/1     Running                 0                16d
</code></pre>
<p>kubectl get events -n staging-jhub --sort-by='.metadata.creationTimestamp'</p>
<pre><code>    LAST SEEN   TYPE      REASON    OBJECT                     MESSAGE
4m44s       Warning   BackOff   pod/hub-5655445674-f2xnd   Back-off restarting failed container git-clone-templates in pod hub-5655445674-f2xnd_staging-jhub(65736f48-bd34-4f87-bff4-ac5406a1c4be)
49m         Normal    Pulling   pod/hub-5655445674-f2xnd   Pulling image &quot;alpine/git&quot;
</code></pre>
<p>kubectl describe pod -n staging-jhub hub-5655445674-f2xnd</p>
<pre><code>Name:         hub-5655445674-f2xnd
Namespace:    staging-jhub
Priority:     0
Node:         supergiant-1/172.27.188.206
Start Time:   Fri, 14 Apr 2023 17:37:34 -0700
Labels:       app=jupyterhub
              component=hub
              hub.jupyter.org/network-access-proxy-api=true
              hub.jupyter.org/network-access-proxy-http=true
              hub.jupyter.org/network-access-singleuser=true
              pod-template-hash=5655445674
              release=staging-jhub
Annotations:  checksum/config-map: 6c268aba85f2e5e2a61817417da69e881bfeef7d531c1da0fe857234fa0d767c
              checksum/secret: a9c0ca03f1c2f8b5b3ba11700efd8de88bcd482625fe55b5194da4c4465e32bd
              cni.projectcalico.org/podIP: 10.95.198.72/32
              cni.projectcalico.org/podIPs: 10.95.198.72/32
              k8s.v1.cni.cncf.io/network-status:
                [{
                    &quot;name&quot;: &quot;&quot;,
                    &quot;ips&quot;: [
                        &quot;10.95.198.72&quot;
                    ],
                    &quot;default&quot;: true,
                    &quot;dns&quot;: {}
                }]
              k8s.v1.cni.cncf.io/networks-status:
                [{
                    &quot;name&quot;: &quot;&quot;,
                    &quot;ips&quot;: [
                        &quot;10.95.198.72&quot;
                    ],
                    &quot;default&quot;: true,
                    &quot;dns&quot;: {}
                }]
Status:       Pending
IP:           10.95.198.72
IPs:
  IP:           10.95.198.72
Controlled By:  ReplicaSet/hub-5655445674
Init Containers:
  git-clone-templates:
    Container ID:  containerd://5072a9bcc2e3489f9c397c22af81673f47fdbe254f274b0e3bd89af70d56d3c0
    Image:         alpine/git
    Image ID:      docker.io/alpine/git@sha256:66b210a97bc07bfd4019826bcd13a488b371a6cbe2630a4b37d23275658bd3f2
    Port:          &lt;none&gt;
    Host Port:     &lt;none&gt;
    Command:
      /bin/sh
      -c
    Args:
      git clone --branch=courseList https://github.com/LibreTexts/jupyterhub-templates.git /tmp/jupyterhub-templates &amp;&amp; cp -r /tmp/jupyterhub-templates/templates/* /templates &amp;&amp; cp -r /tmp/jupyterhub-templates/static/* /static
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    128
      Started:      Mon, 01 May 2023 10:49:55 -0700
      Finished:     Mon, 01 May 2023 10:49:55 -0700
    Ready:          False
    Restart Count:  4673
    Environment:    &lt;none&gt;
    Mounts:
      /static from custom-templates-static (rw)
      /templates from custom-templates (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-z97zw (ro)
Containers:
  hub:
    Container ID:  
    Image:         jupyterhub/k8s-hub:2.0.0
    Image ID:      
    Port:          8081/TCP
    Host Port:     0/TCP
    Args:
      jupyterhub
      --config
      /usr/local/etc/jupyterhub/jupyterhub_config.py
      --upgrade-db
    State:          Waiting
      Reason:       PodInitializing
    Ready:          False
    Restart Count:  0
    Liveness:       http-get http://:http/hub/health delay=300s timeout=3s period=10s #success=1 #failure=30
    Readiness:      http-get http://:http/hub/health delay=0s timeout=1s period=2s #success=1 #failure=1000
    Environment:
      PYTHONUNBUFFERED:        1
      HELM_RELEASE_NAME:       staging-jhub
      POD_NAMESPACE:           staging-jhub (v1:metadata.namespace)
      CONFIGPROXY_AUTH_TOKEN:  &lt;set to the key 'hub.config.ConfigurableHTTPProxy.auth_token' in secret 'hub'&gt;  Optional: false
    Mounts:
      /etc/jupyterhub/templates from custom-templates (rw)
      /srv/jupyterhub from pvc (rw)
      /usr/local/etc/jupyterhub/config/ from config (rw)
      /usr/local/etc/jupyterhub/jupyterhub_config.py from config (rw,path=&quot;jupyterhub_config.py&quot;)
      /usr/local/etc/jupyterhub/secret/ from secret (rw)
      /usr/local/etc/jupyterhub/z2jh.py from config (rw,path=&quot;z2jh.py&quot;)
      /usr/local/share/jupyterhub/static/external from custom-templates-static (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-z97zw (ro)
Conditions:
  Type              Status
  Initialized       False 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  config:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      hub
    Optional:  false
  secret:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  hub
    Optional:    false
  custom-templates:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:     
    SizeLimit:  &lt;unset&gt;
  custom-templates-static:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:     
    SizeLimit:  &lt;unset&gt;
  pvc:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  hub-db-dir
    ReadOnly:   false
  kube-api-access-z97zw:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       &lt;nil&gt;
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              &lt;none&gt;
Tolerations:                 hub.jupyter.org/dedicated=core:NoSchedule
                             hub.jupyter.org_dedicated=core:NoSchedule
                             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
  ----     ------   ----                      ----     -------
  Normal   Pulling  59m (x4705 over 16d)      kubelet  Pulling image &quot;alpine/git&quot;
  Warning  BackOff  4m33s (x109812 over 16d)  kubelet  Back-off restarting failed container git-clone-templates in pod hub-5655445674-f2xnd_staging-jhub(65736f48-bd34-4f87-bff4-ac5406a1c4be)
</code></pre>
<p>I've also tried running kubectl logs staging-jhub --previous but got the output:
Error from server (NotFound): pods &quot;staging-jhub&quot; not found</p>
<p>Does anyone know the fix? Or what else I can try?</p>

ryan
<p>Your init container is crashing because it's trying to perform a clone from a branch that doesn't exist.</p>
<p>The command in the init container is <code>git clone --branch=courseList https://github.com/LibreTexts/jupyterhub-templates.git /tmp/jupyterhub-templates &amp;&amp; cp -r /tmp/jupyterhub-templates/templates/* /templates &amp;&amp; cp -r /tmp/jupyterhub-templates/static/* /static</code>. You can either look up the repo on the web or try to clone locally and you will find that the branch doesn't exist and therefore this errors.</p>
<pre><code>$ git clone --branch=courseList https://github.com/LibreTexts/jupyterhub-templates.git
Cloning into 'jupyterhub-templates'...
fatal: Remote branch courseList not found in upstream origin
</code></pre>
<p>An error in the command of the init container will make it crash, repeatedly crashing will drive you into crashLoopBackoff.</p>
<p>Adjusting to an existing branch should fix this.</p>
