gpt4 book ai didi

docker - 执行 kubeadm 重置后,Kubernetes 无法为 pod 设置网络

转载 作者:IT老高 更新时间:2023-10-28 21:34:51 27 4
gpt4 key购买 nike

我用 kubeadm init 初始化了 Kubernetes,在我使用 kubeadm reset 重置它之后,我发现 --pod-network-cidr 是错误的。更正后,我尝试使用 kubeadm 再次像这样初始化 Kubernetes:

kubeadm init --use-kubernetes-version v1.5.1 --external-etcd endpoints=http://10.111.125.131:2379 --pod-network-cidr=10.244.0.0/16

然后我在节点上遇到了一些错误

12月 28 15:30:55 ydtf-node-137 kubelet[13333]: E1228 15:30:55.838700   13333 cni.go:255] Error adding network: no IP addresses available in network: cbr0
12月 28 15:30:55 ydtf-node-137 kubelet[13333]: E1228 15:30:55.838727 13333 cni.go:209] Error while adding to cni network: no IP addresses available in network: cbr0
12月 28 15:30:55 ydtf-node-137 kubelet[13333]: E1228 15:30:55.838781 13333 docker_manager.go:2201] Failed to setup network for pod "test-701078429-tl3j2_default(6945191b-ccce-11e6-b53d-78acc0f9504e)" using network plugins "cni": no IP addresses available in network: cbr0; Skipping pod
12月 28 15:30:56 ydtf-node-137 kubelet[13333]: E1228 15:30:56.205596 13333 pod_workers.go:184] Error syncing pod 6945191b-ccce-11e6-b53d-78acc0f9504e, skipping: failed to "SetupNetwork" for "test-701078429-tl3j2_default" with SetupNetworkError: "Failed to setup network for pod \"test-701078429-tl3j2_default(6945191b-ccce-11e6-b53d-78acc0f9504e)\" using network plugins \"cni\": no IP addresses available in network: cbr0; Skipping pod"

Dec 29 10:20:02 ydtf-node-137 kubelet: E1229 10:20:02.065142   22259 pod_workers.go:184] Error syncing pod 235cd9c6-cd6c-11e6-a9cd-78acc0f9504e, skipping: failed to "SetupNetwork" for "test-701078429-zmkdf_default" with SetupNetworkError: "Failed to setup network for pod \"test-701078429-zmkdf_default(235cd9c6-cd6c-11e6-a9cd-78acc0f9504e)\" using network plugins \"cni\": \"cni0\" already has an IP address different from 10.244.1.1/24; Skipping pod"

为什么我不能为新的 pod 创建网络?

顺便说一句,我使用 flannel 作为网络提供商,它工作正常。

[root@ydtf-master-131 k8s151]# kubectl get pods --all-namespaces -o wide
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE
default test-701078429-tl3j2 0/1 ContainerCreating 0 2h <none> ydtf-node-137
kube-system dummy-2088944543-hd7b7 1/1 Running 0 2h 10.111.125.131 ydtf-master-131
kube-system kube-apiserver-ydtf-master-131 1/1 Running 7 2h 10.111.125.131 ydtf-master-131
kube-system kube-controller-manager-ydtf-master-131 1/1 Running 0 2h 10.111.125.131 ydtf-master-131
kube-system kube-discovery-1769846148-bjgp8 1/1 Running 0 2h 10.111.125.131 ydtf-master-131
kube-system kube-dns-2924299975-q8x2m 4/4 Running 0 2h 10.244.0.3 ydtf-master-131
kube-system kube-flannel-ds-3fsjh 2/2 Running 0 2h 10.111.125.137 ydtf-node-137
kube-system kube-flannel-ds-89r72 2/2 Running 0 2h 10.111.125.131 ydtf-master-131
kube-system kube-proxy-7w8c4 1/1 Running 0 2h 10.111.125.137 ydtf-node-137
kube-system kube-proxy-jk6z6 1/1 Running 0 2h 10.111.125.131 ydtf-master-131
kube-system kube-scheduler-ydtf-master-131 1/1 Running 0 2h 10.111.125.131 ydtf-master-131

最佳答案

我想通了,如果你通过kubeadm init重新初始化kubernetes时更改--pod-network-cidr,你应该删除一些自动创建的东西,只是在再次执行 kubeadm init 之前,请按照以下步骤操作:

  1. 在主节点和节点上执行 kubeadm reset

  2. 执行etcdctl rm --recursive registry重置etcd中的数据。

  3. rm -rf/var/lib/cni 在主节点和节点上

  4. rm -rf/run/flannel 在主节点和节点上

  5. rm -rf/etc/cni 在主节点和节点上

  6. ifconfig cni0 down 在主节点和节点上

  7. brctl delbr cni0 在主节点和节点上

现在,我的 Kubernetes 工作正常 :)

关于docker - 执行 kubeadm 重置后,Kubernetes 无法为 pod 设置网络,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41359224/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com