K8S部署遇到的問題處理彙總

第一個:

node節點註冊提示:failed to get config map: Unauthorized

代碼以下:node

[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令牌失效,解決方法:python

在master節點執行下面的命令linux

sudo kubeadm token create

而後再執行下面的命令從新生成註冊令牌docker

sudo kubeadm token create --print-join-command

而後殺死node節點全部K8S相關的進程再註冊一次便可api

 

 至此,問題解決!bash

第二個:

從新加入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

解決辦法:刪除相關殘留文件socket

rm -f /etc/kubernetes/kubelet.conf    #刪除k8s配置文件

  

rm -f /etc/kubernetes/pki/ca.crt    #刪除K8S證書

  而後從新加入工具

 

 驗證一下:fetch

 

 至此,問題解決!this

第三個:

端口占用提示:[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

 

相關文章
相關標籤/搜索