Centos7 下Kubernetes配置flannel网络
2018-01-05 15:54
232 查看
操作环境
网络拓扑图本次操作环境参照《 Centos7 下Kubernetes集群安装部署》,在《Centos7
下Kubernetes集群安装部署》环境中k8s-
master没有安装flannel,此次配置需要在k8s-master中安装flannel。
操作步骤
配置k8s-master
1.在k8s-master节点上创建flannel网络[root@k8s-master yaml]# etcdctl mk /atomic.io/network/config '{"Network": "172.17.0.0/16"}'2.配置flannel
[root@k8s-master yaml]# vi /etc/sysconfig/flanneld # Flanneld configuration options # etcd url location. Point this to the server where etcd runs FLANNEL_ETCD_ENDPOINTS="http://10.10.200.224:2379" # etcd config key. This is the configuration key that flannel queries # For address range assignment FLANNEL_ETCD_PREFIX="/atomic.io/network" #FLANNEL_ETCD_PREFIX="/k8s/network" # Any additional options that you want to pass #FLANNEL_OPTIONS="ens192"
[root@k8s-master yaml]# vi /usr/lib/systemd/system/flanneld.service [Unit] Description=Flanneld overlay address etcd agent After=network.target After=network-online.target Wants=network-online.target After=etcd.service Before=docker.service [Service] Type=notify EnvironmentFile=/etc/sysconfig/flanneld EnvironmentFile=-/etc/sysconfig/docker-network #ExecStart=/usr/bin/flanneld-start $FLANNEL_OPTIONS ExecStart=/usr/bin/flanneld -etcd-endpoints=http://10.10.200.224:2379 ExecStartPost=/usr/libexec/flannel/mk-docker-opts.sh -k DOCKER_NETWORK_OPTIONS -d /run/flannel/docker Restart=on-failure [Install] WantedBy=multi-user.target RequiredBy=docker.service
3.启动flannel
[root@k8s-master ~]# systemctl start flanneld.service在启动flannel,通过ifconfig可以查看到flannel0
[root@k8s-master ~]# ifconfig ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.10.200.224 netmask 255.255.255.0 broadcast 10.10.200.255 inet6 fe80::ec55:e4e8:4be:93bb prefixlen 64 scopeid 0x20<link> ether 00:0c:29:18:3f:c3 txqueuelen 1000 (Ethernet) RX packets 147042 bytes 44436790 (42.3 MiB) RX errors 0 dropped 30 overruns 0 frame 0 TX packets 148062 bytes 33065150 (31.5 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 flannel0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1472 inet 172.17.30.0 netmask 255.255.0.0 destination 172.17.30.0 inet6 fe80::3908:159:b907:1624 prefixlen 64 scopeid 0x20<link> unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC) RX packets 1321 bytes 1737235 (1.6 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 630 bytes 58891 (57.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1 (Local Loopback) RX packets 64441 bytes 28164690 (26.8 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 64441 bytes 28164690 (26.8 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
配置k8s-node
1.2个节点flannel的方法相同,配置flannel[root@k8s-node1 ~]# vi /etc/sysconfig/flanneld # Flanneld configuration options # etcd url location. Point this to the server where etcd runs FLANNEL_ETCD_ENDPOINTS="http://10.10.200.224:2379" # etcd config key. This is the configuration key that flannel queries # For address range assignment FLANNEL_ETCD_PREFIX="/atomic.io/network" #FLANNEL_ETCD_PREFIX="/k8s/network" # Any additional options that you want to pass #FLANNEL_OPTIONS="ens192"
[root@k8s-master yaml]# vi /usr/lib/systemd/system/flanneld.service [Unit] Description=Flanneld overlay address etcd agent After=network.target After=network-online.target Wants=network-online.target After=etcd.service Before=docker.service [Service] Type=notify EnvironmentFile=/etc/sysconfig/flanneld EnvironmentFile=-/etc/sysconfig/docker-network #ExecStart=/usr/bin/flanneld-start $FLANNEL_OPTIONS ExecStart=/usr/bin/flanneld -etcd-endpoints=http://10.10.200.224:2379 ExecStartPost=/usr/libexec/flannel/mk-docker-opts.sh -k DOCKER_NETWORK_OPTIONS -d /run/flannel/docker Restart=on-failure [Install] WantedBy=multi-user.target RequiredBy=docker.service
2.启动flannel
[root@k8s-node1 ~]# systemctl start flanneld.service3.启动flannel后,可以通过ifconfig查看到flannel0
[root@k8s-node1 ~]# ifconfig docker0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1472 inet 172.17.23.1 netmask 255.255.255.0 broadcast 0.0.0.0 inet6 fe80::42:a5ff:fef4:9795 prefixlen 64 scopeid 0x20<link> ether 02:42:a5:f4:97:95 txqueuelen 0 (Ethernet) RX packets 1430 bytes 1851730 (1.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1490 bytes 1290056 (1.2 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.10.200.229 netmask 255.255.255.0 broadcast 10.10.200.255 inet6 fe80::5834:2493:e9ef:3b95 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:f6:c6:42 txqueuelen 1000 (Ethernet) RX packets 264090 bytes 41537991 (39.6 MiB) RX errors 0 dropped 19 overruns 0 frame 0 TX packets 251049 bytes 64982214 (61.9 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 flannel0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1472 inet 172.17.23.0 netmask 255.255.0.0 destination 172.17.23.0 inet6 fe80::da8b:b01f:3f46:3352 prefixlen 64 scopeid 0x20<link> unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC) RX packets 616 bytes 58064 (56.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1315 bytes 1736045 (1.6 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1 (Local Loopback) RX packets 438 bytes 23836 (23.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 438 bytes 23836 (23.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 04.设置docker0的ip地址
[root@k8s-node1 ~]# ifconfig docker0 172.17.23.1
5.节点2参照上述配置进行设置即可
通过上述就完成了配置flannel
相关文章推荐
- centos7安装配置Kubernetes
- Kubernetes双向TLS配置-Centos7
- Centos7配置python连接mysql
- centos7 mysql数据库安装和配置
- centos7打开配置https
- CentOS7安装配置MySQL5.6
- Centos7网络配置
- centos7安装mysql5.7脚本并配置开机启动
- 【linux】centos7网络配置
- 脚本实现centos7修改二块网卡名称并配置ip信息
- Centos7 配置固定IP与关闭防火墙--关闭SELinux
- centos7 mysql数据库安装和配置
- Centos7安装mysql5.7,解决没有默认的配置文件
- CentOS7下安装配置docker
- Scala2.10.4在CentOS7中的安装与配置
- Centos7 安装lightdm openbox tint2配置最简单桌面
- CentOS7网络配置和修改网卡名称及常用服务管理命令
- Centos7 nginx安装并负载均衡WCF/Web以及负载策略配置
- CentOS7下使用yum快速安装配置oracle数据库
- Kubernetes平台配置Tensorflow的GPU集群