Alexander Kazantsev
Alexander Kazantsev

Reputation: 340

How to debug Java application in Kubernetes with Cloud Code plugin

I'm trying to debug a Java application in Kubernetes using a Cloud Code plugin. There is no trouble with the default debug. I just click debug and it works, but... I don't know how to connect to application on the start.

I've tried to add option -agentlib:jdwp=transport=dt_socket,server=n,suspend=**y**,address=,quiet=y but JVM crushed because Cloud Code adds its own option agentlib and JVM can't handle two options with the same name.

How can I edit the agentlib option for Cloud Code? (to add suspend=y) or maybe disable that option.

Or maybe there is another way to debug the application while it starts?

Upvotes: 0

Views: 439

Answers (2)

Brian de Alwis
Brian de Alwis

Reputation: 2964

Adding this as an answer to provide additional context.

Skaffold doesn't currently support this feature. There is an open feature request on Skaffold to add this ability.

Adding support for this has not been a high-priority item for Skaffold as suspending on startup often causes puzzling problem cascades as startup, readiness, and liveness probes time out, leading to pod restarts, and then debug sessions being terminated, and then new sessions established. And container startup problems are often more easily debugged in isolation (e.g., running as a normal Java app and emulating the Kubernetes startup through env vars, sending messages, etc).

All that said, Skaffold should respect existing -agentlib settings passed on the command-line or in JAVA_TOOL_OPTIONS. So as you found, you can pass along your own JDWP setting in your JAVA_TOOL_OPTIONS.

Upvotes: 0

Alexander Kazantsev
Alexander Kazantsev

Reputation: 340

I've tried to add agentlib option to JDK_JAVA_OPTIONS, but scaffold(library inside cloud plugin) try to find agentlib in JAVA_TOOL_OPTIONS

I've put the option in the right place and it works well

Upvotes: 1

Related Questions