This community article describes the key steps that need to be done to remotely debug your Java Callout source that executes in a Kubernetes container.
The target audience are the Apigee Java Callout authors and users who need to troubleshoot a callout execution in context of a real proxy. Frequently (especially the second category) would know generic concepts behind remote debugging and can benefit from some tutorial on how this is done in a specific environment.
You can follow the following link for more detailed explanation and a complete step-by-step walkthrough using an example of JSON Sanitizer Apigee Java Callout
https://github.com/apigee/ahr/wiki/tadaa-cloud-code-apigee-hybrid-javacallout-debugging
Of course, you can use Eclipse or VIM to do remote java debugging, but they need to be installed and connectivity needs to be taken cared. With CloudShell and Cloud Code it's already there. That also enables an ability to debug your Java Callout code in production deployments, especially when you cannot reproduce the problem on a development system.
In any case, we have to configure two items:
jvm-debug
port that exposes container's remote debugging port;JAVA_TOOL_OPTIONS
environment variable that configures jvm remote debugging options.1. Locate port:
section and add three lines that patch the debug port 50005 for the apigee-runtime container name: apigee-runtime
- containerPort: 50005 name: jvm-debug protocol: TCP
2. Add container environment variable for container name: apigee-runtime
at the containers:env:
location
- name: JAVA_TOOL_OPTIONS value: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=50005,quiet=y
1. Select Cloud Code: Attach (Java) to k8s Pod
2. Edit the launch.json file to finetune a podSelector as follows:
{ "name": "Attach to Kubernetes Pod (Java)", "type": "cloudcode.kubernetes", "request": "attach", "language": "Java", "debugPort": 50005, "podSelector": { "debug": "apigee-runtime" } }
You are now ready to set a breakpoint in your source code; hit a request that would trigger the breakpoint and inspect the context.
Observe:
WOW, this is terrific Yuriy. Cool stuff ! This will be really useful.
Is this helpful in case of onprem ?
on-prem case is documented in this lab at the following link: