What is the best way to debug an app deployed to Kubernetes locally using Docker Desktop?

こ雲淡風輕ζ 提交于 2020-04-14 07:48:08

问题


I have experience using Docker to develop a relatively complex application. It is very easy to debug an app using Visual Studio (2019). I just set docker-compose.yaml as the startup app and start debugging.

Is it possible to debug an application that is published to Kubernetes locally using Docker Desktop? By debug I mean set breakpoints etc? I have spent a few hours Googling this and I have got nowhere and hence the reason for the question.

Please note that I am not asking how to debug an app that is published to Kubernetes in the Cloud e.g. Azure - there are plenty of webpages that explain how to do that.


回答1:


Assuming the image uses a Java CMD, include the standard debug JVM arguments (What are Java command line options to set to allow JVM to be remotely debugged?), then expose the debug port when running a container, and in IDE set up a remote debug session on that port once the container starts up.




回答2:


Telepresence may be a very good fit for you.

Using telepresence you can debug your Kubernetes service locally, using your favorite debugging tool. So it doesn't matter where your K8S cluster is.

Take a look on this tutorial to check how it works.

HOW IT WORKS:

Telepresence substitutes a two-way network proxy for your normal pod running in the Kubernetes cluster. This pod proxies data from your Kubernetes environment (e.g., TCP connections, environment variables, volumes) to the local process. The local process has its networking transparently overridden so that DNS calls and TCP connections are routed through the proxy to the remote Kubernetes cluster.




回答3:


you can stdout docker logs , use kubectl logs pod_name -n namespace_name



来源:https://stackoverflow.com/questions/60644037/what-is-the-best-way-to-debug-an-app-deployed-to-kubernetes-locally-using-docker

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