
Wrote this Debug Kubernetes Operator-sdk locally in Goland last year before the first major release of the Operator-sdk. Due to changes in the Operator-sdk it’s not valid for version v1.0.0 and greater.
Here are the steps to get debug running with v1.0.0
- In Goland go to Run\Edit Configurations
- Select Go Build\+
- Give the configuration a name
- In Files add the path to main.go
In Environment add WATCH_NAMESPACE=your-operators-namespace
Wrote this some time ago debug-kubernetes-operator-sdk-locally-using-vscode but due to changes in the Operator-sdk it’s not valid for version v1.0.0 and greater.
Here are the Steps to get debug running with v1.0.0
- Go to Run\Add Configuration
- Select Go from environments
- Select Go Launch package

You should get the following launch.json
{
“version”: “0.2.0”,
“configurations”: [
{
“name”: “Launch Package”,
“type”: “go”,
“request”: “launch”,
“mode”: “debug”,
“program”: “${workspaceFolder}”
}
]
}
Add an env for WATCH_NAMESPACE in the configuration so it looks like
{
“version”: “0.2.0”,
“configurations”: [
{
“name”: “Launch Package”,
“type”: “go”,
“request”: “launch”,
“mode”: “debug”,
“program”: “${workspaceFolder}”
"env": {
"WATCH_NAMESPACE": "your-operator-namespace",
}
}
]
}
Debug should now work as expected