通过Etcd修改Flannel子网信息
在首次启动flannel服务的时候可以手动指定subnet.env文件,配置所在节点的flannel子网网段,如果不指定配置文件,flannel将自动分配一个子网网段并生成配置文件 /var/run/flannel/subnet.env,配置信息写入etcd集群。如果节点失效超时,etcd将清除该节点的子网信息。在不移除节点的情况下,修改配置文件并重启flannel服务,flannel会将etcd中的信息写回subnet.env,即subnet.env文件会被重置。因此必须通过修改etcd来修改节点flannel子网信息。
[root@master ~]# etcdctl ls /coreos.com/network/subnets/
/coreos.com/network/subnets/172.7.16.0-24
/coreos.com/network/subnets/172.7.17.0-24
/coreos.com/network/subnets/172.7.28.0-24
[root@master ~]# etcdctl set /coreos.com/network/subnets/172.7.18.0-24 '{"PublicIP":"172.25.25.18","BackendType":"host-gw"}'
{"PublicIP":"172.25.25.18","BackendType":"host-gw"}
[root@master ~]# etcdctl ls /coreos.com/network/subnets/
/coreos.com/network/subnets/172.7.16.0-24
/coreos.com/network/subnets/172.7.17.0-24
/coreos.com/network/subnets/172.7.28.0-24
/coreos.com/network/subnets/172.7.18.0-24
[root@master ~]# etcdctl get /coreos.com/network/subnets/172.7.28.0-24
{"PublicIP":"172.25.25.18","BackendType":"host-gw"}
[root@master ~]# etcdctl get /coreos.com/network/subnets/172.7.18.0-24
{"PublicIP":"172.25.25.18","BackendType":"host-gw"}
[root@master ~]# etcdctl rm /coreos.com/network/subnets/172.7.28.0-24
PrevNode.Value: {"PublicIP":"172.25.25.18","BackendType":"host-gw"}
[root@master ~]# etcdctl ls /coreos.com/network/subnets/
/coreos.com/network/subnets/172.7.16.0-24
/coreos.com/network/subnets/172.7.17.0-24
/coreos.com/network/subnets/172.7.18.0-24
[root@master ~]# etcdctl get /coreos.com/network/subnets/172.7.18.0-24
{"PublicIP":"172.25.25.18","BackendType":"host-gw"}
[root@master ~]# etcdctl get /coreos.com/network/subnets/172.7.17.0-24
{"PublicIP":"172.25.25.17","BackendType":"host-gw"}
[root@master ~]# etcdctl get /coreos.com/network/subnets/172.7.16.0-24
{"PublicIP":"172.25.25.16","BackendType":"host-gw"}
作者:wanghongwei
版权声明:本作品遵循<CC BY-NC-ND 4.0>版权协议,商业转载请联系作者获得授权,非商业转载请附上原文出处链接及本声明。