<p>I am building my <em>docker</em> image and then deploy using <em>kubernetes</em>.</p>
<p>When I execute the command:</p>
<pre><code>kubectl get pods 

NAME                          READY   STATUS    RESTARTS   AGE
lmhfhfhf-def-abc            0/1     Error   0          2m
</code></pre>
<p>I am almost sure that, it's because of my code changes.  How do I debug this pod to find out the logical error in my code.</p>
<p>Please Help.</p>

<p>Welcome to the community @witti_minds</p>
<p>@user2830517 and @andD have generally answered it, however I'd like to add a bit more details and sources.</p>
<p>Your pod is crashed, however since it was scheduled, options used for running pods will work (<a href="https://kubernetes.io/docs/tasks/debug-application-cluster/debug-pod-replication-controller/#my-pod-is-crashing-or-otherwise-unhealthy" rel="nofollow noreferrer">k8s debug unhealthy pods</a>)</p>
<p>First you should get all information about your pod by running a following command, this will give you all information about your pod (<a href="https://kubernetes.io/docs/tasks/debug-application-cluster/debug-application-introspection/" rel="nofollow noreferrer">k8s pod inspection</a>):</p>
<pre><code>kubectl describe pod %pod_name%
</code></pre>
<p>Then you should do is to examine POD's logs using following command:</p>
<pre><code>kubectl logs lmhfhfhf-def-abc %container_name%
</code></pre>
<p>Container name is optional here, if your pod has more than 1 container, you have to use it.
Also you can check logs from previous state of the pod:</p>
<pre><code>kubectl logs --previous %pod_name% %container_name%
</code></pre>
<p>Once you have your container up and running, you can continue troubleshooting your application by running command directly in pod using <code>exec</code> command:</p>
<pre><code>kubectl exec -it %pod_name% -- sh
</code></pre>
<p>There are different types of possible troubleshooting methods, they are all described here <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/debug-running-pod/" rel="nofollow noreferrer">k8s debugging a running pod</a></p>
