Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 1.07 KB

File metadata and controls

32 lines (26 loc) · 1.07 KB

Debugging A Golang GraphQL Service Running in a Local K8s Cluster with Delve

asciicast

An asciicast of the general process

I ran into a situation today where I wanted to use delve to debug a graphql service written in golang running in a pod in my local k8s development cluster.

First I replaced the CMD line in the service's Dockerfile so the container will start but not listen to the port that my ingress service expects to find the service at.

# CMD gin -p 80 run main.go
CMD sleep 99999

Next I start all the services in my project with skaffold dev. I use k9s to conveniently monitor my k8s cluster's services, deployments, pods, etc. I can also attach to a running pod with one keypress. The equivalent can be done with kubectl:

$ kubectl exec -it POD_NAME -- bash # assuming bash in path

Next I build with delve, set a breakpoint, and start the service

$ PORT=80 dlv debug main.go