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

启用CGO  KUBE_CGO_OVERRIDES=kubelet,kubectl,xxx

例子 KUBE_CGO_OVERRIDES=kubelet KUBE_BUILD_PLATFORMS=linux/amd64 make   GOLDFLAGS="" GOGCFLAGS="all=-N -l" WHAT="cmd/kubelet"

实际测试后,发现使用 CGO_ENABLED=1  KUBE_BUILD_PLATFORMS=linux/amd64 make   GOLDFLAGS="" GOGCFLAGS="all=-N -l" WHAT="cmd/kubelet" 可以

 

编译后的命令  "_output/local/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

debugging kubernetes (Delve and Goland)

 

 Don't forget create breakingpoints before debugging

debugging kubernetes (Delve and Goland)

 

相关文章:

  • 2021-12-24
  • 2021-05-31
  • 2021-07-26
  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
  • 2022-02-19
  • 2021-05-19
猜你喜欢
  • 2022-01-18
  • 2021-12-15
  • 2021-04-29
  • 2021-12-30
  • 2021-07-08
  • 2022-03-07
  • 2022-12-23
相关资源
相似解决方案