Centos7/RHEL7安装docker20.10.7+K8S-v1.20.9遇到的坑
1,使用kubeadmin init时,提示报错,经查日志有以下报错,
Nov 15 11:15:44 k8smaster kubelet[99728]: E1115 11:15:44.924812 99728 pod_workers.go:191] Error syncing pod 3727d6783c46108c76e5b899df77ce70 ("kube-apiserver-k8smaster_kube-system(3727d6783c46108c76e5b899df77ce70)"), skipping: failed to "StartContainer" for "kube-apiserver" with CrashLoopBackOff: "back-off 5m0s restarting failed container=kube-apiserver pod=kube-apiserver-k8smaster_kube-system(3727d6783c46108c76e5b899df77ce70)"
Nov 15 11:15:45 k8smaster kubelet[99728]: E1115 11:15:45.583614 99728 kubelet.go:2263] node "k8smaster" not found
Nov 15 11:15:45 k8smaster kubelet[99728]: W1115 11:15:45.642347 99728 pod_container_deletor.go:79] Container "f4d9630c0fc474157914b33e33fdf39641030fb0bd7e0750cce7a3108b9811b6" not found in pod's containers
经检查,docker中的pod已经添加,但是pod没法正常启动。
于是又自行加载了一个容器,经测试,运行容器报错如下:
[root@k8smaster ~]# docker run -d -p 3888:8080 --name myjava-app leifengyang/java-demo:v1.0
41027da9e2e86b42e53b1be8a11076efda48ad1e42e7a3e9352fa2b2542edbc6
docker: Error response from daemon: cannot start a stopped process: unknown.
[root@k8smaster ~]# kubectl get nodes
Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")
解决方法,将之前生成的 .kube的目录直接全部删除掉,再重建。
[root@k8smaster ~]# rm .kube -rf
[root@k8smaster ~]# mkdir -p $HOME/.kube
[root@k8smaster ~]# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
[root@k8smaster ~]# sudo chown $(id -u):$(id -g) $HOME/.kube/config
[root@k8smaster ~]#
[root@k8smaster ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8smaster Ready control-plane,master 136m v1.20.9
[root@k8smaster ~]#
目录 返回
首页