问题描述
我用kubeadm init
初始化了Kubernetes,在使用kubeadm reset
重置它之后,我发现--pod-network-cidr
是错误的.更正它后,我尝试使用kubeadm
再次像这样初始化Kubernetes:
I initialized Kubernetes with kubeadm init
, and after I used kubeadm reset
to reset it I found --pod-network-cidr
was wrong. After correcting it I tried to use kubeadm
to init Kubernetes again like this:
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
然后我在节点上出现了一些错误
Then I got some errors on the nodes
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创建网络?
Why can't I create a network for the new pods?
顺便说一句,我使用法兰绒作为网络提供商,并且运行良好.
By the way, I use flannel as network provider and it works fine.
[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 ,我就知道了. /strong>,您应该删除一些自动创建的内容,只需按照以下步骤操作,然后再次执行 kubeadm init :
I figured it out, if you change --pod-network-cidr when you reinitialize kubernetes via kubeadm init, you should delete some auto-created things, just follow the steps below before you execute kubeadm init again:
- 在主服务器和节点上
-
执行 kubeadm重置.
execute kubeadm reset on master and nodes.
执行 etcdctl rm-递归注册表重置etcd中的数据.
execute etcdctl rm --recursive registry reset data in etcd.
现在,我的kubernets可以正常工作了:)
Now, my kubernets works fine :)
这篇关于在执行kubeadm重置后,Kubernetes无法为Pod设置网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!