Flannel网络部署
一、Flannel网络部署
为Flannel生成证书
[root@linux-node1 ssl]# vim flanneld-csr.json
{
"CN": "flanneld",
"hosts": [],
"key": {
"algo": "rsa",
"size":
},
"names": [
{
"C": "CN",
"ST": "BeiJing",
"L": "BeiJing",
"O": "k8s",
"OU": "System"
}
]
}
生成证书
[root@linux-node1 ssl]# cfssl gencert -ca=/opt/kubernetes/ssl/ca.pem \
-ca-key=/opt/kubernetes/ssl/ca-key.pem \
-config=/opt/kubernetes/ssl/ca-config.json \
-profile=kubernetes flanneld-csr.json | cfssljson -bare flanneld
// :: [INFO] generate received request
// :: [INFO] received CSR
// :: [INFO] generating key: rsa-
// :: [INFO] encoded CSR
// :: [INFO] signed certificate with serial number
// :: [WARNING] This certificate lacks a "hosts" field. This makes it unsuitable for
websites. For more information see the Baseline Requirements for the Issuance and Management
of Publicly-Trusted Certificates, v.1.1., from the CA/Browser Forum (https://cabforum.org);
specifically, section 10.2. ("Information Requirements"). [root@linux-node1 ssl]# ll flanneld*
-rw-r--r-- root root May : flanneld.csr
-rw-r--r-- root root May : flanneld-csr.json
-rw------- root root May : flanneld-key.pem
-rw-r--r-- root root May : flanneld.pem
分发证书
[root@linux-node1 ssl]# scp flanneld*.pem 192.168.56.12:/opt/kubernetes/ssl/
[root@linux-node1 ssl]# scp flanneld*.pem 192.168.56.13:/opt/kubernetes/ssl/
下载Flannel软件包
# wget https://github.com/coreos/flannel/releases/download/v0.10.0/flannel-v0.10.0-linux-amd64.tar.gz [root@linux-node1 ssl]# cd /usr/local/src/
[root@linux-node1 src]# pwd
/usr/local/src
[root@linux-node1 src]# tar zxf flannel-v0.10.0-linux-amd64.tar.gz
[root@linux-node1 src]# cp flanneld mk-docker-opts.sh /opt/kubernetes/bin/
#复制到linux-node2、linux-node3节点上
[root@linux-node1 src]# scp flanneld mk-docker-opts.sh 192.168.56.12:/opt/kubernetes/bin/
[root@linux-node1 src]# scp flanneld mk-docker-opts.sh 192.168.56.13:/opt/kubernetes/bin/ 复制对应脚本到/opt/kubernetes/bin目录下。
[root@linux-node1 src]# cd /usr/local/src/kubernetes/cluster/centos/node/bin/
[root@linux-node1 bin]# ll
total
-rwxr-xr-x root root Apr : mk-docker-opts.sh
-rwxr-xr-x root root Apr : remove-docker0.sh
[root@linux-node1 bin]# cp remove-docker0.sh /opt/kubernetes/bin/
[root@linux-node1 bin]# scp remove-docker0.sh 192.168.56.12:/opt/kubernetes/bin/
[root@linux-node1 bin]# scp remove-docker0.sh 192.168.56.13:/opt/kubernetes/bin/
配置Flannel
[root@linux-node1 bin]# vim /opt/kubernetes/cfg/flannel
FLANNEL_ETCD="-etcd-endpoints=https://192.168.56.11:2379,https://192.168.56.12:2379,https://192.168.56.13:2379"
FLANNEL_ETCD_KEY="-etcd-prefix=/kubernetes/network"
FLANNEL_ETCD_CAFILE="--etcd-cafile=/opt/kubernetes/ssl/ca.pem"
FLANNEL_ETCD_CERTFILE="--etcd-certfile=/opt/kubernetes/ssl/flanneld.pem"
FLANNEL_ETCD_KEYFILE="--etcd-keyfile=/opt/kubernetes/ssl/flanneld-key.pem" 复制配置到其它节点上
[root@linux-node1 bin]# scp /opt/kubernetes/cfg/flannel 192.168.56.12:/opt/kubernetes/cfg/
[root@linux-node1 bin]# scp /opt/kubernetes/cfg/flannel 192.168.56.13:/opt/kubernetes/cfg/
设置Flannel系统服务
[root@linux-node1 bin]# vim /usr/lib/systemd/system/flannel.service
[root@linux-node1 bin]# cat /usr/lib/systemd/system/flannel.service
[Unit]
Description=Flanneld overlay address etcd agent
After=network.target
Before=docker.service [Service]
EnvironmentFile=-/opt/kubernetes/cfg/flannel
ExecStartPre=/opt/kubernetes/bin/remove-docker0.sh
ExecStart=/opt/kubernetes/bin/flanneld ${FLANNEL_ETCD} ${FLANNEL_ETCD_KEY} ${FLANNEL_ETCD_CAFILE} ${FLANNEL_ETCD_CERTFILE} ${FLANNEL_ETCD_KEYFILE}
ExecStartPost=/opt/kubernetes/bin/mk-docker-opts.sh -d /run/flannel/docker Type=notify [Install]
WantedBy=multi-user.target
RequiredBy=docker.service 复制系统服务脚本到其它节点上
[root@linux-node1 bin]# scp /usr/lib/systemd/system/flannel.service 192.168.56.12:/usr/lib/systemd/system/
[root@linux-node1 bin]# scp /usr/lib/systemd/system/flannel.service 192.168.56.13:/usr/lib/systemd/system/
二、Flannel CNI集成
下载CNI插件
#下载CNI插件
https://github.com/containernetworking/plugins/releases
wget https://github.com/containernetworking/plugins/releases/download/v0.7.1/cni-plugins-amd64-v0.7.1.tgz
[root@linux-node1 bin]# mkdir /opt/kubernetes/bin/cni
[root@linux-node2 ssl]# mkdir /opt/kubernetes/bin/cni
[root@linux-node3 ssl]# mkdir /opt/kubernetes/bin/cni
[root@linux-node1 bin]# cd /usr/local/src/
[root@linux-node1 src]# tar zxf cni-plugins-amd64-v0.7.1.tgz -C /opt/kubernetes/bin/cni
[root@linux-node1 src]# scp -r /opt/kubernetes/bin/cni/* 192.168.56.12:/opt/kubernetes/bin/cni/
root@linux-node1 src]# scp -r /opt/kubernetes/bin/cni/* 192.168.56.13:/opt/kubernetes/bin/cni/
创建Etcd的key
root@linux-node1 src]# /opt/kubernetes/bin/etcdctl --ca-file /opt/kubernetes/ssl/ca.pem --cert-file /opt/kubernetes/ssl/flanneld.pem --key-file /opt/kubernetes/ssl/flanneld-key.pem \
--no-sync -C https://192.168.56.11:2379,https://192.168.56.12:2379,https://192.168.56.13:2379 \
mk /kubernetes/network/config '{ "Network": "10.2.0.0/16", "Backend": { "Type": "vxlan", "VNI": 1 }}' >/dev/null >&
启动flannel
######################linux-node1启动#############################
[root@linux-node1 src]# systemctl daemon-reload
[root@linux-node1 src]# systemctl enable flannel
Created symlink from /etc/systemd/system/multi-user.target.wants/flannel.service to /usr/lib/systemd/system/flannel.service.
Created symlink from /etc/systemd/system/docker.service.requires/flannel.service to /usr/lib/systemd/system/flannel.service.
[root@linux-node1 src]# chmod +x /opt/kubernetes/bin/*
[root@linux-node1 src]# systemctl start flannel ######################linux-node2启动#############################
[root@linux-node2 src]# systemctl daemon-reload
[root@linux-node2 src]# systemctl enable flannel
Created symlink from /etc/systemd/system/multi-user.target.wants/flannel.service to /usr/lib/systemd/system/flannel.service.
Created symlink from /etc/systemd/system/docker.service.requires/flannel.service to /usr/lib/systemd/system/flannel.service.
[root@linux-node2 src]# chmod +x /opt/kubernetes/bin/*
[root@linux-node2 src]# systemctl start flannel ######################linux-node3启动#############################
[root@linux-node3 ssl]# systemctl daemon-reload
[root@linux-node3 ssl]# systemctl enable flannel
Created symlink from /etc/systemd/system/multi-user.target.wants/flannel.service to /usr/lib/systemd/system/flannel.service.
Created symlink from /etc/systemd/system/docker.service.requires/flannel.service to /usr/lib/systemd/system/flannel.service.
[root@linux-node3 ssl]# chmod +x /opt/kubernetes/bin/*
[root@linux-node3 ssl]# systemctl start flannel
查看服务状态
[root@linux-node1 src]# systemctl status flannel
[root@linux-node2 src]# systemctl status flannel
[root@linux-node3 ssl]# systemctl status flannel
[root@linux-node1 src]# ifconfig
eth0: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 192.168.56.11 netmask 255.255.255.0 broadcast 192.168.56.255
inet6 fe80::20c:29ff:fea0:10ca prefixlen scopeid 0x20<link>
ether :0c::a0::ca txqueuelen (Ethernet)
RX packets bytes (59.9 MiB)
RX errors dropped overruns frame
TX packets bytes (1.1 GiB)
TX errors dropped overruns carrier collisions flannel.: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 10.2.9.0 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe80:::bbff:fee0:41a6 prefixlen scopeid 0x20<link>
ether ::bb:e0::a6 txqueuelen (Ethernet)
RX packets bytes (0.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (56.5 MiB)
RX errors dropped overruns frame
TX packets bytes (56.5 MiB)
TX errors dropped overruns carrier collisions
linux-node1上查看网卡ifconfig
[root@linux-node2 src]# ifconfig
eth0: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 192.168.56.12 netmask 255.255.255.0 broadcast 192.168.56.255
inet6 fe80::20c:29ff:fef9:ca25 prefixlen scopeid 0x20<link>
ether :0c::f9:ca: txqueuelen (Ethernet)
RX packets bytes (354.7 MiB)
RX errors dropped overruns frame
TX packets bytes (60.8 MiB)
TX errors dropped overruns carrier collisions flannel.: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 10.2.13.0 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe80:::7ff:fe2d:9c2f prefixlen scopeid 0x20<link>
ether :::2d:9c:2f txqueuelen (Ethernet)
RX packets bytes (0.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (70.8 KiB)
RX errors dropped overruns frame
TX packets bytes (70.8 KiB)
TX errors dropped overruns carrier collisions
linux-node2上查看网卡ifconfig
[root@linux-node3 ssl]# ifconfig
eth0: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 192.168.56.13 netmask 255.255.255.0 broadcast 192.168.56.255
inet6 fe80::20c:29ff:feca:800d prefixlen scopeid 0x20<link>
ether :0c::ca::0d txqueuelen (Ethernet)
RX packets bytes (343.1 MiB)
RX errors dropped overruns frame
TX packets bytes (49.3 MiB)
TX errors dropped overruns carrier collisions flannel.: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 10.2.17.0 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe80::c86c:3ff:fe2e:d4ca prefixlen scopeid 0x20<link>
ether ca:6c::2e:d4:ca txqueuelen (Ethernet)
RX packets bytes (0.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (47.4 KiB)
RX errors dropped overruns frame
TX packets bytes (47.4 KiB)
TX errors dropped overruns carrier collisions
linux-node3上查看网卡ifconfig
[root@linux-node3 ssl]# cat /run/flannel/docker
DOCKER_OPT_BIP="--bip=10.2.17.1/24"
DOCKER_OPT_IPMASQ="--ip-masq=true"
DOCKER_OPT_MTU="--mtu=1450"
DOCKER_OPTS=" --bip=10.2.17.1/24 --ip-masq=true --mtu=1450"
三、配置Docker使用Flannel
root@linux-node1 ~]# vim /usr/lib/systemd/system/docker.service
[Unit] #在Unit下面修改After和增加Requires
After=network-online.target firewalld.service flannel.service
Wants=network-online.target
Requires=flannel.service [Service] #增加EnvironmentFile=-/run/flannel/docker
Type=notify
EnvironmentFile=-/run/flannel/docker
ExecStart=/usr/bin/dockerd $DOCKER_OPTS
将配置复制到另外两个节点
[root@linux-node1 src]# scp /usr/lib/systemd/system/docker.service 192.168.56.12:/usr/lib/systemd/system/
[root@linux-node1 src]# scp /usr/lib/systemd/system/docker.service 192.168.56.13:/usr/lib/systemd/system/
重启Docker
#####################linux-node1重启Docker服务########################
[root@linux-node1 src]# systemctl daemon-reload
[root@linux-node1 src]# systemctl restart docker #####################linux-node3重启Docker服务########################
[root@linux-node2 src]# systemctl daemon-reload
[root@linux-node2 src]# systemctl restart docker #####################linux-node3重启Docker服务########################
[root@linux-node3 ssl]# systemctl daemon-reload
[root@linux-node3 ssl]# systemctl restart docker
[root@linux-node1 src]# ifconfig
docker0: flags=<UP,BROADCAST,MULTICAST> mtu
inet 10.2.9.1 netmask 255.255.255.0 broadcast 10.2.9.255
ether :::d5:e0:d1 txqueuelen (Ethernet)
RX packets bytes (0.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions eth0: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 192.168.56.11 netmask 255.255.255.0 broadcast 192.168.56.255
inet6 fe80::20c:29ff:fea0:10ca prefixlen scopeid 0x20<link>
ether :0c::a0::ca txqueuelen (Ethernet)
RX packets bytes (65.5 MiB)
RX errors dropped overruns frame
TX packets bytes (1.1 GiB)
TX errors dropped overruns carrier collisions flannel.: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 10.2.9.0 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe80:::bbff:fee0:41a6 prefixlen scopeid 0x20<link>
ether ::bb:e0::a6 txqueuelen (Ethernet)
RX packets bytes (0.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (62.3 MiB)
RX errors dropped overruns frame
TX packets bytes (62.3 MiB)
TX errors dropped overruns carrier collisions
linux-node1上查看网卡ifconfig
[root@linux-node2 src]# ifconfig
docker0: flags=<UP,BROADCAST,MULTICAST> mtu
inet 10.2.13.1 netmask 255.255.255.0 broadcast 10.2.13.255
ether ::6a:cf::9f txqueuelen (Ethernet)
RX packets bytes (0.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions eth0: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 192.168.56.12 netmask 255.255.255.0 broadcast 192.168.56.255
inet6 fe80::20c:29ff:fef9:ca25 prefixlen scopeid 0x20<link>
ether :0c::f9:ca: txqueuelen (Ethernet)
RX packets bytes (361.5 MiB)
RX errors dropped overruns frame
TX packets bytes (67.7 MiB)
TX errors dropped overruns carrier collisions flannel.: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 10.2.13.0 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe80:::7ff:fe2d:9c2f prefixlen scopeid 0x20<link>
ether :::2d:9c:2f txqueuelen (Ethernet)
RX packets bytes (0.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (86.3 KiB)
RX errors dropped overruns frame
TX packets bytes (86.3 KiB)
TX errors dropped overruns carrier collisions
linux-node2上查看网卡ifconfig
[root@linux-node3 ssl]# ifconfig
docker0: flags=<UP,BROADCAST,MULTICAST> mtu
inet 10.2.17.1 netmask 255.255.255.0 broadcast 10.2.17.255
ether ::e3:::2d txqueuelen (Ethernet)
RX packets bytes (0.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions eth0: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 192.168.56.13 netmask 255.255.255.0 broadcast 192.168.56.255
inet6 fe80::20c:29ff:feca:800d prefixlen scopeid 0x20<link>
ether :0c::ca::0d txqueuelen (Ethernet)
RX packets bytes (348.1 MiB)
RX errors dropped overruns frame
TX packets bytes (54.4 MiB)
TX errors dropped overruns carrier collisions flannel.: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 10.2.17.0 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe80::c86c:3ff:fe2e:d4ca prefixlen scopeid 0x20<link>
ether ca:6c::2e:d4:ca txqueuelen (Ethernet)
RX packets bytes (0.0 B)
RX errors dropped overruns frame
TX packets bytes (0.0 B)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (51.3 KiB)
RX errors dropped overruns frame
TX packets bytes (51.3 KiB)
TX errors dropped overruns carrier collisions
linux-node3上查看网卡ifconfig
Flannel网络部署的更多相关文章
- K8s集群部署(四)------ Flannel网络部署
所有节点都要部署Flannel网络,在所有节点操作. 1.为Flannel生成证书 [root@k8s-master ssl]# pwd /usr/local/src/ssl [root@k8s-ma ...
- docker flannel网络部署和路由走向分析
1.flannel介绍 flannel是coreos开发的容器网络解决方案.flannel为每个host分配一个subnet,容器从此subnet中分配ip.这些ip可以在host间路由,容器间无需n ...
- kubbernetes Flannel网络部署(五)
一.Flannel生成证书 1.创建Flannel生成证书的文件 [root@linux-node1 ~]# vim flanneld-csr.json { "CN": " ...
- Kubernetes学习之路(五)之Flannel网络二进制部署和测试
一.K8S的ip地址 Node IP:节点设备的IP,如物理机,虚拟机等容器宿主的实际IP. Pod IP:Pod的IP地址,是根据docker0网络IP段进行分配的. Cluster IP:Serv ...
- 部署Flannel网络
部署Flannel网络 部署flannel网络需要执行以下步骤: 1)写入分配的子网段到etcd,供flanneld使用 2)下载二进制包 3)配置Flannel 4)systemd管理Flannel ...
- 二进制安装 kubernetes 1.12(二) - 安装docker, 部署Flannel网络
在 node 节点上安装 docker 参考 https://www.cnblogs.com/klvchen/p/8468855.html Flannel 工作原理: 部署Flannel网络 在 ma ...
- 使用kubeadm安装kubernetes/部署前准备/flannel网络插件/镜像下载/
本文内容参考<kuberneters进阶实战>/马哥的新书/推荐 部署前的准备 主机名称解析 分布式系统环境中的多主机通信通常基于主机名称进行,这在IP地址存在变化的可能性时为主机提供了固 ...
- 高可用Kubernetes集群-5. 部署flannel网络
七.部署flannel网络 kubernetes支持基于vxlan方式的flannel与weave网络,基于BGP路由的Calico网络,本节采用flannel网络. Flannel网络采用etcd等 ...
- k8s1.13.0二进制部署-flannel网络(二)
Flannel容器集群网络部署 Overlay Network:覆盖网络,在基础网络上叠加的一种虚拟网络技术模式,该网络中的主机通过虚拟链路连接起来.VXLAN:将源数据包封装到UDP中,并使用基础网 ...
随机推荐
- 总线设备驱动模型---platform篇
总线设备驱动模型----驱动篇 http://blog.chinaunix.net/uid-27664726-id-3334923.html http://blog.chinaunix.net/uid ...
- vc14(vs2015) 编译php7 记录
windows 编译php 官方教程 https://wiki.php.net/internals/windows/stepbystepbuild 参考 http://blog.csdn.net/ ...
- 【跟着stackoverflow学Pandas】 -Get list from pandas DataFrame column headers - Pandas 获取列名
最近做一个系列博客,跟着stackoverflow学Pandas. 以 pandas作为关键词,在stackoverflow中进行搜索,随后安照 votes 数目进行排序: https://stack ...
- Winform创建解决方案
Winform的开发工具可以使用VS2005---VS2013,版本在不断升级,VS的功能也越来越强大.本系列文章采用VS2012(以后全称VS)演示. 窗体是winform开发的基础,需要掌握窗体的 ...
- 《DSP using MATLAB》Problem 2.6
1.代码 %% ------------------------------------------------------------------------ %% Output Info abou ...
- SSH学习之四 OpenSSH安全
OpenSSH是Linux/Unix下一款加密通讯软件.同一时候也是我们用来远程控制Linux/Unixserver重要的必装软件. 对于各版本号的Linux及Unix发行版而言,O ...
- Hadoop NameNode 高可用 (High Availability) 实现解析[转]
NameNode 高可用整体架构概述 在 Hadoop 1.0 时代,Hadoop 的两大核心组件 HDFS NameNode 和 JobTracker 都存在着单点问题,这其中以 NameNode ...
- 唯品会的Service Mesh三年进化史
每种架构风格,都会因各公司面临的情况不同而有不同的实现路线,Service Mesh也不例外,比如江南白衣描述的唯品会的服务化体系开放服务平台OSP(Open Service Platform)走的S ...
- linux系统硬件配置
转自:http://blog.163.com/yang_jianli/blog/static/1619900062010391127338/ 一:查看cpu more /proc/cpuinfo | ...
- mark TODO:完善拦截规则;日志分析;web仪表盘展示;终极目标动态配置规则