<p>I am currently running a django app under python3 through kubernetes by going through <code>skaffold dev</code>. I have hot reload working with the Python source code. Is it currently possible to do interactive debugging with python on kubernetes?</p>

<p>For example,</p>

<pre><code>def index(request):
    import pdb; pdb.set_trace()
    return render(request, 'index.html', {})
</code></pre>

<p>Usually, outside a container, hitting the endpoint will drop me in the <code>(pdb)</code> shell. </p>

<p>In the current setup, I have set <code>stdin</code> and <code>tty</code> to <code>true</code> in the <code>Deployment</code> file. The code does stop at the breakpoint but it doesn't give me access to the <code>(pdb)</code> shell.</p>

Thierry Lam
<p>There is a <code>kubectl</code> command that allows you to <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#attach" rel="nofollow noreferrer">attach</a> to a running container in a pod:</p>
<pre><code>kubectl attach &lt;pod-name&gt; -c &lt;container-name&gt; [-n namespace] -i -t

-i  (default:false) Pass stdin to the container
-t  (default:false) Stdin is a TTY
</code></pre>
<p>It should allow you to interact with the debugger in the container.
Probably you may need to adjust your pod to use a debugger, so the following article might be helpful:</p>
<ul>
<li><a href="https://medium.com/@vladyslav.krylasov/how-to-use-pdb-inside-a-docker-container-eeb230de4d11" rel="nofollow noreferrer">How to use PDB inside a docker container.</a></li>
</ul>
<p>There is also <a href="https://kubernetes.io/docs/tasks/debug-application-cluster/local-debugging/" rel="nofollow noreferrer"><strong>telepresence</strong></a> tool that helps you to use different approach of application debugging:</p>
<blockquote>
<p>Using <strong>telepresence</strong> allows you to use custom tools, such as a debugger and IDE, for a local service and provides the service full access to ConfigMap, secrets, and the services running on the remote cluster.</p>
<p>Use the <code>--swap-deployment</code> option to swap an existing deployment with the Telepresence proxy. Swapping allows you to run a service locally and connect to the remote Kubernetes cluster. The services in the remote cluster can now access the locally running instance.</p>
</blockquote>
