Search code examples
eclipsekubernetesmicroservicesopen-libertymicroprofile

How to debug kubernetes deployed service using Eclipse


I have a micro service written using Java EE + Openliberty. I have deployed this into kubernetes in my Docker-Desktop. I want to know, is there any way to debug this deployed service? I am using Eclipse. Please let me know how can I debug deployed service. Thank you!


Solution

  • I heartily endorse looking at telepresence. I don't use it for real yet, but I've verified it will be very useful in our enterprise once we get some pieces in place.

    However, I don't believe you need that complication for your simpler situation. Telepresence will be very nice for injecting NEW code into a cluster without actually deploying it. In your case, you just want to debug the existing code. This allows for a simpler mechanism.

    To remotely debug in Eclipse, you need to connect to a debugger port. To do this with code running in a k8s cluster, you have to expose the port to connect to, and make it available on your desktop.

    In your image, you have to ensure that your Java command line has the "-Xdebug" parameters, which specifies the debugger port (5005 by convention). You also have to ensure that your Dockerfile specifies that port to be exposed. When that is running in your cluster, you have to use "kubectl port-forward" on your desktop (with appropriate parameters). This will proxy the debugger port in the cluster to a corresponding port on your desktop. You then connect to that port from Eclipse.