Get the App
SLTechnology News&Howtos  ›  Servers  › 

K8S single master deployment II: Flannel network deployment

Shulou Source: shulou.com Published: 2022-06-03 06:14:38 09月21日 Update

All of the following operations are done on the node node

Overview of Flannel Network

Flannel provides a virtual network for the container by assigning a subnet to each host. It is based on Linux TUN/TAP, uses UDP/VXLAN to encapsulate IP packets to create an overlay network, and maintains network allocation with the help of etcd (which also supports kubernetes).

Server role assignment role address installation components master192.168.142.220kube-apiserver kube-controller-manager kube-scheduler etcdnode1192.168.142.136kubelet kube-proxy docker flannel etcdnode2192.168.142.132kubelet kube-proxy docker flannel etcdFlannel network deployment (all node nodes) install docker container

The installation of the docker engine is relatively simple and will not be explained here, just stick to the script brush.

The script is as follows:

#! / bin/bash#Docker engine deployment # install dependency package yum install yum-utils device-mapper-persistent-data lvm2-y # set Ali cloud image source yum-config-manager-- add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo# install Docker-ceyum install-y docker-ce# turn off firewall and enhanced security features systemctl stop firewalld.servicesetenforce start Docker and set it to boot Systemctl start docker.servicesystemctl enable docker.service# image acceleration service (everyone's Ali acceleration address is different Please go to Ali's official website to obtain) tee / etc/docker/daemon.json / etc/sysctl.confsysctl-pservice network restart systemctl restart docker# to check whether the container starts and completes docker imagesif [$?-eq 0] Then echo "Docker startup completes" else echo "ERROR" systemctl status docker exit 1fi assigns subnet segments to the flannel network And inject [root@node2 bin] # / opt/etcd/bin/etcdctl-- ca-file=/opt/etcd/ssl/ca.pem\-- cert-file=/opt/etcd/ssl/server.pem\-- key-file=/opt/etcd/ssl/server-key.pem\-- endpoints= "https://192.168.142.220:2379,https://192.168.142.136:2379," into the etcd database Https://192.168.142.132:2379" set / coreos.com/network/config'{"Network": "172.17.0.0 opt/kubernetes/ 16", "Backend": {"Type": "vxlan"}} 'decompress and install Flannel binary package [root@node2 ~] # tar zxvf flannel-v0.10.0-linux-amd64.tar.gzflanneldmk-docker-opts.shREADME.md// set up working directory [root@node2 ~] # mkdir-p / opt/kubernetes/ {cfg,ssl Bin} / / move to the working directory [root@node2 ~] # mv flanneld mk-docker-opts.sh / opt/kubernetes/bin/ change the flannel configuration file [root@node2 ~] # cat

Tags: Network container allocation script Ali service address engine file directory network segment node role mirror work check configuration different security one line Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB vpn Docker macOS Redmi