DEV Community

Cover image for Debug Kubernetes Operator-sdk locally in Goland
Austin Cunningham
Austin Cunningham

Posted on • Edited on

2 1

Debug Kubernetes Operator-sdk locally in Goland

This is a follow on from this article setting up the operator-sdk debug in vscode.

Setup Goland to debug

The setup for Goland is pretty similar to Vscode.

Delve is a debug tool for golang, it can be downloaded here https://github.com/go-delve/delve/tree/master/Documentation/installation or by just using go

go get -u github.com/go-delve/delve/cmd/dlv 

In Goland go to Run\Edit Configurations...

Alt Text

Click on the Plus symbol + and add Go Remote add a Name and click Apply the defaults are fine

Alt Text

You need to run delve with the command line switch --enable-delve on the up local command
e.g. The operator I am working on is called integreatly-operator so the commands to run it are as follows

# You need to set the namespace to watch 
$ export WATCH_NAMESPACE=integreatly-operator
# You can then run the up local with delve enabled
$ operator-sdk up local --namespace=integreatly-operator --enable-delve
# you will see something like
INFO[0000] Running the operator locally.                
INFO[0000] Using namespace integreatly-operator.        
INFO[0000] Delve debugger enabled with args [--listen=:2345 --headless=true --api-version=2 exec build/_output/bin/integreatly-operator-local --] 
API server listening at: [::]:2345

NOTE: command changed with v0.15.0 operator-sdk run --local --namespace=integreatly-operator

Click on Run\Debug 'whatYouCallYourGoRemote'

Goland will start to debug and stop at your breakpoints.

Alt Text

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay