2.kubernetes的CNI网络插件Flannel(运维技术交流群:926402931,欢迎大家一起来交流。)
目录
- 1.集群架构
- 1.1.下载软件,解压,做软链接
- 1.2.创建目录
- 1.3.拷贝证书文件
- 1.4.创建配置
- 1.5.创建启动脚本
- 1.6.授权和创建日志目录
- 1.7.创建supervisor配置
- 2.flannel host-gw模型(三选一)
- 2.1.启动服务并检查
- 3.flannel vxlan模型(三选一)
- 4.flannel 直接路由模型(三选一)
1.集群架构
主机名 角色 IP地址
hdss7-21.host.com
flannel
10.4.7.21
hdss7-22.host.com
flannel
10.4.7.22
部署方法以hdss7-21.host.com为例
1.1.下载软件,解压,做软链接
[root@hdss7-21 ~]# cd /opt/src/[root@hdss7-21 src]# wget https://github.com/coreos/flannel/releases/download/v0.11.0/flannel-v0.11.0-linux-amd64.tar.gz
[root@hdss7-21 src]# mkdir /opt/flannel-v0.11.0
[root@hdss7-21 src]# tar xf flannel-v0.11.0-linux-amd64.tar.gz -C /opt/flannel-v0.11.0/
[root@hdss7-21 src]# ln -s /opt/flannel-v0.11.0/ /opt/flannel
1.2.创建目录
[root@hdss7-21 src]# /opt/flannel[root@hdss7-21 flannel]# mkdir /opt/flannel/cert
1.3.拷贝证书文件
[root@hdss7-21 flannel]# cd cert[root@hdss7-21 cert]# scp hdss7-200:/opt/certs/ca.pem .
[root@hdss7-21 cert]# scp hdss7-200:/opt/certs/client.pem .
[root@hdss7-21 cert]# scp hdss7-200:/opt/certs/client-key.pem .
1.4.创建配置
[root@hdss7-21 cert]# cd ..[root@hdss7-21 flannel]# vi subnet.env
FLANNEL_NETWORK=172.7.0.0/16
FLANNEL_SUBNET=172.7.21.1/24
FLANNEL_MTU=1500
FLANNEL_IPMASQ=false
1.5.创建启动脚本
[root@hdss7-21 flannel]# vi flanneld.sh#!/bin/sh
./flanneld
--public-ip=10.4.7.21
--etcd-endpoints=https://10.4.7.12:2379,https://10.4.7.21:2379,https://10.4.7.22:2379
--etcd-keyfile=./cert/client-key.pem
--etcd-certfile=./cert/client.pem
--etcd-cafile=./cert/ca.pem
--iface=eth0
--subnet-file=./subnet.env
--healthz-port=2401
1.6.授权和创建日志目录
[root@hdss7-21 flannel]# chmod +x flanneld.sh [root@hdss7-21 flannel]# mkdir -p /data/logs/flanneld
1.7.创建supervisor配置
[root@hdss7-21 flannel]# vi /etc/supervisord.d/flannel.ini[program:flanneld-7-21]
command=/opt/flannel/flanneld.sh ; the program (relative uses PATH, can take args)
numprocs=1 ; number of processes copies to start (def 1)
directory=/opt/flannel ; directory to cwd to before exec (def no cwd)
autostart=true ; start at supervisord start (default: true)
autorestart=true ; retstart at unexpected quit (default: true)
startsecs=30 ; number of secs prog must stay running (def. 1)
startretries=3 ; max # of serial start failures (default 3)
exitcodes=0,2 ; "expected" exit codes for process (default 0,2)
stopsignal=QUIT ; signal used to kill process (default TERM)
stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
user=root ; setuid to this UNIX account to run the program
redirect_stderr=true ; redirect proc stderr to stdout (default false)
stdout_logfile=/data/logs/flanneld/flanneld.stdout.log ; stderr log path, NONE for none; default AUTO
stdout_logfile_maxbytes=64MB ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups=4 ; # of stdout logfile backups (default 10)
stdout_capture_maxbytes=1MB ; number of bytes in "capturemode" (default 0)
stdout_events_enabled=false ; emit events on stdout writes (default false)
2.flannel host-gw模型(三选一)
[root@hdss7-21 etcd]# ./etcdctl set /coreos.com/network/config "{"Network": "172.7.0.0/16", "Backend": {"Type": "host-gw"}}"{"Network": "172.7.0.0/16", "Backend": {"Type": "host-gw"}}
验证:
[root@hdss7-21 etcd]# ./etcdctl get /coreos.com/network/config
{"Network": "172.7.0.0/16", "Backend": {"Type": "host-gw"}}
2.1.启动服务并检查
[root@hdss7-21 flannel]# supervisorctl update[root@hdss7-21 flannel]# supervisorctl status
3.flannel vxlan模型(三选一)
1.supervisor stop flanneld-7-[21.22]2.删除host-gw模型创建的路由
route del -net 172.7.21.0/24 gw 10.4.7.21 hdss7-22.host.com上
route del -net 172.7.22.0/24 gw 10.4.7.22 hdss7-21.host.com上
3.在etcd修改
./etcdctl get /coreos.com/network/config
./etcdctl rm /coreos.com/network/config
./etcdctl set /coreos.com/network/config "{"Network": "172.7.0.0/16", "Backend": {"Type": "VxLAN"}}"
4.supervisor start flanneld-7-[21.22]
4.flannel 直接路由模型(三选一)
"{"Network": "172.7.0.0/16", "Backend": {"Type": "VxLAN","Directrouting": true}}"
以上是 2.kubernetes的CNI网络插件Flannel(运维技术交流群:926402931,欢迎大家一起来交流。) 的全部内容, 来源链接: utcz.com/z/515162.html