flannel生成的vxlan设备的删除方法

flannel所生成的vxlan设备,删除的时候与docker0的删除方式不同,因为是vxlan设备,所以需要使用ip link del进行删除,本文对操作方法进行简单记录。

停止flanneld服务并确认

使用systemctl停止flanneld服务并确认结果

[root@host131 ~]# systemctl stop flanneld
[root@host131 ~]# 
[root@host131 ~]# systemctl status flanneld
● flanneld.service - Flanneld Service
   Loaded: loaded (/usr/lib/systemd/system/flanneld.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Sun 2019-03-24 12:40:39 CST; 5min ago
     Docs: https://github.com/coreos/flannel
  Process: 14059 ExecStart=/usr/local/bin/flanneld $FLANNELD_OPTS (code=exited, status=0/SUCCESS)
 Main PID: 14059 (code=exited, status=0/SUCCESS)

Mar 24 12:40:25 host131 flanneld[14059]: I0324 12:40:25.423725   14059 main.go:300] Wrote subnet file to /run/flannel/subnet.env
Mar 24 12:40:25 host131 flanneld[14059]: I0324 12:40:25.423747   14059 main.go:304] Running backend.
Mar 24 12:40:25 host131 flanneld[14059]: I0324 12:40:25.437930   14059 vxlan_network.go:60] watching for new subnet leases
Mar 24 12:40:25 host131 flanneld[14059]: I0324 12:40:25.438838   14059 main.go:396] Waiting for 22h59m59.982339138s to renew lease
Mar 24 12:40:39 host131 systemd[1]: Stopping Flanneld Service...
Mar 24 12:40:39 host131 flanneld[14059]: I0324 12:40:39.588573   14059 main.go:337] shutdownHandler sent cancel signal...
Mar 24 12:40:39 host131 flanneld[14059]: I0324 12:40:39.588785   14059 main.go:404] Stopped monitoring lease
Mar 24 12:40:39 host131 flanneld[14059]: I0324 12:40:39.588801   14059 main.go:322] Waiting for all goroutines to exit
Mar 24 12:40:39 host131 flanneld[14059]: I0324 12:40:39.588935   14059 main.go:325] Exiting cleanly...
Mar 24 12:40:39 host131 systemd[1]: Stopped Flanneld Service.
[root@host131 ~]#

使用ifconfig将设备停止

[root@host131 ~]# ip addr s flannel.1
3: flannel.1:  mtu 1450 qdisc noqueue state UNKNOWN group default 
    link/ether 8e:ef:b7:55:ed:43 brd ff:ff:ff:ff:ff:ff
    inet 172.200.240.0/32 scope global flannel.1
       valid_lft forever preferred_lft forever
    inet6 fe80::8cef:b7ff:fe55:ed43/64 scope link 
       valid_lft forever preferred_lft forever
[root@host131 ~]# ifconfig flannel.1 down
[root@host131 ~]# ip addr s flannel.1
3: flannel.1:  mtu 1450 qdisc noqueue state DOWN group default 
    link/ether 8e:ef:b7:55:ed:43 brd ff:ff:ff:ff:ff:ff
    inet 172.200.240.0/32 scope global flannel.1
       valid_lft forever preferred_lft forever
[root@host131 ~]# 

使用ip link del删除vxlan设备

[root@host131 ~]# ip link del flannel.1
[root@host131 ~]# 
[root@host131 ~]# ip addr s flannel.1
Device "flannel.1" does not exist.
[root@host131 ~]# 

注意事项

docker0由于是网桥设备,所以可以使用brctl进行删除,具体命令为:

brctl delbr docker0

如果使用此种方式删除flannel产生的vxlan设备,会得到如下提示:

[root@host131 ~]# brctl delbr flannel.1
can't delete bridge flannel.1: Operation not permitted
[root@host131 ~]# 

所使用package

如果没有相关命令,在centos下使用如下方式进行安装即可。

命令 所在package centos下安装命令
ifconfig net-tools yum install net-tools
brctl bridge-utils yum install bridge-utils

参考文章

https://github.com/coreos/flannel/issues/733

你可能感兴趣的:(Kubernetes,深入浅出kubernetes)