Deploy a 3-node k8s cluster
**
Environment deployment (three virtual machines)
**
Check the version of the operating system (installing the kubernetes cluster in this way requires the Centos version to be 7.9)
host name resolution (download a vim first, otherwise it is not very habitual)
enter vim /etc/hosts
to modify the host name, the first one is master .The second one is node1. The third one is node2
Time synchronization, download chrony.
Modify the configuration file, comment all the previous ones, and configure the seventh line.
Restart the service, boot up, and then check the synchronization.
Then close the selinux service. setenforce 0, then check the selinux status
Close the firewall, then restart
Disable the swap partition, enter /etc/fstab, comment out the swap line to
upgrade the operating system kernel
Import elrepo gpg key
install elrepo YUM source warehouse
install kernel-ml version, ml is long-term stable version, lt is the long-term maintenance version.
Set the default boot of grub2 to 0
to regenerate the grub2 boot file
. After the update, you need to restart and use the upgraded
kernel to take effect
. Kernel parameters
Edit the /etc/sysctl.d/kubernetes.conf file
Reload the configuration (don’t care if the file does not exist)
Load the bridge filter module
Check whether the bridge filter module is loaded successfully
Configure the ipvs function
Install ipset and ipvsadm
to add the modules that need to be loaded Write the script file
Add execution permission to the script file
Execute the script file
Check whether the corresponding module is loaded successfully
K8s basic environment preparation
Switch the mirror source to China (the yum source of Alibaba Cloud is used here)
View all available editions
Cluster software installation (version 1.24.2)
Check the version after installation
Configure the cgroup of kubelet
to set kubelet to start automatically after booting
and then create a snapshot
Install containerd
Install some necessary system tools
Add software source information
Query software packages
Install software packages
Initialize default configuration
Modify containerd configuration Change cgroup
Modify mirror source
Configure crictl
to restart, reload, and automatically open
Verify that
the Master node can be initialized
Generate configuration files
Modify the following configuration:
- advertiseAddress:为控制切面地址,( Master 主机 IP )
- criSocket:为 containerd 的 socket 文件地址
- name:master
- imageRepository:阿里云镜像代理地址,否则拉取镜像会失败
- kubernetesVersion:为 k8s 版本
View the list of required images
Pull the image
Start kubeadm according to the configuration file Initialize k8s
and set the master as root
Set node1 node2 as a member
Check the cluster nodes
Install the network plug-in
Execute
Wait for a while, it will start and it will be OK