In IntelliJ open the Run Configurations such as with the menu "Run > Edit Configurations...". Add a new configuration of type "Remote":
Pick the module to debug from the "Use module classpath" and copy off the command line arguments it provides:
Use kubectl edit or the GCP Console web interface to edit the app-deployment to debug. Locate the JAVA_TOOL_OPTIONS environment variable and add the "-agentlib" arguments copied from the run config. If using the GCP Console, make sure to scroll to the bottom of the page and click "Save".
While you're in there modifying the deployment, it is helpful to scale the replicas down to 1 in order to ensure one, known instance of the application will handle API/events and can be reliably debugged.
Wait for the scaling and new revision of the pod to be created and ready...
Start port forwarding to the remote debug port (5005 by default) of the pod using kubectl port-forward such as
In IntelliJ open the Run Configurations such as with the menu "Run > Edit Configurations...". Add a new configuration of type "Remote":
Pick the module to debug from the "Use module classpath" and copy off the command line arguments it provides:
Use
kubectl edit
or the GCP Console web interface to edit the app-deployment to debug. Locate theJAVA_TOOL_OPTIONS
environment variable and add the "-agentlib" arguments copied from the run config. If using the GCP Console, make sure to scroll to the bottom of the page and click "Save".While you're in there modifying the deployment, it is helpful to scale the replicas down to 1 in order to ensure one, known instance of the application will handle API/events and can be reliably debugged.
Wait for the scaling and new revision of the pod to be created and ready...
Start port forwarding to the remote debug port (5005 by default) of the pod using
kubectl port-forward
such asStart a debug session by selecting the run config created above and clicking the "Debug" button:
You can now set breakpoints and/or pause the remote JVM to debug further.
Press the stop button to detach the remote debugger session:
You can now Control-C to stop the
kubectl port-forward
instance.