使用192.168.0.0/16或其他iprange作为kubernetes +法兰绒的Pod cidr [英] Use 192.168.0.0/16 or other iprange as pod cidr for kubernetes + flannel
问题描述
在教程 https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/,它说
要使法兰绒正常工作,必须将
-pod-network-cidr = 10.244.0.0/16
传递给kubeadm init.
.
如何传递其他cidr,例如-pod-network-cidr = 192.168.0.0/16
?
How to pass other cidr, e.g., --pod-network-cidr=192.168.0.0/16
?
推荐答案
按照本教程中的相同步骤进行操作,除了:
Follow the same steps in the tutorial, except:
(1) kubeadm重置
后,请清除主节点和从节点上的早期网络接口.
(1) After kubeadm reset
, clear earlier net interfaces on both master and slave nodes.
sudo ip link del cni0
sudo ip link del flannel.1
sudo systemctl restart network
(2)运行 kubeadm init --pod-network-cidr = 192.168.0.0/16
(3)下载 kube-flannel.yml
文件,将硬编码的 10.244.0.0
更改为 192.168.0.0
,然后执行 kubectl create -f kube-flannel.yml
.
(3) Download the kube-flannel.yml
file, change hard coded 10.244.0.0
to 192.168.0.0
, then do kubectl create -f kube-flannel.yml
.
测试结果
$ k get po -o=wide
NAME READY STATUS RESTARTS AGE IP NODE
h2-75cb7756c6-r4gkj 1/1 Running 0 5m 192.168.1.14 slave1
h2-75cb7756c6-xfstk 1/1 Running 0 16m 192.168.0.5 master
jobserver-58bf6985f9-77mdd 1/1 Running 0 16m 192.168.0.6 master
jobserver-58bf6985f9-h9hlx 1/1 Running 0 5m 192.168.1.15 slave1
# ping pod on slave
$ ping 192.168.1.14
PING 192.168.1.14 (192.168.1.14) 56(84) bytes of data.
64 bytes from 192.168.1.14: icmp_seq=1 ttl=63 time=0.454 ms
# ping pod on master
$ ping 192.168.0.5
PING 192.168.0.5 (192.168.0.5) 56(84) bytes of data.
64 bytes from 192.168.0.5: icmp_seq=1 ttl=64 time=0.143 ms
# ping docker container on the same node
$ ping 172.18.0.2
PING 172.18.0.2 (172.18.0.2): 56 data bytes
64 bytes from 172.18.0.2: seq=0 ttl=241 time=21.580 ms
这篇关于使用192.168.0.0/16或其他iprange作为kubernetes +法兰绒的Pod cidr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!