Remote debug metricbeat running on docker/k8s from your laptop#31748
Remote debug metricbeat running on docker/k8s from your laptop#31748gsantoro merged 19 commits intoelastic:mainfrom
Conversation
…nto feature/remote-debugger
|
/test |
tetianakravchenko
left a comment
There was a problem hiding this comment.
@gsantoro thank you for the detailed readme! I was able to run remote debugger locally
just one comment:
from my understanding this is mainly to debug metricbeat on k8s or in docker, should maybe then be added a comment in dockerfile/ or adjusted dockerfile name to point it out?
Co-authored-by: Tetiana Kravchenko <tanya.kravchenko.v@gmail.com>
|
hey @tetianakravchenko, thanks for reviewing my PR, can you please clarify what you mean by?
Let me see if I can make this clearer.
|
|
/test |
my point was, that now we have a readme located in k8s module folder ( |
…nto feature/remote-debugger
* extra Dockerfile.debug with instructions on how to use remote debugging to debug metricbeat running on k8s
What does this PR do?
Allow to remote debug metricbeat running on kubernetes from VisualStudioCode
Why is it important?
Remote debugging with breakpoints is far superior to fmt.printLn
Checklist
Author's Checklist
How to test this PR locally
create a local file at
.vscode/launch.jsonto run the debugger from VisualStudioCode on your laptop{ "version": "0.2.0", "configurations": [ { "name": "Connect to server", "type": "go", "request": "attach", "mode": "remote", "debugAdapter": "dlv-dap", "port": 56268, "host": "127.0.0.1", "showLog": true, "trace": "trace", "cwd": "${workspaceFolder}", "substitutePath": [ { "from": "${workspaceFolder}", # NOTE: REPLACE `<absolute path>` with the absolute path of the root folder "to": "<absolute path>" } ] } ] }Steps to run on docker:
substitutePath.tois still pointing to our root folder.cd metricbeatGOOS=linux GOARCH=amd64 go build -gcflags "-N -l" -o metricbeat main.godocker build -t metricbeat-debugger-image -f Dockerfile.debug ..vscode/launch.json. Remember to add first some breakpointsSteps to run on kubernetes:
Steps from 0 to 2 (included) are the same as
Steps to run on docker0. Move into metricbeat folder. Note: For some reason even if we are building in a subfolder, the
substitutePath.tois still pointing to our root folder.cd metricbeatGOOS=linux GOARCH=amd64 go build -gcflags "-N -l" -o metricbeat main.godocker build -t metricbeat-debugger-image -f Dockerfile.debug .deploy/kubernetes/metricbeat-kubernetes.yamlwith these changesNamely you need:
imagePullPolicyto pull the image from inside Kindportsto expose the port in order to remote debug from laptopwhere
<pod-name>is the name of the pod running on k8s.vscode/launch.json. Remember to add first some breakpoints. For example you can put a breakpoint atmetricbeat/cmd/root.goat line 74 to stop at the very beginning of the metricbeat commandUse cases