How to debug java apps on Openshift/Kubernetes

Envirorment variable/Config Maps

Add these evironmment variables to config maps in deployment template.



If the JAVA_DEBUG variable is set to true and no value is provided for the JAVA_DEBUG_PORT variable, JAVA_DEBUG_PORT is set to 5005 by default.

Connect Local Debugging Port to a Port on the Pod

Get the name of the pod running the application.

oc get pods

Use the OpenShift / Kubernetes port forwarding feature to listen on a local port and forward to a port on the OpenShift pod.

oc port-forward <name-of-pod> 5005:9009

Intellij Remote debugging

Open the same code base.

Run > Edit Configuration > Add New Configuration > select “Remote” from the list.

give any sutiable name to the config

HOST: localhostPort: 5005

Run the config.

You can now set break pointings on the code and debug application.

#redhatter #opensource #developer #kubernetes #keycloak #golang #openshift #quarkus #spring