4

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
  • 15,099
  • 32
  • 152
  • 329
  • 1
    Probably, you'll find this helpful: https://espressocoder.com/2019/06/11/getting-started-with-docker-in-visual-studio-2019/ – VAS Mar 18 '20 at 18:12

3 Answers3

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.

Chris
  • 1,644
  • 1
  • 11
  • 15
0

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.

Mark Watney
  • 5,268
  • 2
  • 11
  • 33
  • I am taking about debugging local Kubernetes (enabled in Docker Desktop) using Visual Studio 2019. I believe your link is more appropriate for Cloud type environments. Does that make sense? – w0051977 Mar 12 '20 at 10:20
  • Using telepresence you can standardize all your debugging approaches regardless where your K8S cluster is located. – Mark Watney Mar 12 '20 at 11:01
  • OK thanks. Do you know of a tutorial that explains how to use it with Visual Studio 2019 and Kubernetes enabled in Docker Desktop? – w0051977 Mar 12 '20 at 11:08
  • I couldn't find anything specific to VS but have you checked [this](https://kubernetes.io/docs/tasks/debug-application-cluster/local-debugging/#developing-or-debugging-an-existing-service) and [this](https://cloud.google.com/community/tutorials/developing-services-with-k8s) documents? – Mark Watney Mar 12 '20 at 11:40
-2

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