手动安装K8s第八节:部署Fannel网络

[[email protected] ~]# cd /usr/local/src/ssl/
[[email protected] ssl]# vim flanneld-csr.json

{
"CN": "flanneld",
"hosts": [],
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "CN",
"ST": "BeiJing",
"L": "BeiJing",
"O": "k8s",
"OU": "System"
}
]
}

2.生成证书
[[email protected] 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

3.分发证书
[[email protected] ssl]# cp flanneld.pem /opt/kubernetes/ssl/
[[email protected] ssl]# scp flanneld
.pem k8snode1:/opt/kubernetes/ssl/
[[email protected] ssl]# scp flanneld*.pem k8snode2:/opt/kubernetes/ssl/

4.下载Flannel软件包

wget https://github.com/coreos/flannel/releases/download/v0.10.0/flannel-v0.10.0-linux-amd64.tar.gz

[[email protected] k8s-v1.10.1]# tar zxf flannel-v0.10.0-linux-amd64.tar.gz

[[email protected] k8s-v1.10.1]# cp flanneld mk-docker-opts.sh /opt/kubernetes/bin/
[[email protected] k8s-v1.10.1]# scp flanneld mk-docker-opts.sh k8snode1:/opt/kubernetes/bin/
[[email protected] k8s-v1.10.1]# scp flanneld mk-docker-opts.sh k8snode2:/opt/kubernetes/bin/

复制对应脚本到/opt/kubernetes/bin目录下。
[[email protected] ~]# cd /usr/local/src/k8s-v1.10.1-manual/k8s-v1.10.1/kubernetes/cluster/centos/node/bin/
[[email protected] bin]# ls
mk-docker-opts.sh remove-docker0.sh
[[email protected] bin]# cp remove-docker0.sh /opt/kubernetes/bin/
[[email protected] bin]# scp remove-docker0.sh k8snode1:/opt/kubernetes/bin/
[[email protected] bin]# scp remove-docker0.sh k8snode2:/opt/kubernetes/bin/

5.配置Flannel
[[email protected] ~]# vim /opt/kubernetes/cfg/flannel

FLANNEL_ETCD="-etcd-endpoints=https://192.168.137.171:2379,https://192.168.137.201:2379,https://192.168.137.198: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"
复制配置到其它节点上
[[email protected] ~]# scp /opt/kubernetes/cfg/flannel k8snode1:/opt/kubernetes/cfg/
[[email protected] ~]# scp /opt/kubernetes/cfg/flannel k8snode2:/opt/kubernetes/cfg/
[[email protected] ~]#

6.设置Flannel系统服务
[[email protected] ~]# vim /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

[[email protected] ~]# scp /usr/lib/systemd/system/flannel.service k8snode1:/usr/lib/systemd/system/
[[email protected] ~]# scp /usr/lib/systemd/system/flannel.service k8snode2:/usr/lib/systemd/system/

Flannel 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

mkdir /opt/kubernetes/bin/cni

[[email protected] ~]# cd /usr/local/src/k8s-v1.10.1-manual/k8s-v1.10.1/
[[email protected] k8s-v1.10.1]# tar zxf cni-plugins-amd64-v0.7.1.tgz -C /opt/kubernetes/bin/cni

[[email protected] ~]# scp -r /opt/kubernetes/bin/cni/ k8snode1:/opt/kubernetes/bin/cni/
[[email protected] ~]# scp -r /opt/kubernetes/bin/cni/
k8snode2:/opt/kubernetes/bin/cni/

创建Etcd的key
[[email protected] ssl]# /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.137.171:2379,https://192.168.137.201:2379,https://192.168.137.198:2379 \
mk /kubernetes/network/config ‘{ "Network": "10.2.0.0/16", "Backend": { "Type": "vxlan", "VNI": 1 }}‘ >/dev/null 2>&1

启动flannel(所有节点)
[[email protected] ~]# systemctl daemon-reload
[[email protected] ~]# systemctl enable flannel

[[email protected] ~]# chmod +x /opt/kubernetes/bin/*
[[email protected] ~]# systemctl start flannel
[[email protected] ~]# systemctl status flannel

[[email protected] ~]# ip a
3: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN
link/ether 6a:83:e1:9e:94:a7 brd ff:ff:ff:ff:ff:ff
inet 10.2.79.0/32 scope global flannel.1
valid_lft forever preferred_lft forever
inet6 fe80::6883:e1ff:fe9e:94a7/64 scope link
valid_lft forever preferred_lft forever

配置Docker使用Flannel

[[email protected] ~]# vim /usr/lib/systemd/system/docker.service
#在Unit下面修改After和增加Requires
#增加EnvironmentFile=-/run/flannel/docker
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service flannel.service
Wants=network-online.target
Requires=flannel.service

[Service]
Type=notify
EnvironmentFile=-/run/flannel/docker
ExecStart=/usr/bin/dockerd $DOCKER_OPTS

[[email protected] ~]# scp /usr/lib/systemd/system/docker.service k8snode1:/usr/lib/systemd/system/
[[email protected] ~]# scp /usr/lib/systemd/system/docker.service k8snode2:/usr/lib/systemd/system/

[[email protected] ~]# systemctl daemon-reload
[[email protected] ~]# systemctl restart docker

[[email protected] ~]# ip a
3: flannel.1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN
link/ether 6a:83:e1:9e:94:a7 brd ff:ff:ff:ff:ff:ff
inet 10.2.79.0/32 scope global flannel.1
valid_lft forever preferred_lft forever
inet6 fe80::6883:e1ff:fe9e:94a7/64 scope link
valid_lft forever preferred_lft forever
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
link/ether 02:42:28:be:a7:90 brd ff:ff:ff:ff:ff:ff
inet 10.2.79.1/24 brd 10.2.79.255 scope global docker0
valid_lft forever preferred_lft forever

原文地址:http://blog.51cto.com/andyliu/2129076

时间: 2024-11-09 01:48:14

手动安装K8s第八节:部署Fannel网络的相关文章

手动安装K8s第三节:etcd集群部署

准备安装包https://github.com/coreos/etcd版本:3.2.18wget https://github.com/coreos/etcd/releases/download/v3.2.18/etcd-v3.2.18-linux-amd64.tar.gz 0.安装[[email protected] src]# tar zxf etcd-v3.2.18-linux-amd64.tar.gz[[email protected] src]# cd etcd-v3.2.18-lin

手动安装K8s第六节:node节点部署-kubelet

部署kubelet1.准备二进制包[[email protected] ~]# cd /usr/local/src/kubernetes/server/bin/ [[email protected] bin]# scp kubelet kube-proxy k8snode1:/opt/kubernetes/bin/ [[email protected] bin]# scp kubelet kube-proxy k8snode2:/opt/kubernetes/bin/ 2.创建角色绑定[[ema

手动安装K8s第五节:master节点kubectl命令部署

1.部署kubectl 命令行工具准备二进制包[[email protected] ~]# cd /usr/local/src/kubernetes/client/bin[[email protected] bin]# cp kubectl /opt/kubernetes/bin/ 2.创建 admin 证书签名请求[[email protected] bin]# cd /usr/local/src/ssl/[[email protected] ssl]# vim admin-csr.json

手动安装K8s第四节:Master节点

0.准备软件包 cd /usr/local/src/kubernetes[[email protected] kubernetes]# cp server/bin/kube-apiserver /opt/kubernetes/bin/[[email protected] kubernetes]# cp server/bin/kube-controller-manager /opt/kubernetes/bin/[[email protected] kubernetes]# cp server/b

centos7 k8s集群部署

安装k8s集群前期准备:网络环境:节点 主机名 ipMaster k8s_master 192.168.3.216Node1 k8s_node1 192.168.3.217Node2 k8s_node2 192.168.3.219 centos7版本:[[email protected]_master ~]# cat /etc/redhat-releaseCentOS Linux release 7.4.1708 (Core) 关闭firewalld:systemctl stop firewal

Redis集群部署(手动安装)

1. 安装依赖包 注意:本节需要使用root用户操作 1.1 安装ruby yum install ruby -y yum install ruby-devel.x86_64 -y 1.2 安装rubygem 有些系统默认没有rubygems的包,可能需要手动安装,先安装好ruby-irb和ruby-rdoc,然后操作以下步骤. (1) 下载rubygem包,https://rubygems.org/?locale=zh-CN (2) 上传rubygems-2.4.8.zip至/redis目录

Ubuntu16.04安装K8s步骤和踩坑记录【不错】

文章目录环境信息安装步骤系统配置修改安装docker安装kubectl,kubelet,kubeadm配置Master配置Node部署结果检查K8S部署mysql学习新建mysql-rc.yaml创建mysql-svc.yaml安装K8S部署JAVA应用创建deployment创建service更新deployment其他命令参考K8S Deployment 命令环境信息名称: 版本Docker 18.06.1-ce操作系统 Ubuntu16.04K8s v1.13.2机器信息 IP 作用 组件

github安装k8s

转:https://mritd.me/2016/10/29/set-up-kubernetes-cluster-by-kubeadm/#23镜像版本怎么整 一.环境准备 首先环境还是三台虚拟机,虚拟机地址如下然后每台机器安装好 docker,至于 rpm 安装包版本下面介绍 IP 地址 节点192.168.1.167 master192.168.1.189 node1192.168.1.176 node2 二.说点正经事 2.1.安装包从哪来 官方的文档页面更新并不及时,同时他的 yum 源更新

XenServer部署实录——网络配置

XenServer部署实录系列之06网络配置 作业环境 XenServer服务器 硬件型号:Dell PowerEdge R720 OS:XenServer 6.2 Hostname:xsr01 Eth0 IP:192.168.0.241/24 Gateway:IP:192.168.0.1/24 三层交换机 硬件型号:Quidway S5700 VLAN信息: VLAN10网段为192.168.10.0/24,管理IP为192.168.10.1 VLAN20网段为192.168.20.0/24,