1. Build from source
编译整个项目 make all GOLDFLAGS="" GOGCFLAGS="all=-N -l"
编译单个组件 make GOLDFLAGS="" GOGCFLAGS="all=-N -l" WHAT="cmd/kube-apiserver"
如果需要编译不同平台使用 KUBE_BUILD_PLATFORMS=linux/amd64
编译后的命令 "_output/bin/"
https://github.com/kubernetes/kubernetes/issues/77527
2.Install delve
Follow the delve's toturial to install delve
After install you can debugging use delve or use Goland
3.Debugging by Goland
Example by apiserver
cd $GOPATH/src/k8s.io/kubernetes/cmd/kube-apiserver/
$GOPATH/bin/dlv debug --headless --listen=:2345 --api-version=2 -- k8s.io/kubernetes/cmd/kube-apiserver/apiserver.go --etcd-servers http://localhost:2379
After the command delve will output a "debug" file in current directory and listen on 2345 port
Open Goland create new remote debug
Don't forget create breakingpoints before debugging