Debug Python on Kubernetes

1/24/2019

Current Architecture

On the most foundation part is Kubernetes with multiple different container images.

On top of them, we have a python library which dynamically loads our code, which we write and install on those containers after deployment. We write stateful applications on k8, that's why this kind of architecture.

Let's call our code beta and the lib which loads it alpha

The current process testing new changes it the following:

  • provision of a new container with the new installed changed from the artefactory
  • run alpha, which loads beta, which we actively develop

What we can do/ cannot do

  • no ssh
  • all commands of kubectl
  • port forwards
  • im using OSX, with PyCharm

Now the question:

  • How can I start my local IDE and set a breakpoint in beta, which gets loaded after running alpha on the k8 pod -> container
-- nmanh
debugging
kubernetes
networking
python

1 Answer

2/1/2019

For now the possible solution was to do the following: - add a remote debugger to the code, which listens upon start - port forward the traffic - clone the code (install), such that the lib gets run, as soon as you run the main - run the code - it waits until attach - attach to the debugger.

Voila it works.

-- nmanh
Source: StackOverflow