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

3/11/2020

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.

-- w0051977
c#
docker-compose
kubernetes

3 Answers

3/12/2020

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.

-- mWatney
Source: StackOverflow

3/11/2020

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.

-- Chris
Source: StackOverflow

3/11/2020

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

-- ANISH KUMAR MOURYA
Source: StackOverflow