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中,并使用基础网 ...
随机推荐
- js字符串的裁剪
一.JavaScript字符串的处理方法 1.split() 功能:使用一个指定的分隔符把一个字符串分割存储到数组 例子: str=”jpg|bmp|gif|ico|png”; arr=str. ...
- springboot项目中文件的下载(解决中文乱码问题)
最近使用springboot项目,一直以来文件都以英文格式存储,这次使用的是xls文件下载,文件名为中文的,特此记录下中文文件名的下载以及springboot中下载路径报错问题. 正文 在使用spri ...
- ②Jenkins集成—集成构建部署
之前的博文介绍了Jenkins的入门安装,本文主要介绍如何使用jenkins进行git项目的集成构建与部署 1.首先进行全局工具配置 查看下本机的jdk.maven.git安装路径 echo $PAT ...
- oracle之 监听器无法启动的几个原因总结
1)防火墙没关 2)/etc/hosts配置问题,有可能误删了127.0.0.1的默认记录,添加默认记录 [root@rac02 ~]# cat /etc/hosts127.0.0.1 localho ...
- security自动登陆
package*.security; import java.util.ArrayList; import javax.servlet.http.Cookie; import javax.servle ...
- Windows自带NAT端口映射,命令行CMD操作即可
由于有需求进行端口映射,又不想装乱七八糟的软件,Windows本身自带的路由远程访问配置太麻烦,还要两块网卡,坑爹啊. 其实Windows本身命令行支持配置端口映射,条件是已经安装了IPV6,启不启用 ...
- 【monkeyrunner】monkeyrunner 实例
import time import os import re from com.android.monkeyrunner import MonkeyRunner as mr from com.and ...
- 转- 集群NAS技术架构
集群NAS技术架构 标签: 集群存储负载均衡扩展服务器网络 原贴:http://blog.csdn.net/liuaigui/article/details/6422700 作者刘爱贵 1 什么是集群 ...
- MyEclipse下Tomcat无法部署项目 finish按钮无法点击
问题描述:MyEclipse环境下,使用Tomcat进行项目部署时,无法部署项目,finish按钮无法点击. 问题原因:Context-root丢失 解决办法:右击项目->properties- ...
- ffmpeg+nginx+video实现rtsp流转hls流,通过H5查看监控视频
一.FFmpeg下载:http://ffmpeg.zeranoe.com/builds/ 下载并解压FFmpeg文件夹,配置环境变量:在“Path”变量原有变量值内容上加上d:\ffmpeg\bin, ...