码迷,mamicode.com
首页 > Web开发 > 详细

kubernetes-flannel-05

时间:2020-12-05 10:43:42      阅读:9      评论:0      收藏:0      [点我收藏+]

标签:failure   use   node   ast   cert   ack   pts   isa   known   

部署Flannel

1 下载Flannel二进制包

#所有的节点,下载到master-1
[root@ node -1 ~]# mkdir /soft ; cd /soft
[root@ node -1 ~]# wget https://github.com/coreos/flannel/releases/download/v0.11.0/flannel-v0.11.0-linux-amd64.tar.gz
[root@ node -1 ~]# tar xvf flannel-v0.10.0-linux-amd64.tar.gz
[root@ node -1 ~]# mv flanneld mk-docker-opts.sh /usr/local/bin/

#复制flanneld到其他的所有节点
[root@ node -1 ~]# for i in master-2 master-3 node-1 node-2;do scp /usr/local/bin/flanneld $i:/usr/local/bin/;done
[root@ node -1 ~]# for i in master-2 master-3 node-1 node-2;do scp /usr/local/bin/mk-docker-opts.sh $i:/usr/local/bin/;done

2 配置Flannel (所有节点)

[root@node-1 ~]# mkdir -p /etc/flannel
[root@ node -1 ~]# cat > /etc/flannel/flannel.cfg<<EOF
FLANNEL_OPTIONS="-etcd-endpoints=https://192.168.91.18:2379,https://192.168.91.19:2379,https://192.168.91.20:2379 -etcd-cafile=/etc/etcd/ssl/ca.pem -etcd-certfile=/etc/etcd/ssl/server.pem  -etcd-keyfile=/etc/etcd/ssl/server-key.pem"
EOF
#多个ETCD: -etcd-endpoints=https://192.168.91.200:2379,https://192.168.91.201:2379,https://192.168.91.202:2379

3 配置Flannel配置文件

[root@node-1 ~]# cat > /usr/lib/systemd/system/flanneld.service <<EOF
[Unit]
Description=Flanneld overlay address etcd agent
After=network-online.target network.target
Before=docker.service

[Service]
Type=notify
EnvironmentFile=/etc/flannel/flannel.cfg
ExecStart=/usr/local/bin/flanneld --ip-masq \$FLANNEL_OPTIONS
ExecStartPost=/usr/local/bin/mk-docker-opts.sh -k DOCKER_NETWORK_OPTIONS -d /run/flannel/subnet.env
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

4 启动Flannel

[root@node-1 ~]# service flanneld start
[root@node-1 ~]# chkconfig flanneld on
[root@node-2 ~]# service flanneld status
Redirecting to /bin/systemctl status flanneld.service
● flanneld.service - Flanneld overlay address etcd agent
   Loaded: loaded (/usr/lib/systemd/system/flanneld.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2020-04-05 14:35:51 CST; 7min ago
  Process: 11420 ExecStartPost=/usr/local/bin/mk-docker-opts.sh -k DOCKER_NETWORK_OPTIONS -d /run/flannel/subnet.env (code=exited, status=0/SUCCESS)
 Main PID: 11406 (flanneld)
    Tasks: 8
   Memory: 6.6M
   CGroup: /system.slice/flanneld.service
           └─11406 /usr/local/bin/flanneld --ip-masq -etcd-endpoints=https://192.168.91.18:2379,https://192.168.91.19:2379,https://192.168.91.20:2379 -etcd-cafile=/etc/etcd/ssl/ca.pem...


#所有的节点都需要有172.17.0.0/16 网段IP
[root@master-1 soft]# ip a | grep flannel
3: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN group default 
    inet 172.17.41.0/32 scope global flannel.1

#node节点停止flanneld
[root@node-1 ~]# service flanneld stop

5 修改Docker启动文件(node节点)

[root@node-1 ~]# cat >/usr/lib/systemd/system/docker.service<<EOFL
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
EnvironmentFile=/run/flannel/subnet.env
ExecStart=/usr/bin/dockerd  \$DOCKER_NETWORK_OPTIONS
ExecReload=/bin/kill -s HUP \$MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target
EOFL

6 重启Docker服务

[root@node-1 ~]# systemctl daemon-reload
[root@node-1 ~]# service flanneld restart
[root@node-1 ~]# service docker restart

#检查IP地址, docker 与flanneld 是同一个网段
[root@node-1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:7b:24:0a brd ff:ff:ff:ff:ff:ff
    inet 192.168.91.21/24 brd 192.168.91.255 scope global noprefixroute ens32
       valid_lft forever preferred_lft forever
    inet6 fe80::f8e9:2eba:8648:f6ad/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:1b:93:48:98 brd ff:ff:ff:ff:ff:ff
    inet 172.17.68.1/24 brd 172.17.68.255 scope global docker0
       valid_lft forever preferred_lft forever
4: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN group default 
    link/ether 8a:11:c3:08:83:48 brd ff:ff:ff:ff:ff:ff
    inet 172.17.68.0/32 scope global flannel.1
       valid_lft forever preferred_lft forever
    inet6 fe80::8811:c3ff:fe08:8348/64 scope link 
       valid_lft forever preferred_lft forever

7 Node 节点验证是否可以访问其他节点Docker0

#在每个Node节点Ping其他的节点, 网段都是通的。
[root@master-1 soft]# ping  172.17.68.1
PING 172.17.68.1 (172.17.68.1) 56(84) bytes of data.
64 bytes from 172.17.68.1: icmp_seq=1 ttl=64 time=0.345 ms
64 bytes from 172.17.68.1: icmp_seq=2 ttl=64 time=0.325 ms
64 bytes from 172.17.68.1: icmp_seq=3 ttl=64 time=0.518 ms

kubernetes-flannel-05

标签:failure   use   node   ast   cert   ack   pts   isa   known   

原文地址:https://www.cnblogs.com/liangchen4/p/14065621.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!