异常信息:
[root@n1 kubernetes]# systemctl status kubelet -l ● kubelet.service - Kubernetes Kubelet Loaded: loaded (/etc/systemd/system/kubelet.service; enabled; vendor preset: disabled) Active: active (running) since 二 2022-08-02 19:31:38 CST; 42s ago Docs: https://github.com/GoogleCloudPlatform/kubernetes Main PID: 80509 (kubelet) Tasks: 9 Memory: 13.0M CGroup: /system.slice/kubelet.service └─80509 /usr/local/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/kubelet-bootstrap.kubeconfig --cert-dir=/etc/kubernetes/pki --kubecig=/etc/kubernetes/kubelet.kubeconfig --config=/etc/kubernetes/kubelet.config.json --network-plugin=cni --pod-infra-container-image=k8s.gcr.io/paused64:3.1 --allow-privileged=true --alsologtostderr=true --logtostderr=false --log-dir=/var/log/kubernetes --v=2 8月 02 19:32:01 n1 kubelet[80509]: I0802 19:32:01.240801 80509 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials 8月 02 19:32:03 n1 kubelet[80509]: I0802 19:32:03.277292 80509 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials 8月 02 19:32:05 n1 kubelet[80509]: I0802 19:32:05.531491 80509 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials 8月 02 19:32:07 n1 kubelet[80509]: I0802 19:32:07.698197 80509 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials 8月 02 19:32:09 n1 kubelet[80509]: I0802 19:32:09.946787 80509 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials 8月 02 19:32:11 n1 kubelet[80509]: I0802 19:32:11.955601 80509 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials 8月 02 19:32:14 n1 kubelet[80509]: I0802 19:32:14.092859 80509 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials 8月 02 19:32:16 n1 kubelet[80509]: I0802 19:32:16.101928 80509 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials 8月 02 19:32:18 n1 kubelet[80509]: I0802 19:32:18.293540 80509 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials 8月 02 19:32:20 n1 kubelet[80509]: I0802 19:32:20.408899 80509 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials [root@n1 kubernetes]# journalctl -xef -u kubelet -- Logs begin at 二 2022-08-02 17:43:29 CST. -- 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.598616 80432 flags.go:33] FLAG: --version="false" 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.598635 80432 flags.go:33] FLAG: --vmodule="" 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.598645 80432 flags.go:33] FLAG: --volume-plugin-dir="/usr/libexec/kubernetes/kubelet-plugins/vol/exec/" 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.598656 80432 flags.go:33] FLAG: --volume-stats-agg-period="1m0s" 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.598737 80432 feature_gate.go:226] feature gates: &{map[]} 8月 02 19:28:22 n1 kubelet[80432]: Flag --allow-privileged has been deprecated, will be removed in a future version 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.602278 80432 feature_gate.go:226] feature gates: &{map[RotateKubeletClientCertificate:true RotatbeletServerCertificate:true]} 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.602390 80432 feature_gate.go:226] feature gates: &{map[RotateKubeletClientCertificate:true RotatbeletServerCertificate:true]} 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.639153 80432 mount_linux.go:171] Detected OS with systemd 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.639224 80432 server.go:417] Version: v1.14.0 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.639304 80432 feature_gate.go:226] feature gates: &{map[RotateKubeletClientCertificate:true RotatbeletServerCertificate:true]} 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.639400 80432 feature_gate.go:226] feature gates: &{map[RotateKubeletClientCertificate:true RotatbeletServerCertificate:true]} 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.639516 80432 plugins.go:103] No cloud provider specified. 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.639547 80432 server.go:533] No cloud provider specified: "" from the config file: "" 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.639593 80432 bootstrap.go:118] Using bootstrap kubeconfig to generate TLS client cert, key and kconfig file 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.645893 80432 bootstrap.go:149] No valid private key and/or certificate found, reusing existing pate key or creating a new one 8月 02 19:28:22 n1 kubelet[80432]: I0802 19:28:22.685746 80432 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials 8月 02 19:28:24 n1 kubelet[80432]: I0802 19:28:24.912832 80432 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials 8月 02 19:28:27 n1 kubelet[80432]: I0802 19:28:27.025950 80432 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials 8月 02 19:28:29 n1 kubelet[80432]: I0802 19:28:29.403173 80432 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials 8月 02 19:28:31 n1 kubelet[80432]: I0802 19:28:31.677202 80432 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials 8月 02 19:28:33 n1 kubelet[80432]: I0802 19:28:33.738455 80432 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials 8月 02 19:28:35 n1 kubelet[80432]: I0802 19:28:35.927611 80432 bootstrap.go:294] Failed to connect to apiserver: the server has asked for the clieto provide credentials
解决:
1.证书过期了导致链接不上。
2.可以看到 token 已经过期重新生成一下就可以了。
[root@m1 .kube]# kubeadm token list TOKEN TTL EXPIRES USAGES DESCRIPTION EXTRA GROUPS bwa8py.ghf5s0vfsxz1d7fx <invalid> 2022-08-01T19:06:15+08:00 authentication,signing kubelet-bootstrap-token system:bootstrappers:worker