[英]Debug Python on Kubernetes
On the most foundation part is Kubernetes with multiple different container images. 最基础的部分是带有多个不同容器映像的Kubernetes。
On top of them, we have a python library which dynamically loads our code, which we write and install on those containers after deployment. 在它们之上,我们有一个python库,可动态加载我们的代码,我们在部署后将这些代码编写并安装在这些容器上。 We write stateful applications on k8, that's why this kind of architecture. 我们在k8上编写有状态的应用程序,这就是这种架构的原因。
Let's call our code beta
and the lib which loads it alpha
让我们将代码称为beta
和将其加载为alpha
alpha
, which loads beta
, which we actively develop 运行alpha
,加载beta
,我们会积极开发 beta
, which gets loaded after running alpha
on the k8 pod -> container 我如何启动我的本地IDE并在beta
设置一个断点,在k8 pod->容器上运行alpha
之后,该断点将被加载 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. 现在,可能的解决方案是执行以下操作:-在代码中添加一个远程调试器,该调试器在启动时进行侦听-端口转发流量-克隆代码(安装),以便库在运行时立即运行main-运行代码-等待连接-附加到调试器。
Voila it works. 瞧,它有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.