编译调试kube-apiserver
k8s v1.19.0
cd kubernetes && make generated_files
cd cmd/kube-apiserver && go build
报错app/server.go:467:87: undefined: openapi.GetOpenAPIDefinitions
cd kubernetes && make generated_files
# vscode launch.json
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "exec",
"program": "/root/code/go/src/k8s.io/kubernetes/cmd/kube-apiserver/kube-apiserver",
"env": {},
"args": ["--advertise-address=192.168.3.27", "--allow-privileged=true", "--authorization-mode=Node,RBAC", "--client-ca-file=/etc/kubernetes/pki/ca.crt", "--enable-admission-plugins=NodeRestriction",
"--enable-bootstrap-token-auth=true", "--etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt", "--etcd-certfile=/etc/kubernetes/pki/apiserver-etcd-client.crt",
"--etcd-keyfile=/etc/kubernetes/pki/apiserver-etcd-client.key", "--etcd-servers=https://127.0.0.1:2379", "--insecure-port=0",
"--kubelet-client-certificate=/etc/kubernetes/pki/apiserver-kubelet-client.crt", "--kubelet-client-key=/etc/kubernetes/pki/apiserver-kubelet-client.key",
"--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname", "--proxy-client-cert-file=/etc/kubernetes/pki/front-proxy-client.crt",
"--proxy-client-key-file=/etc/kubernetes/pki/front-proxy-client.key", "--requestheader-allowed-names=front-proxy-client", "--requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt",
"--requestheader-extra-headers-prefix=X-Remote-Extra-", "--requestheader-group-headers=X-Remote-Group", "--requestheader-username-headers=X-Remote-User",
"--secure-port=6443", "--service-account-key-file=/etc/kubernetes/pki/sa.pub", "--service-cluster-ip-range=10.96.0.0/12", "--tls-cert-file=/etc/kubernetes/pki/apiserver.crt", "--tls-private-key-file=/etc/kubernetes/pki/apiserver.key"]
}
因为k8s staging目录中存在k8s.io子目录,k8s.io存在点,所以调试时红心会变成灰色空心点,无法命中。