当前位置:   article > 正文

k8s部署-3.Flannel网络_k8s flanneld etcdctl_api=2

k8s flanneld etcdctl_api=2

一、下载Flannel

https://github.com/coreos/flannel/releases

二、配置flannel

解压并复制到指定目录

cp flanneld /opt/kubernetes/bin/
cp mk-docker-opts.sh  /opt/kubernetes/bin/
  • 1
  • 2

三、systemd管理Flannel

vi /usr/lib/systemd/system/flanneld.service
  • 1
[Unit]
Description=Flanneld overlay address etcd agent
After=network-online.target network.target
Before=docker.service

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

[Install]
WantedBy=multi-user.target
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

四、配置Flannel网络

cd /opt/kubernetes/ssl/
  • 1
ETCDCTL_API=2 etcdctl --ca-file=ca.pem --cert-file=server.pem --key-file=server-key.pem --endpoints="https://192.168.112.134:2379,https://192.168.112.137:2379,https://192.168.112.138:2379"   set  /coreos.com/network/config  '{ "Network": "172.17.0.0/16", "Backend":  {"Type": "vxlan"}}'
  • 1

查看配置信息

ETCDCTL_API=2 etcdctl --ca-file=ca.pem --cert-file=server.pem --key-file=server-key.pem --endpoints="https://192.168.112.134:2379,https://192.168.112.137:2379,https://192.168.112.138:2379"   get  /coreos.com/network/config  '{ "Network": "172.17.0.0/16", "Backend":  {"Type": "vxlan"}}'
  • 1

注:flannel目前确实不能与etcdV3直接交互,只能用etcdv2。

解决方法:etcdctl 命令前加ETCDCTL_API=2

如:ETCDCTL_API=2 etcdctl -v

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

五、启动Flannel

systemctl daemon-reload 
systemctl restart flanneld.service
systemctl enable flanneld.service
  • 1
  • 2
  • 3

六、修改docker配置

vi /usr/lib/systemd/system/docker.service
  • 1
[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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

重启docker

systemctl restart docker 
  • 1

查看网络

ip a
  • 1

在这里插入图片描述

七、配置其他节点

同上

八、验证

节点之间互相ping对方docker 网关

192.168.112.137

ping 172.17.90.1
  • 1

192.168.112.138

ping 172.17.95.1
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/128333
推荐阅读
相关标签
  

闽ICP备14008679号