How do you debug python code with kubernetes and skaffold?

∥☆過路亽.° 提交于 2019-12-05 11:47:35

There is a kubectl command that allows you to attach to a running container in a pod:

kubectl attach <pod-name> -c <container-name> [-n namespace] -i -t

-i  (default:false) Pass stdin to the container
-t  (default:false) Stdin is a TTY

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:

There is also telepresence tool that helps you to use different approach of application debugging:

Using telepresence 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.

Use the --swap-deployment 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.

It might be worth looking into Rookout which allows in-prod live debugging of Python on Kubernetes pods without restarts or redeploys. You lose path-forcing etc but you gain loads of flexibility for effectively simulating breakpoint-type stack traces on the fly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!