下载路径flannel https://github.com/coreos/flannel/releases
配置两台节点,master不需要配置

scp flanneld mk-docker-opts.sh root@10.186.104.104:/opt/kurnetes/bin/
scp flanneld mk-docker-opts.sh root@10.186.104.90:/opt/kurnetes/bin/
vim flanneld

FLANNEL_OPTIONS="--etcd-endpoints=https://10.186.104.90,https://10.186.104.102,https://10.186.104.104 -etcd-cafile=/opt/kubernetes/ssl/ca.pem -etcd-certfile=/opt/kubernetes/ssl/server.pem -etcd-keyfile=/opt/kubernetes/ssl/server-key.pem"

vim /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
/opt/kubernetes/bin/etcdctl \
--ca-file=ca.pem --cert-file=server.pem --key-file=server-key.pem \--endpoints="https://192.168.0.211:2379,https://192.168.0.212:2379,https://192.168.0.213:2379" \set /coreos.com/network/config '{ "Network": "172.17.0.0/16", "Backend": {"Type": "vxlan"}}'


systemctl start flanneld

vim /usr/lib/systemd/system/docker.service
加上
EnvironmentFile=/run/flannel/subnet.env

systemctl daemon-reload
systemctl start docker

两个节点相互ping一下,看看能不能ping
ip addr 看一下docker 和 flanneld是否在一个网段

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐