flannel安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了flannel安装相关的知识,希望对你有一定的参考价值。

环境
10.130.0.252 etcd flannel
10.130.0.251 flannel

yum install etcd -y
vi /etc/default/etcd
ETCD_DATA_DIR="/var/lib/etcd/default"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_ADVERTISE_CLIENT_URLS=http://0.0.0.0:2379
sed -i ‘s/localhost/0.0.0.0/g‘ /etc/etcd/etcd.conf
systemctl start etcd

tar xf flannel-v0.10.0-linux-amd64.tar.gz
cp flanneld mk-docker-opts.sh /usr/bin/
etcdctl set /coreos.com/network/config ‘{ "Network": "10.1.0.0/16" }‘

cat /usr/lib/systemd/system/flanneld.service
[Unit]
Description=Flanneld overlay address etcd agent
After=network.target
Before=docker.service
[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/flanneld
ExecStart=/usr/bin/flanneld -etcd-endpoints=${FLANNEL_ETCD} $FLANNEL_OPTIONS
[Install]
RequiredBy=docker.service
WantedBy=multi-user.target

cat /etc/sysconfig/flanneld
FLANNEL_ETCD="http://10.130.0.252:2379"
FLANNEL_ETCD_KEY="/coreos.com/network"

cat /etc/init.d/start_flannel.sh
#!/bin/bash
systemctl stop docker
systemctl restart flanneld
mk-docker-opts.sh -i
source /run/flannel/subnet.env
ifconfig docker0 ${FLANNEL_SUBNET}
systemctl start docker

vi /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd --bip=10.1.78.1/24 --mtu=1472
systemctl daemon-reload
docker run -itd --name bbox1 busybox
docker run -itd --name bbox2 busybox
docker exec bbox1 ip r
docker exec bbox2 ip r
docker exec bbox1 ping
docker exec bbox2 ping

以上是关于flannel安装的主要内容,如果未能解决你的问题,请参考以下文章

kubectl安装flannel

Flannel 原理简析及安装

Flannel的安装与配置实现原理说明

手把手-安装-flannel

Kubernetes二进制部署——Flannel网络

Kubernetes二进制部署——Flannel网络