Home > database >  How to debug java application in kubernetes with cloud code plugin
How to debug java application in kubernetes with cloud code plugin

Time:08-26

I'm trying to debug java application in kubernetes with cloud code plugin. There is no troubles with default debug. I just click debug and its work, 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 cloude code add it's own option agentlib and jvm can't handle two options with same name.

How can edit agentlib option for cloude code? (to add suspend=y) or may be disable that option.

Or may be there is other way to debug application while it starting?

CodePudding user response:

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

CodePudding user response:

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.

  • Related