当前位置:网站首页>Kubernetes cluster deployment (v1.23.5)
Kubernetes cluster deployment (v1.23.5)
2022-06-26 09:22:00 【cuibin1991】
1. Deployment Topology
1.1 Service configuration and topology
Mirror image :CentOS-7-x86_64-Minimal-1908
CPU:2 nucleus
Memory :2G

1.2 Change host name
// stay master Virtual machine , Set up master01 node
hostnamectl set-hostname master01
// Take effect immediately
bash
// see /etc/hostname by master01
cat /etc/hostname
// It will take effect permanently after restart
reboot
// In the same way node1 Virtual machine , Set up node01 node
hostnamectl set-hostname node01
// Take effect immediately
bash
// see /etc/hostname by node01
cat /etc/hostname
// It will take effect permanently after restart
reboot
node2 Such as node1 operation
2. install docker
// install yum Tools
yum install -y yum-utils
// Uninstall old version Docker
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
// Installation warehouse
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
// Update configuration yum After source , Generate the cache with the following command , Improve the speed of searching and installing software
sudo yum makecache fast
// install Docker
sudo yum install docker-ce docker-ce-cli containerd.io -y
// start-up docker
sudo systemctl start docker
// Set boot up
sudo systemctl enable docker
sudo systemctl status docker
// New configuration file
cat >> /etc/docker/daemon.json << EOF
{
"exec-opts":["native.cgroupdriver=systemd"]
}
EOF
// restart docker
systemctl restart docker
systemctl status docker
3. Server configuration
3.1 Turn off firewall
systemctl stop firewalld
systemctl disable firewalld
3.2 take SELinux Set to permissive Pattern ( It's equivalent to disabling )
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
3.3 allow iptables Check bridge flow
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
3.4 Shut down the system Swap
swapoff -a
// close swap Partition
sed -ri 's/.*swap.*/#&/' /etc/fstab
3.5 To configure /etc/hosts
// Customize master And node IP, Please modify... According to your personal situation
cat >> /etc/hosts << EOF
192.168.186.155 master01
192.168.186.156 node01
192.168.186.157 node02
EOF
4. install kubelet、kubeadm and kubectl
4.1 Configure software source
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
// For modification repo_gpgcheck=0
4.2 install kubelet kubeadm kubectl
Install on all nodes kubelet、kubeadm and kubectl.
- kubelet Running on the Cluster On all nodes , Responsible for starting Pod And the container .
- kubeadm For initialization Cluster.
- adopt kubectl Can be deployed and managed application , View resources , establish 、 Delete and update various components .
sudo yum update -y
//sudo yum install -y kubelet-1.19.4 kubeadm-1.19.4 kubectl-1.19.4
// According to github The release , Appoint
// Abreast of the times 1.24 Version is deprecated docker, Therefore, you need to specify 1.23
sudo yum install -y kubelet-1.23.5 kubeadm-1.23.5 kubectl-1.23.5
// Default latest version
//sudo yum install -y kubelet kubeadm kubectl
sudo systemctl enable --now kubelet
sudo systemctl start kubelet
//sudo systemctl status kubelet here kubelet Not ready yet , stay kubeadm init after master Nodes will ok, take node node join After adding kubelet It will be normal
4.3 Check tool installation
yum list installed | grep kubelet
yum list installed | grep kubeadm
yum list installed | grep kubectl
// View the cluster version results Kubernetes v1.23.5
kubelet --version
![]()
5. use kubeadm establish Cluster
5.1 initialization Master
- --apiserver-advertise-address Indicate the use Master Which one? interface And Cluster Other node communications for . If Master There are many. interface, It is suggested to specify clearly , If you don't specify ,kubeadm Will automatically select the interface.
- --pod-network-cidr Appoint Pod Scope of the network .Kubernetes Support multiple network solutions , And different network solutions --pod-network-cidr Have their own requirements , I'm going to set it to 10.244.0.0/16 Because we will use flannel Network plan , Must be set to this CIDR. In the later practice, we will switch to other network solutions , such as Canal.
//apiserver-advertise-address 192.168.186.155 by master node IP, According to the individual master IP modify
kubeadm init --apiserver-advertise-address 192.168.186.155 --image-repository registry.aliyuncs.com/google_containers --pod-network-cidr 10.244.0.0/16 --service-cidr 10.96.0.0/12
Add :Kubeadm Initialization error :[ERROR CRI]: container runtime is not running
terms of settlement :
rm -rf /etc/containerd/config.toml
systemctl restart containerd
// If execution fails , Reset required
kubeadm reset
// Configure client kubectl
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
5.2 initialization worker
//worker Nodes are added to the cluster ---> stay worker node node1 On the implementation
// Can pass kubeadm token list see token
// You can also obtain commands at one time through the following commands
kubeadm token create --print-join-command
![]()
5.3 add to pod The Internet calico --> master Node execution
wget https://docs.projectcalico.org/v3.20/manifests/calico.yaml --no-check-certificate
kubectl apply -f calico.yaml
// After application here node State by NotReady --> Ready
5.4 Control surface view cluster
kubectl get nodes

kubectl get pod -A

5.5 The workload worker node node1 View cluster
// stay master01 Transfer documents to node01, among 172.168.186.156 by master01 node
scp -r /etc/kubernetes/admin.conf [email protected]:/etc/kubernetes/
// stay node1 On the implementation
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
source ~/.bash_profile
边栏推荐
- Detectron2 save (according to maxap50) model during training_ best. PTH weight
- 行为树XML文件 热加载
- PD fast magnetization mobile power supply scheme
- Programming training 7- date conversion problem
- 行為樹XML文件 熱加載
- Unity connects to Turing robot
- Practice is the fastest way to become a network engineer
- 简析ROS计算图级
- Phpcms applet interface new universal interface get_ diy. php
- Chargement à chaud du fichier XML de l'arbre de comportement
猜你喜欢

Error importerror: numpy core. multiarray failed to import

Yolov5 advanced camera real-time acquisition and recognition

Router bridging settings

External sorting and heap size knowledge

《一周搞定模电》-二极管

首期Techo Day腾讯技术开放日,628等你

Upgrade phpcms applet plug-in API interface to 4.3 (add batch acquisition interface, search interface, etc.)

How to convert wechat applet into Baidu applet

"One week's work on Analog Electronics" - Basic amplification circuit
![Modify coco evaluation index maxdets=[10,15,20]](/img/f6/a0fbf601371aa51ec5b0136574c756.jpg)
Modify coco evaluation index maxdets=[10,15,20]
随机推荐
Self learning neural network sequence -- 2 perceptron
首期Techo Day腾讯技术开放日,628等你
"One week's study of model electricity" - capacitor, triode, FET
Self taught programming series - 4 numpy arrays
Lagrange multiplier method
Router bridging settings
Phpcms V9 mall module (fix the Alipay interface Bug)
Dedecms applet plug-in is officially launched, and one click installation does not require any PHP or SQL Foundation
"One week's solution to analog electricity" - power circuit
Yolov5 advanced 4 train your own data set
How to solve the problem that NVIDIA model cannot be viewed by inputting NVIDIA SMI and quickly view NVIDIA model information of computer graphics card
[open source] use phenocv weedcam for more intelligent and accurate weed management
Phpcms V9 background article list adds one click push to Baidu function
Self learning neural network series - 7 feedforward neural network pre knowledge
Phpcms V9 remove the phpsso module
Phpcms V9 adds the reading amount field in the background, and the reading amount can be modified at will
Self taught programming series - 1 regular expression
How to handle the small program tabbar that does not support parameter transfer
Self taught neural network series - 9 convolutional neural network CNN
全面解读!Golang中泛型的使用