Kubedlv is a small tool to forward command to golang delve command.
In a Kubernetes container, some commands require numerous arguments and subcommands
to initiate. Starting a Delve instance can be challenging without modifying the
original YAML file. One approach is to have delve attach to the running process.
However, this option is often unavailable due to missing Docker capabilities.
You may use
go install github.com/imwithye/[email protected]to installkubedlv.
- Install or copy
dlvandkubedlvto the running container. - Open the YAML file of the running deployment, and in the command section,
add
kubedlvas the first command.
For example:
# change this
command:
- http-server
# to this
command:
- kubedlv
- http-serverNow you can attach to port 2345 to start debugging.
The kubedlv simply pipes the original execution command to dlv. It translates
http-server --host 0.0.0.0 --port 8080to
dlv --api-version=2 --listen=:2345 --headless=true --continue --accept-multiclient exec http-server -- --host 0.0.0.0 --port 8080