第一個:
node節點注冊提示:failed to get config map: Unauthorized
代碼如下:
[root@node1 ~]# kubeadm join 10.5.1.10:6443 --token llilpc.9je7qvdn7l4sygoo --discovery-token-ca-cert-hash sha256:a82baf34d02c5338c6c7c8e9234316dffecee709cea7cc76cda47c8e595f1745 W0122 19:36:32.447752 12903 join.go:346] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set. [preflight] Running pre-flight checks [preflight] Reading configuration from the cluster... [preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml' error execution phase preflight: unable to fetch the kubeadm-config ConfigMap: failed to get config map: Unauthorized To see the stack trace of this error execute with --v=5 or higher
錯誤原因,token令牌失效,解決方法:
在master節點執行下面的命令
sudo kubeadm token create
然后再執行下面的命令重新生成注冊令牌
sudo kubeadm token create --print-join-command
然后殺死node節點所有K8S相關的進程再注冊一次即可
至此,問題解決!
第二個:
重新加入master節點提示error execution phase preflight: [preflight] Some fatal errors occurred
[root@node1 ~]# kubeadm join 10.5.1.5:6443 --token 1a8fot.izehoikcbfm6vcj6 --discovery-token-ca-cert-hash sha256:41498e76da4b483ec99963948303e3df1d0a4308bb096d33f77d6f8f42e53e63 W0203 17:56:00.454059 11793 join.go:346] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set. [preflight] Running pre-flight checks error execution phase preflight: [preflight] Some fatal errors occurred: [ERROR FileAvailable--etc-kubernetes-kubelet.conf]: /etc/kubernetes/kubelet.conf already exists [ERROR FileAvailable--etc-kubernetes-pki-ca.crt]: /etc/kubernetes/pki/ca.crt already exists [preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...` To see the stack trace of this error execute with --v=5 or higher
解決辦法:刪除相關殘留文件
rm -f /etc/kubernetes/kubelet.conf #刪除k8s配置文件
rm -f /etc/kubernetes/pki/ca.crt #刪除K8S證書
然后重新加入
驗證一下:
至此,問題解決!
第三個:
端口占用提示:[ERROR Port-10250]: Port 10250 is in use
解決辦法:查看占用進程,然后殺掉,再加入
sudo yum install -y net-tools -q #安裝相關工具(-q:靜默安裝)
然后查看端口
netstat -ntpl | grep 10250
可以看出,是K8S占用了,那就嘗試重啟服務看看能不能解決
此時,端口已經不在使用了,然后重新加入
加入成功,問題解決!
第四個:
應用yaml文件提示:unknown field "NodePort" in io.k8s.api.core.v1.ServicePort; if you choose to ignore these errors, turn validation off with --validate=false
錯誤原因,yaml參數填寫錯誤,在這里我的是NodePort這段寫錯了,正確的nodeport模式指定具體值時應首字母小寫
一開始寫成了“NodePort”,后來改成“nodePort”之后問題解決
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
第五個:
加入master提示:error execution phase kubelet-start: error uploading crisocket: timed out waiting for the condition
解決辦法:
swapoff -a #關閉swap交換
kubeadm reset #重置K8S配置
systemctl daemon-reload&&systemctl restart docker kubelet #重置配置,重啟服務
rm -rf $HOME/.kube/config #刪除配置文件
iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X #更新iptables規則
最后重新加入即可,至此,問題解決!
第六個
加入master提示:[ERROR FileExisting-nsenter]: nsenter not found in system path
node節點信息如下:
master節點信息為:
Centos7
解決方法如下:
rm -f util-linux-2.25.tar.gz*&&wget https://k8s-1252147235.cos.ap-chengdu.myqcloud.com/docker/util-linux-2.25.tar.gz
mkdir -p /cx/&&tar -zxvf util-linux-2.25.tar.gz -C /cx/
sudo apt-get install autopoint autoconf libtool automake make
./configure --without-python --disable-all-programs --enable-nsenter --without-ncurses
make nsenter; cp nsenter /usr/local/bin
可以看到,此時已經沒有之前那個錯誤警告了,不過出現了新的問題-------------------------------------------emmmmmmmmmmmmm
第七個
加入master節點提示:/proc/sys/net/bridge/bridge-nf-call-iptables does not exist
解決辦法如下:
modprobe br_netfilter&&echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables