Unable to update cni config: No networks found in /etc/cni/net
錯誤如下:
Unable to update cni config: No networks found in /etc/cni/net Container runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message
解決方法是安裝flannel:
sysctl net.bridge.bridge-nf-call-iptables=1 kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml
1 node(s) had taints that the pod didn't tolerate.
kubectl describe pod
有時候一個pod創建之后一直是pending,沒有日志,也沒有pull鏡像,describe的時候發現里面有一句話: 1 node(s) had taints that the pod didn't tolerate.
直譯意思是節點有了污點無法容忍,執行 kubectl get no -o yaml | grep taint -A 5 之后發現該節點是不可調度的。這是因為kubernetes出於安全考慮默認情況下無法在master節點上部署pod,於是用下面方法解決:
kubectl taint nodes --all node-role.kubernetes.io/master-
- master節點默認不可部署pod
執行如下,node-role.kubernetes.io/master 可以在 kubectl edit node master1中taint配置參數下查到
root@master1:/var/lib/kubelet# kubectl taint node master1 node-role.kubernetes.io/master-
node "master1" untainted
- node節點pod無法啟動/節點刪除網絡重置
- node1之前反復添加過,添加之前需要清除下網絡
root@master1:/var/lib/kubelet# kubectl get po -o wide
NAME READY STATUS RESTARTS AGE IP NODE
nginx-8586cf59-6zw9k 1/1 Running 0 9m 10.244.3.3 node2
nginx-8586cf59-jk5pc 0/1 ContainerCreating 0 9m <none> node1
nginx-8586cf59-vm9h4 0/1 ContainerCreating 0 9m <none> node1
nginx-8586cf59-zjb84 1/1 Running 0 9m 10.244.3.2 node2
root@node1:~# journalctl -u kubelet
failed: rpc error: code = Unknown desc = NetworkPlugin cni failed to set up pod "nginx-8586cf59-rm4sh_default" network: failed to set bridge addr: "cni0" already has an IP address different from 10.244.2.1/24
12252 cni.go:227] Error while adding to cni network: failed to set bridge addr: "cni0" already
- 重置kubernetes服務,重置網絡。刪除網絡配置,link
kubeadm reset
systemctl stop kubelet
systemctl stop docker
rm -rf /var/lib/cni/
rm -rf /var/lib/kubelet/*
rm -rf /etc/cni/
ifconfig cni0 down
ifconfig flannel.1 down
ifconfig docker0 down
ip link delete cni0
ip link delete flannel.1
systemctl start docker
