ETCD和Flannel安装完成后.
将网络配置信息写入了ETCD中,启动flanneld测试时一直报错如下.
E0108 10:44:42.533021 8815 main.go:382] Couldn't fetch network config: 100: Key not found (/coreos.com) [46]
timed out
配置检查如下:
[root@umsk8s-master ~]# ETCDCTL_API=3 /umsapp/etcd/etcdctl --endpoints https://172.30.251.200:20079,https://172.30.251.201:20179,https://172.30.251.202:20279,https://172.30.251.203:20379,https://172.30.251.204:20479 --cacert /umsapp/certs/etcd-root-ca.pem --cert /umsapp/certs/umsk8s-master.pem --key /umsapp/certs/umsk8s-master-key.pem get /coreos.com/network/config
/coreos.com/network/config
{"Network":"192.170.0.0/16", "SubnetLen": 24, "SubnetMin": "192.170.0.1", "SubnetMax": "192.170.254.253", "Backend": {"Type": "vxlan"}}
[root@umsk8s-master ~]#
[root@umsk8s-master ~]# /usr/bin/flanneld --etcd-endpoints=https://172.30.251.200:20079,https://172.30.251.201:20179,https://172.30.251.202:20279,https://172.30.251.203:20379,https://172.30.251.204:20479 -etcd-cafile=/umsapp/certs/etcd-root-ca.pem -etcd-certfile=/umsapp/certs/umsk8s-master.pem -etcd-keyfile=/umsapp/certs/umsk8s-master-key.pem -etcd-prefix=/coreos.com/network
I0108 10:44:40.505507 8815 main.go:514] Determining IP address of default interface
I0108 10:44:40.505757 8815 main.go:527] Using interface with name ens32 and address 172.30.251.200
I0108 10:44:40.505773 8815 main.go:544] Defaulting external address to interface address (172.30.251.200)
2020-01-08 10:44:40.506391 I | warning: ignoring ServerName for user-provided CA for backwards compatibility is deprecated
I0108 10:44:40.506453 8815 main.go:244] Created subnet manager: Etcd Local Manager with Previous Subnet: None
I0108 10:44:40.506461 8815 main.go:247] Installing signal handlers
E0108 10:44:40.529390 8815 main.go:382] Couldn't fetch network config: 100: Key not found (/coreos.com) [46]
timed out
E0108 10:44:41.531100 8815 main.go:382] Couldn't fetch network config: 100: Key not found (/coreos.com) [46]
timed out
E0108 10:44:42.533021 8815 main.go:382] Couldn't fetch network config: 100: Key not found (/coreos.com) [46]
timed out
E0108 10:44:43.535099 8815 main.go:382] Couldn't fetch network config: 100: Key not found (/coreos.com) [46]
^CI0108 10:44:44.396074 8815 main.go:370] shutdownHandler sent cancel signal...
[root@umsk8s-master ~]#
ETCD和flanneld版本分别如下:
[root@umsk8s-master ~]# /umsapp/etcd/etcd --version
etcd Version: 3.3.8
Git SHA: 33245c6b5
Go Version: go1.9.7
Go OS/Arch: linux/amd64
[root@umsk8s-master ~]# /usr/bin/flanneld -version
v0.11.0
[root@umsk8s-master ~]#
网络上的方案均与本案实际情况不一致。
Google之后发现如下github连接.
https://github.com/coreos/flannel/issues/1191
https://github.com/coreos/flannel/issues/554
https://github.com/coreos/flannel/issues/755
https://bugzilla.redhat.com/show_bug.cgi?id=1498096
flannel目前确实不能与etcdV3直接交互.
作如下调整后,flanneld服务正常启动。
1 开启etcd 支持V2api功能,在etcd启动参数中加入 --enable-v2参数,并重启etcd2
2 向etcd写入flanneld网络配置时,使用如下指令指定V2版本.
ETCDCTL_API=2 /umsapp/etcd/etcdctl --endpoints https://172.30.251.200:20079,https://172.30.251.201:20179,https://172.30.251.202:20279,https://172.30.251.203:20379,https://172.30.251.204:20479 --ca-file /umsapp/certs/etcd-root-ca.pem --cert-file /umsapp/certs/umsk8s-master.pem --key-file /umsapp/certs/umsk8s-master-key.pem mk /coreos.com/network/config
ETCDCTL_API=2 /umsapp/etcd/etcdctl --endpoints https://172.30.251.200:20079,https://172.30.251.201:20179,https://172.30.251.202:20279,https://172.30.251.203:20379,https://172.30.251.204:20479 --ca-file /umsapp/certs/etcd-root-ca.pem --cert-file /umsapp/certs/umsk8s-master.pem --key-file /umsapp/certs/umsk8s-master-key.pem set /coreos.com/network/config '{"Network":"172.18.0.0/16", "Backend": {"Type": "vxlan"}}'
3 重启flanneld网络即可.