赞
踩
https://github.com/coreos/flannel/releases
解压并复制到指定目录
cp flanneld /opt/kubernetes/bin/
cp mk-docker-opts.sh /opt/kubernetes/bin/
vi /usr/lib/systemd/system/flanneld.service
[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
cd /opt/kubernetes/ssl/
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"}}'
查看配置信息
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"}}'
注:flannel目前确实不能与etcdV3直接交互,只能用etcdv2。
解决方法:etcdctl 命令前加ETCDCTL_API=2
如:ETCDCTL_API=2 etcdctl -v
https://github.com/coreos/flannel/issues/1191
systemctl daemon-reload
systemctl restart flanneld.service
systemctl enable flanneld.service
vi /usr/lib/systemd/system/docker.service
[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
重启docker
systemctl restart docker
查看网络
ip a
同上
节点之间互相ping对方docker 网关
192.168.112.137
ping 172.17.90.1
192.168.112.138
ping 172.17.95.1
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。