<p>I am trying to debug jenkins kubernetes pod which is not initializing. The pod is in initialized state.</p>
<p>Once I run <code>kubectl get pods --all-namespaces | grep jenkins</code></p>
<p>I am getting</p>
<p><code>infrastructure   jenkins-fdfc9cf6c-2tvvm   0/1     Init:0/1    0  4m</code></p>
<p>I am able to extract the logs using</p>
<p><code>kubectl logs jenkins-fdfc9cf6c-2tvvm   -c copy-default-config -n infrastructure</code></p>
<p>Is there any way that I can actually SSH to this pod?</p>
<p>I tried <code>kubectl -n infrastructure exec -it jenkins-fdfc9cf6c-2tvvm /bin/bash</code>, but I am getting error <code>error: unable to upgrade connection: container not found (&quot;jenkins&quot;)</code>.</p>
<p>This is how my container status looks like</p>
<pre><code>  containerStatuses:
  - image: jenkins/jenkins:lts
    imageID: &quot;&quot;
    lastState: {}
    name: jenkins
    ready: false
    restartCount: 0
    state:
      waiting:
        reason: PodInitializing
</code></pre>
<p>Any advice how to do this?</p>

Bob
<p>I don't think you can run the bash of a pod that is not initializing. But you can start the pod with <strong>sleep</strong> command first and then run <code>kubectl exec</code> command to run the bash of that pod.</p>
<pre><code>apiVersion: v1
kind: Pod
...
spec:
  containers:
  - name: ***
    image: ***
    command: [&quot;sleep 3600&quot;]
</code></pre>
<p>By doing this, the pod won't really run the docker's command, and will initialize correctly. Then you can run <code>kubectl exec -it -n infrastructure jenkins-fdfc9cf6c-2tvvm  /bin/bash</code> to access the bash of that pod, then run the original command manually and see what will happen.</p>
