Kubernetes部署(一):架構(gòu)及功能說明
Kubernetes部署(二):系統(tǒng)環(huán)境初始化
Kubernetes部署(三):CA證書制作
Kubernetes部署(四):ETCD集群部署
Kubernetes部署(五):Haproxy、Keppalived部署
Kubernetes部署(六):Master節(jié)點(diǎn)部署
Kubernetes部署(七):Node節(jié)點(diǎn)部署
Kubernetes部署(八):Flannel網(wǎng)絡(luò)部署
Kubernetes部署(九):CoreDNS、Dashboard、Ingress部署
Kubernetes部署(十):儲存之glusterfs和heketi部署
Kubernetes部署(十一):管理之Helm和Rancher部署
Kubernetes部署(十二):helm部署harbor企業(yè)級鏡像倉庫
Flannel 需要在所有的master和node都部署
1.為Flannel生成證書
[root@node-01 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.生成證書
[root@node-01 ssl]# cfssl gencert -ca=/data/kubernetes/ssl/ca.pem \
-ca-key=/data/kubernetes/ssl/ca-key.pem \
-config=/data/kubernetes/ssl/ca-config.json \
-profile=kubernetes flanneld-csr.json | cfssljson -bare flanneld
3.分發(fā)證書
[root@node-01 ssl]# for n in `seq 201 206`; do scp flanneld*.pem 10.31.90.$n:/data/kubernetes/ssl/;done
4.下載Flannel軟件包
[root@node-01 k8s]#wget https://github.com/coreos/flannel/releases/download/v0.10.0/flannel-v0.10.0-linux-amd64.tar.gz
[root@node-01 k8s]# tar zxf flannel-v0.10.0-linux-amd64.tar.gz
[root@node-01 k8s]# for n in `seq 201 206`;do scp flanneld mk-docker-opts.sh 10.31.90.$n:/data/kubernetes/bin/;done
復(fù)制對應(yīng)腳本到/data/kubernetes/bin目錄下。
[root@node-01 k8s]# for n in `seq 201 206`;do scp remove-docker0.sh 10.31.90.$n:/data/kubernetes/bin/;done
5.配置Flannel
[root@node-04 ssl]# vim /data/kubernetes/cfg/flannel
FLANNEL_ETCD="-etcd-endpoints=https://10.31.90.201:2379,https://10.31.90.202:2379,https://10.31.90.203:2379"
FLANNEL_ETCD_KEY="-etcd-prefix=/kubernetes/network"
FLANNEL_ETCD_CAFILE="--etcd-cafile=/data/kubernetes/ssl/ca.pem"
FLANNEL_ETCD_CERTFILE="--etcd-certfile=/data/kubernetes/ssl/flanneld.pem"
FLANNEL_ETCD_KEYFILE="--etcd-keyfile=/data/kubernetes/ssl/flanneld-key.pem"
復(fù)制配置到其它節(jié)點(diǎn)上
[root@node-01 ~]# for n in `seq 201 206`;do scp /data/kubernetes/cfg/flannel 10.31.90.$n:/data/kubernetes/cfg/;done
6.設(shè)置Flannel系統(tǒng)服務(wù)
[root@node-01 ~]# vim /usr/lib/systemd/system/flannel.service
[Unit]
Description=Flanneld overlay address etcd agent
After=network.target
Before=docker.service
[Service]
EnvironmentFile=-/data/kubernetes/cfg/flannel
ExecStartPre=/data/kubernetes/bin/remove-docker0.sh
ExecStart=/data/kubernetes/bin/flanneld ${FLANNEL_ETCD} ${FLANNEL_ETCD_KEY} ${FLANNEL_ETCD_CAFILE} ${FLANNEL_ETCD_CERTFILE} ${FLANNEL_ETCD_KEYFILE}
ExecStartPost=/data/kubernetes/bin/mk-docker-opts.sh -d /run/flannel/docker
Type=notify
[Install]
WantedBy=multi-user.target
RequiredBy=docker.service
復(fù)制系統(tǒng)服務(wù)腳本到其它節(jié)點(diǎn)上
[root@node-01 k8s]# for n in `seq 201 206`;do scp /usr/lib/systemd/system/flannel.service 10.31.90.$n:/usr/lib/systemd/system/flannel.service;done
下載CNI插件
[root@node-01 ~]# wget https://github.com/containernetworking/plugins/releases/download/v0.7.1/cni-plugins-amd64-v0.7.1.tgz
[root@node-01 ~]# mkdir /data/kubernetes/bin/cni
[root@node-01 src]# tar zxf cni-plugins-amd64-v0.7.1.tgz -C /data/kubernetes/bin/cni
[root@node-01 k8s]# for n in `seq 201 206`;do scp /data/kubernetes/bin/cni/* 10.31.90.$n:/data/kubernetes/bin/cni/;done
創(chuàng)建Etcd的key
[root@node-01 ~]# /data/kubernetes/bin/etcdctl --ca-file /data/kubernetes/ssl/ca.pem --cert-file /data/kubernetes/ssl/flanneld.pem --key-file /data/kubernetes/ssl/flanneld-key.pem \
--no-sync -C https://10.31.90.201:2379,https://10.31.90.202:2379,https://10.31.90.203:2379 \
mk /kubernetes/network/config '{ "Network": "10.2.0.0/16", "Backend": { "Type": "vxlan", "VNI": 1 }}' >/dev/null 2>&1
啟動flannel
[root@node-01 ~]# systemctl daemon-reload
[root@node-01 ~]# systemctl enable flannel
[root@node-01 ~]# chmod +x /data/kubernetes/bin/*
[root@node-01 ~]# systemctl start flannel
查看服務(wù)狀態(tài)
[root@node-01 ~]# systemctl status flannel
[root@node-01 ~]# 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
將配置復(fù)制到其它所有的node
[root@node-01 k8s]# for n in `seq 201 206`;do scp /usr/lib/systemd/system/docker.service 10.31.90.$n:/usr/lib/systemd/system/docker.service;done
重啟Docker
[root@node-01 ~]# systemctl daemon-reload
[root@node-01 ~]# systemctl restart docker
再查看各個(gè)節(jié)點(diǎn)會發(fā)現(xiàn)docker0網(wǎng)卡和flannel網(wǎng)卡的ip地址都是我們上面配置的網(wǎng)段了。
[root@node-01 k8s]# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 10.2.84.1 netmask 255.255.255.0 broadcast 10.2.84.255
ether 02:42:5e:c6:0c:aa txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
flannel.1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1450
inet 10.2.84.0 netmask 255.255.255.255 broadcast 0.0.0.0
inet6 fe80::8ccc:15ff:fedd:c00d prefixlen 64 scopeid 0x20<link>
ether 8e:cc:15:dd:c0:0d txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 8 overruns 0 carrier 0 collisions 0
至此k8s的集群就已經(jīng)全部部署完成,后續(xù)會繼續(xù)補(bǔ)充管理、監(jiān)控、存儲等方面的文檔。
后續(xù)會陸續(xù)更新所有的安裝文檔,如果你覺得我寫的不錯(cuò),希望大家多多關(guān)注點(diǎn)贊,非常感謝!
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
當(dāng)前標(biāo)題:Kubernetes部署(八):Flannel網(wǎng)絡(luò)部署-創(chuàng)新互聯(lián)
分享網(wǎng)址:http://jinyejixie.com/article30/pedso.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動網(wǎng)站建設(shè)、云服務(wù)器、網(wǎng)站建設(shè)、微信公眾號、網(wǎng)站內(nèi)鏈、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容