Kubernetes部署v1.26.0

一、准备环境

角色IP地址角色
kmaster192.168.100.180控制节点
knode01192.168.100.181工作节点
knode02192.168.100.182工作节点

二、系统环境配置

1、修改主机名

[root@ecs-kmaster ~]# hostnamectl set-hostname kmaster
[root@ecs-kmaster ~]# bash
[root@kmaster ~]# 
[root@ecs-knode1 ~]# hostnamectl set-hostname knode1
[root@ecs-knode1 ~]# bash
[root@knode1 ~]# 
[root@ecs-knode2 ~]# hostnamectl set-hostname knode2
[root@ecs-knode2 ~]# bash
[root@knode2 ~]# 

2、hosts设置

[root@kmaster ~]# vim /etc/hosts
[root@kmaster ~]# cat /etc/hosts
::1	localhost	localhost.localdomain	localhost6	localhost6.localdomain6
127.0.0.1	localhost	localhost.localdomain	localhost4	localhost4.localdomain4
192.168.100.180	kmaster
192.168.100.181 knode1
192.168.100.182	knode2
[root@kmaster ~]# scp -r /etc/hosts root@192.168.100.181:/etc/hosts
The authenticity of host '192.168.100.181 (192.168.100.181)' can't be established.
ECDSA key fingerprint is SHA256:Lrztnro7dY9v1yrw4oFQuJLUK46WoRYYRhHBljU25SQ.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.100.181' (ECDSA) to the list of known hosts.
root@192.168.100.181's password:
hosts                                                                                                      100%  218   460.8KB/s   00:00
[root@kmaster ~]# scp -r /etc/hosts root@192.168.100.182:/etc/hosts
The authenticity of host '192.168.100.182 (192.168.100.182)' can't be established.
ECDSA key fingerprint is SHA256:yDuD8g/sEJMHgMdKxhIjwqBM4T9FPq+fLK/3+BU97Uo.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.100.182' (ECDSA) to the list of known hosts.
root@192.168.100.182's password: 
hosts                                                                                                      100%  218    84.4KB/s   00:00    

3、安装所需包

[root@kmaster ~]# yum install -y yum-utils vim bash-completion net-tools wget
CentOS-8 - AppStream                                                                                          72 MB/s | 8.4 MB     00:00    
CentOS-8 - Base                                                                                               59 MB/s | 4.6 MB     00:00    
CentOS-8 - Extras                                                                                            280 kB/s |  10 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                                                                50 kB/s |  14 MB     04:44    
Extra Packages for Enterprise Linux Modular 8 - x86_64                                                       246 kB/s | 733 kB     00:02    
Package vim-enhanced-2:8.0.1763-16.el8.x86_64 is already installed.
Package net-tools-2.0-0.52.20160912git.el8.x86_64 is already installed.
Package wget-1.19.5-10.el8.x86_64 is already installed.
Dependencies resolved.
=============================================================================================================================================
 Package                               Architecture                 Version                               Repository                    Size
=============================================================================================================================================
Installing:
 bash-completion                       noarch                       1:2.7-5.el8                           BaseOS                       274 k
 yum-utils                             noarch                       4.0.21-3.el8                          BaseOS                        73 k

Transaction Summary
=============================================================================================================================================
Install  2 Packages

Total download size: 346 k
Installed size: 918 k
Downloading Packages:
(1/2): bash-completion-2.7-5.el8.noarch.rpm                                                                   12 MB/s | 274 kB     00:00    
(2/2): yum-utils-4.0.21-3.el8.noarch.rpm                                                                     2.9 MB/s |  73 kB     00:00    
---------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                         13 MB/s | 346 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                     1/1 
  Installing       : yum-utils-4.0.21-3.el8.noarch                                                                                       1/2 
  Installing       : bash-completion-1:2.7-5.el8.noarch                                                                                  2/2 
  Running scriptlet: bash-completion-1:2.7-5.el8.noarch                                                                                  2/2 
  Verifying        : bash-completion-1:2.7-5.el8.noarch                                                                                  1/2 
  Verifying        : yum-utils-4.0.21-3.el8.noarch                                                                                       2/2 

Installed:
  bash-completion-1:2.7-5.el8.noarch                                      yum-utils-4.0.21-3.el8.noarch                                     

Complete!

[root@knode1 ~]# yum install -y yum-utils vim bash-completion net-tools wget
CentOS-8 - AppStream                                                                                          72 MB/s | 8.4 MB     00:00    
CentOS-8 - Base                                                                                               55 MB/s | 4.6 MB     00:00    
CentOS-8 - Extras                                                                                            314 kB/s |  10 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                                                                18 kB/s |  14 MB     13:10    
Extra Packages for Enterprise Linux Modular 8 - x86_64                                                        33 kB/s | 733 kB     00:22    
Package vim-enhanced-2:8.0.1763-16.el8.x86_64 is already installed.
Package net-tools-2.0-0.52.20160912git.el8.x86_64 is already installed.
Package wget-1.19.5-10.el8.x86_64 is already installed.
Dependencies resolved.
=============================================================================================================================================
 Package                               Architecture                 Version                               Repository                    Size
=============================================================================================================================================
Installing:
 bash-completion                       noarch                       1:2.7-5.el8                           BaseOS                       274 k
 yum-utils                             noarch                       4.0.21-3.el8                          BaseOS                        73 k

Transaction Summary
=============================================================================================================================================
Install  2 Packages

Total download size: 346 k
Installed size: 918 k
Downloading Packages:
(1/2): yum-utils-4.0.21-3.el8.noarch.rpm                                                                     3.3 MB/s |  73 kB     00:00    
(2/2): bash-completion-2.7-5.el8.noarch.rpm                                                                   10 MB/s | 274 kB     00:00    
---------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                         12 MB/s | 346 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                     1/1 
  Installing       : yum-utils-4.0.21-3.el8.noarch                                                                                       1/2 
  Installing       : bash-completion-1:2.7-5.el8.noarch                                                                                  2/2 
  Running scriptlet: bash-completion-1:2.7-5.el8.noarch                                                                                  2/2 
  Verifying        : bash-completion-1:2.7-5.el8.noarch                                                                                  1/2 
  Verifying        : yum-utils-4.0.21-3.el8.noarch                                                                                       2/2 

Installed:
  bash-completion-1:2.7-5.el8.noarch                                      yum-utils-4.0.21-3.el8.noarch                                     

Complete!

[root@knode2 ~]# yum install -y yum-utils vim bash-completion net-tools wget
CentOS-8 - AppStream                                                                                          82 MB/s | 8.4 MB     00:00    
CentOS-8 - Base                                                                                               58 MB/s | 4.6 MB     00:00    
CentOS-8 - Extras                                                                                            253 kB/s |  10 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                                                                20 kB/s |  14 MB     12:07    
Extra Packages for Enterprise Linux Modular 8 - x86_64                                                        16 kB/s | 733 kB     00:44    
Package vim-enhanced-2:8.0.1763-16.el8.x86_64 is already installed.
Package net-tools-2.0-0.52.20160912git.el8.x86_64 is already installed.
Package wget-1.19.5-10.el8.x86_64 is already installed.
Dependencies resolved.
=============================================================================================================================================
 Package                               Architecture                 Version                               Repository                    Size
=============================================================================================================================================
Installing:
 bash-completion                       noarch                       1:2.7-5.el8                           BaseOS                       274 k
 yum-utils                             noarch                       4.0.21-3.el8                          BaseOS                        73 k

Transaction Summary
=============================================================================================================================================
Install  2 Packages

Total download size: 346 k
Installed size: 918 k
Downloading Packages:
(1/2): bash-completion-2.7-5.el8.noarch.rpm                                                                   10 MB/s | 274 kB     00:00    
(2/2): yum-utils-4.0.21-3.el8.noarch.rpm                                                                     2.5 MB/s |  73 kB     00:00    
---------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                         11 MB/s | 346 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                     1/1 
  Installing       : yum-utils-4.0.21-3.el8.noarch                                                                                       1/2 
  Installing       : bash-completion-1:2.7-5.el8.noarch                                                                                  2/2 
  Running scriptlet: bash-completion-1:2.7-5.el8.noarch                                                                                  2/2 
  Verifying        : bash-completion-1:2.7-5.el8.noarch                                                                                  1/2 
  Verifying        : yum-utils-4.0.21-3.el8.noarch                                                                                       2/2 

Installed:
  bash-completion-1:2.7-5.el8.noarch                                      yum-utils-4.0.21-3.el8.noarch                                     

Complete!

4、禁用swap分区

[root@kmaster ~]# swapoff -a
[root@kmaster ~]# swapon -s
[root@kmaster ~]# vim /etc/fstab
[root@kmaster ~]# cat /etc/fstab
#/dev/mapper/cs-swap     none                    swap    defaults        0 0

[root@knode1 ~]# swapoff -a
[root@knode1 ~]# swapon -s
[root@knode1 ~]# vim /etc/fstab
[root@knode1 ~]# cat /etc/fstab
#/dev/mapper/cs-swap     none                    swap    defaults        0 0

[root@knode2 ~]# swapoff -a
[root@knode2 ~]# swapon -s
[root@knode2 ~]# vim /etc/fstab
[root@knode2 ~]# cat /etc/fstab
#/dev/mapper/cs-swap     none                    swap    defaults        0 0

5、关闭防火墙和SELinux

[root@kmaster ~]# systemctl stop firewalld
[root@kmaster ~]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@kmaster ~]# setenforce 0
[root@kmaster ~]# sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config

[root@knode1 ~]# systemctl stop firewalld
[root@knode1 ~]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@knode1 ~]# setenforce 0
[root@knode1 ~]# sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config

[root@knode2 ~]# systemctl stop firewalld
[root@knode2 ~]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@knode2 ~]# setenforce 0
[root@knode2 ~]# sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config

6、安装docker

[root@kmaster ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@kmaster ~]# yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64                3:24.0.0-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.6-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.5-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.4-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.3-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.2-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.1-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.0-1.el8                  docker-ce-stable
docker-ce.x86_64                3:20.10.9-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.8-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.7-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.6-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.5-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.4-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.3-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.24-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.2-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.23-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.22-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.21-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.20-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.19-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.18-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.17-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.16-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.15-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.14-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.1-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.13-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.12-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.11-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.10-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.0-3.el8                 docker-ce-stable
docker-ce.x86_64                3:19.03.15-3.el8                docker-ce-stable
docker-ce.x86_64                3:19.03.14-3.el8                docker-ce-stable
docker-ce.x86_64                3:19.03.13-3.el8                docker-ce-stable
Docker CE Stable - x86_64                       140 kB/s |  44 kB     00:00    
Available Packages
[root@kmaster ~]# yum install -y docker-ce
Last metadata expiration check: 0:00:01 ago on Thu 18 May 2023 02:59:11 PM CST.
Dependencies resolved.
=============================================================================================================================================
 Package                                Architecture     Version                                            Repository                  Size
=============================================================================================================================================
Installing:
 docker-ce                              x86_64           3:24.0.0-1.el8                                     docker-ce-stable            24 M
Installing dependencies:
 checkpolicy                            x86_64           2.9-1.el8                                          BaseOS                     348 k
 container-selinux                      noarch           2:2.167.0-1.module_el8.5.0+911+f19012f9            AppStream                   54 k
 containerd.io                          x86_64           1.6.21-3.1.el8                                     docker-ce-stable            34 M
 docker-ce-cli                          x86_64           1:24.0.0-1.el8                                     docker-ce-stable           7.2 M
 docker-ce-rootless-extras              x86_64           24.0.0-1.el8                                       docker-ce-stable           4.9 M
 fuse-common                            x86_64           3.2.1-12.el8                                       BaseOS                      21 k
 fuse-overlayfs                         x86_64           1.7.1-1.module_el8.5.0+890+6b136101                AppStream                   73 k
 fuse3                                  x86_64           3.2.1-12.el8                                       BaseOS                      50 k
 fuse3-libs                             x86_64           3.2.1-12.el8                                       BaseOS                      94 k
 libcgroup                              x86_64           0.41-19.el8                                        BaseOS                      70 k
 libslirp                               x86_64           4.4.0-1.module_el8.5.0+890+6b136101                AppStream                   70 k
 policycoreutils-python-utils           noarch           2.9-16.el8                                         BaseOS                     252 k
 python3-audit                          x86_64           3.0-0.17.20191104git1c2f876.el8                    BaseOS                      86 k
 python3-libsemanage                    x86_64           2.9-6.el8                                          BaseOS                     127 k
 python3-policycoreutils                noarch           2.9-16.el8                                         BaseOS                     2.2 M
 python3-setools                        x86_64           4.3.0-2.el8                                        BaseOS                     626 k
 slirp4netns                            x86_64           1.1.8-1.module_el8.5.0+890+6b136101                AppStream                   51 k
Installing weak dependencies:
 docker-buildx-plugin                   x86_64           0.10.4-1.el8                                       docker-ce-stable            12 M
 docker-compose-plugin                  x86_64           2.17.3-1.el8                                       docker-ce-stable            12 M
Enabling module streams:
 container-tools                                         rhel8                                                                              

Transaction Summary
=============================================================================================================================================
Install  20 Packages

Total download size: 98 M
Installed size: 371 M
Downloading Packages:
(1/20): libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64.rpm                                              2.8 MB/s |  70 kB     00:00    
(2/20): slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64.rpm                                           5.9 MB/s |  51 kB     00:00    
(3/20): checkpolicy-2.9-1.el8.x86_64.rpm                                                                      19 MB/s | 348 kB     00:00    
(4/20): fuse-common-3.2.1-12.el8.x86_64.rpm                                                                  3.9 MB/s |  21 kB     00:00    
(5/20): fuse3-3.2.1-12.el8.x86_64.rpm                                                                        6.7 MB/s |  50 kB     00:00    
(6/20): fuse3-libs-3.2.1-12.el8.x86_64.rpm                                                                    13 MB/s |  94 kB     00:00    
(7/20): libcgroup-0.41-19.el8.x86_64.rpm                                                                     9.5 MB/s |  70 kB     00:00    
(8/20): policycoreutils-python-utils-2.9-16.el8.noarch.rpm                                                    20 MB/s | 252 kB     00:00    
(9/20): python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64.rpm                                              13 MB/s |  86 kB     00:00    
(10/20): python3-libsemanage-2.9-6.el8.x86_64.rpm                                                             18 MB/s | 127 kB     00:00    
(11/20): python3-policycoreutils-2.9-16.el8.noarch.rpm                                                        42 MB/s | 2.2 MB     00:00    
(12/20): python3-setools-4.3.0-2.el8.x86_64.rpm                                                               38 MB/s | 626 kB     00:00    
(13/20): container-selinux-2.167.0-1.module_el8.5.0+911+f19012f9.noarch.rpm                                  227 kB/s |  54 kB     00:00    
(14/20): fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64.rpm                                        10 kB/s |  73 kB     00:07    
(15/20): docker-buildx-plugin-0.10.4-1.el8.x86_64.rpm                                                        484 kB/s |  12 MB     00:25    
(16/20): docker-ce-cli-24.0.0-1.el8.x86_64.rpm                                                               471 kB/s | 7.2 MB     00:15    
(17/20): docker-ce-rootless-extras-24.0.0-1.el8.x86_64.rpm                                                   464 kB/s | 4.9 MB     00:10    
(18/20): docker-ce-24.0.0-1.el8.x86_64.rpm                                                                   476 kB/s |  24 MB     00:52    
(19/20): containerd.io-1.6.21-3.1.el8.x86_64.rpm                                                             473 kB/s |  34 MB     01:12    
(20/20): docker-compose-plugin-2.17.3-1.el8.x86_64.rpm                                                       449 kB/s |  12 MB     00:26    
---------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                        1.2 MB/s |  98 MB     01:18     
Docker CE Stable - x86_64                                                                                     24 kB/s | 1.6 kB     00:00    
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
 From       : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                     1/1 
  Installing       : docker-compose-plugin-2.17.3-1.el8.x86_64                                                                          1/20 
  Running scriptlet: docker-compose-plugin-2.17.3-1.el8.x86_64                                                                          1/20 
  Installing       : docker-buildx-plugin-0.10.4-1.el8.x86_64                                                                           2/20 
  Running scriptlet: docker-buildx-plugin-0.10.4-1.el8.x86_64                                                                           2/20 
  Installing       : docker-ce-cli-1:24.0.0-1.el8.x86_64                                                                                3/20 
  Running scriptlet: docker-ce-cli-1:24.0.0-1.el8.x86_64                                                                                3/20 
  Installing       : python3-setools-4.3.0-2.el8.x86_64                                                                                 4/20 
  Installing       : python3-libsemanage-2.9-6.el8.x86_64                                                                               5/20 
  Installing       : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                                                               6/20 
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                                       7/20 
  Installing       : libcgroup-0.41-19.el8.x86_64                                                                                       7/20 
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                                       7/20 
  Installing       : fuse3-libs-3.2.1-12.el8.x86_64                                                                                     8/20 
  Running scriptlet: fuse3-libs-3.2.1-12.el8.x86_64                                                                                     8/20 
  Installing       : fuse-common-3.2.1-12.el8.x86_64                                                                                    9/20 
  Installing       : fuse3-3.2.1-12.el8.x86_64                                                                                         10/20 
  Installing       : fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64                                                         11/20 
  Running scriptlet: fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64                                                         11/20 
  Installing       : checkpolicy-2.9-1.el8.x86_64                                                                                      12/20 
  Installing       : python3-policycoreutils-2.9-16.el8.noarch                                                                         13/20 
  Installing       : policycoreutils-python-utils-2.9-16.el8.noarch                                                                    14/20 
  Running scriptlet: container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                  15/20 
  Installing       : container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                  15/20 
  Running scriptlet: container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                  15/20 
  Installing       : containerd.io-1.6.21-3.1.el8.x86_64                                                                               16/20 
  Running scriptlet: containerd.io-1.6.21-3.1.el8.x86_64                                                                               16/20 
  Installing       : libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64                                                               17/20 
  Installing       : slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64                                                            18/20 
  Installing       : docker-ce-rootless-extras-24.0.0-1.el8.x86_64                                                                     19/20 
  Running scriptlet: docker-ce-rootless-extras-24.0.0-1.el8.x86_64                                                                     19/20 
  Installing       : docker-ce-3:24.0.0-1.el8.x86_64                                                                                   20/20 
  Running scriptlet: docker-ce-3:24.0.0-1.el8.x86_64                                                                                   20/20 
  Running scriptlet: container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                  20/20 
  Running scriptlet: docker-ce-3:24.0.0-1.el8.x86_64                                                                                   20/20 
  Verifying        : container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                   1/20 
  Verifying        : fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64                                                          2/20 
  Verifying        : libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64                                                                3/20 
  Verifying        : slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64                                                             4/20 
  Verifying        : checkpolicy-2.9-1.el8.x86_64                                                                                       5/20 
  Verifying        : fuse-common-3.2.1-12.el8.x86_64                                                                                    6/20 
  Verifying        : fuse3-3.2.1-12.el8.x86_64                                                                                          7/20 
  Verifying        : fuse3-libs-3.2.1-12.el8.x86_64                                                                                     8/20 
  Verifying        : libcgroup-0.41-19.el8.x86_64                                                                                       9/20 
  Verifying        : policycoreutils-python-utils-2.9-16.el8.noarch                                                                    10/20 
  Verifying        : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                                                              11/20 
  Verifying        : python3-libsemanage-2.9-6.el8.x86_64                                                                              12/20 
  Verifying        : python3-policycoreutils-2.9-16.el8.noarch                                                                         13/20 
  Verifying        : python3-setools-4.3.0-2.el8.x86_64                                                                                14/20 
  Verifying        : containerd.io-1.6.21-3.1.el8.x86_64                                                                               15/20 
  Verifying        : docker-buildx-plugin-0.10.4-1.el8.x86_64                                                                          16/20 
  Verifying        : docker-ce-3:24.0.0-1.el8.x86_64                                                                                   17/20 
  Verifying        : docker-ce-cli-1:24.0.0-1.el8.x86_64                                                                               18/20 
  Verifying        : docker-ce-rootless-extras-24.0.0-1.el8.x86_64                                                                     19/20 
  Verifying        : docker-compose-plugin-2.17.3-1.el8.x86_64                                                                         20/20 

Installed:
  checkpolicy-2.9-1.el8.x86_64                                 container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch              
  containerd.io-1.6.21-3.1.el8.x86_64                          docker-buildx-plugin-0.10.4-1.el8.x86_64                                      
  docker-ce-3:24.0.0-1.el8.x86_64                              docker-ce-cli-1:24.0.0-1.el8.x86_64                                           
  docker-ce-rootless-extras-24.0.0-1.el8.x86_64                docker-compose-plugin-2.17.3-1.el8.x86_64                                     
  fuse-common-3.2.1-12.el8.x86_64                              fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64                     
  fuse3-3.2.1-12.el8.x86_64                                    fuse3-libs-3.2.1-12.el8.x86_64                                                
  libcgroup-0.41-19.el8.x86_64                                 libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64                           
  policycoreutils-python-utils-2.9-16.el8.noarch               python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                          
  python3-libsemanage-2.9-6.el8.x86_64                         python3-policycoreutils-2.9-16.el8.noarch                                     
  python3-setools-4.3.0-2.el8.x86_64                           slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64                        

Complete!
[root@kmaster ~]# systemctl start docker 
[root@kmaster ~]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[root@kmaster ~]# docker -v
Docker version 24.0.0, build 98fdcd7
[root@kmaster ~]# systemctl is-active docker
active
[root@kmaster ~]# systemctl is-enabled docker
enabled

[root@knode1 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@knode1 ~]# yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64                3:24.0.0-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.6-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.5-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.4-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.3-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.2-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.1-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.0-1.el8                  docker-ce-stable
docker-ce.x86_64                3:20.10.9-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.8-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.7-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.6-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.5-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.4-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.3-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.24-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.2-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.23-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.22-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.21-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.20-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.19-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.18-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.17-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.16-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.15-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.14-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.1-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.13-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.12-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.11-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.10-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.0-3.el8                 docker-ce-stable
docker-ce.x86_64                3:19.03.15-3.el8                docker-ce-stable
docker-ce.x86_64                3:19.03.14-3.el8                docker-ce-stable
docker-ce.x86_64                3:19.03.13-3.el8                docker-ce-stable
Docker CE Stable - x86_64                       162 kB/s |  44 kB     00:00    
Available Packages
[root@knode1 ~]# yum install -y docker-ce
Last metadata expiration check: 0:00:01 ago on Thu 18 May 2023 02:59:11 PM CST.
Dependencies resolved.
=============================================================================================================================================
 Package                                Architecture     Version                                            Repository                  Size
=============================================================================================================================================
Installing:
 docker-ce                              x86_64           3:24.0.0-1.el8                                     docker-ce-stable            24 M
Installing dependencies:
 checkpolicy                            x86_64           2.9-1.el8                                          BaseOS                     348 k
 container-selinux                      noarch           2:2.167.0-1.module_el8.5.0+911+f19012f9            AppStream                   54 k
 containerd.io                          x86_64           1.6.21-3.1.el8                                     docker-ce-stable            34 M
 docker-ce-cli                          x86_64           1:24.0.0-1.el8                                     docker-ce-stable           7.2 M
 docker-ce-rootless-extras              x86_64           24.0.0-1.el8                                       docker-ce-stable           4.9 M
 fuse-common                            x86_64           3.2.1-12.el8                                       BaseOS                      21 k
 fuse-overlayfs                         x86_64           1.7.1-1.module_el8.5.0+890+6b136101                AppStream                   73 k
 fuse3                                  x86_64           3.2.1-12.el8                                       BaseOS                      50 k
 fuse3-libs                             x86_64           3.2.1-12.el8                                       BaseOS                      94 k
 libcgroup                              x86_64           0.41-19.el8                                        BaseOS                      70 k
 libslirp                               x86_64           4.4.0-1.module_el8.5.0+890+6b136101                AppStream                   70 k
 policycoreutils-python-utils           noarch           2.9-16.el8                                         BaseOS                     252 k
 python3-audit                          x86_64           3.0-0.17.20191104git1c2f876.el8                    BaseOS                      86 k
 python3-libsemanage                    x86_64           2.9-6.el8                                          BaseOS                     127 k
 python3-policycoreutils                noarch           2.9-16.el8                                         BaseOS                     2.2 M
 python3-setools                        x86_64           4.3.0-2.el8                                        BaseOS                     626 k
 slirp4netns                            x86_64           1.1.8-1.module_el8.5.0+890+6b136101                AppStream                   51 k
Installing weak dependencies:
 docker-buildx-plugin                   x86_64           0.10.4-1.el8                                       docker-ce-stable            12 M
 docker-compose-plugin                  x86_64           2.17.3-1.el8                                       docker-ce-stable            12 M
Enabling module streams:
 container-tools                                         rhel8                                                                              

Transaction Summary
=============================================================================================================================================
Install  20 Packages

Total download size: 98 M
Installed size: 371 M
Downloading Packages:
(1/20): libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64.rpm                                              3.3 MB/s |  70 kB     00:00    
(2/20): fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64.rpm                                        2.8 MB/s |  73 kB     00:00    
(3/20): slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64.rpm                                           7.1 MB/s |  51 kB     00:00    
(4/20): checkpolicy-2.9-1.el8.x86_64.rpm                                                                      30 MB/s | 348 kB     00:00    
(5/20): fuse-common-3.2.1-12.el8.x86_64.rpm                                                                  1.8 MB/s |  21 kB     00:00    
(6/20): fuse3-3.2.1-12.el8.x86_64.rpm                                                                        7.6 MB/s |  50 kB     00:00    
(7/20): fuse3-libs-3.2.1-12.el8.x86_64.rpm                                                                    16 MB/s |  94 kB     00:00    
(8/20): libcgroup-0.41-19.el8.x86_64.rpm                                                                     7.1 MB/s |  70 kB     00:00    
(9/20): policycoreutils-python-utils-2.9-16.el8.noarch.rpm                                                    20 MB/s | 252 kB     00:00    
(10/20): python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64.rpm                                            9.4 MB/s |  86 kB     00:00    
(11/20): python3-libsemanage-2.9-6.el8.x86_64.rpm                                                             17 MB/s | 127 kB     00:00    
(12/20): python3-setools-4.3.0-2.el8.x86_64.rpm                                                               35 MB/s | 626 kB     00:00    
(13/20): python3-policycoreutils-2.9-16.el8.noarch.rpm                                                        55 MB/s | 2.2 MB     00:00    
(14/20): container-selinux-2.167.0-1.module_el8.5.0+911+f19012f9.noarch.rpm                                  7.6 kB/s |  54 kB     00:07    
(15/20): docker-buildx-plugin-0.10.4-1.el8.x86_64.rpm                                                        335 kB/s |  12 MB     00:37    
(16/20): docker-ce-cli-24.0.0-1.el8.x86_64.rpm                                                               317 kB/s | 7.2 MB     00:23    
(17/20): docker-ce-rootless-extras-24.0.0-1.el8.x86_64.rpm                                                   328 kB/s | 4.9 MB     00:15    
(18/20): docker-ce-24.0.0-1.el8.x86_64.rpm                                                                   334 kB/s |  24 MB     01:14    
(19/20): containerd.io-1.6.21-3.1.el8.x86_64.rpm                                                             296 kB/s |  34 MB     01:56    
(20/20): docker-compose-plugin-2.17.3-1.el8.x86_64.rpm                                                       284 kB/s |  12 MB     00:41    
---------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                        853 kB/s |  98 MB     01:57     
Docker CE Stable - x86_64                                                                                     19 kB/s | 1.6 kB     00:00    
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
 From       : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                     1/1 
  Installing       : docker-compose-plugin-2.17.3-1.el8.x86_64                                                                          1/20 
  Running scriptlet: docker-compose-plugin-2.17.3-1.el8.x86_64                                                                          1/20 
  Installing       : docker-buildx-plugin-0.10.4-1.el8.x86_64                                                                           2/20 
  Running scriptlet: docker-buildx-plugin-0.10.4-1.el8.x86_64                                                                           2/20 
  Installing       : docker-ce-cli-1:24.0.0-1.el8.x86_64                                                                                3/20 
  Running scriptlet: docker-ce-cli-1:24.0.0-1.el8.x86_64                                                                                3/20 
  Installing       : python3-setools-4.3.0-2.el8.x86_64                                                                                 4/20 
  Installing       : python3-libsemanage-2.9-6.el8.x86_64                                                                               5/20 
  Installing       : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                                                               6/20 
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                                       7/20 
  Installing       : libcgroup-0.41-19.el8.x86_64                                                                                       7/20 
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                                       7/20 
  Installing       : fuse3-libs-3.2.1-12.el8.x86_64                                                                                     8/20 
  Running scriptlet: fuse3-libs-3.2.1-12.el8.x86_64                                                                                     8/20 
  Installing       : fuse-common-3.2.1-12.el8.x86_64                                                                                    9/20 
  Installing       : fuse3-3.2.1-12.el8.x86_64                                                                                         10/20 
  Installing       : fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64                                                         11/20 
  Running scriptlet: fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64                                                         11/20 
  Installing       : checkpolicy-2.9-1.el8.x86_64                                                                                      12/20 
  Installing       : python3-policycoreutils-2.9-16.el8.noarch                                                                         13/20 
  Installing       : policycoreutils-python-utils-2.9-16.el8.noarch                                                                    14/20 
  Running scriptlet: container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                  15/20 
  Installing       : container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                  15/20 
  Running scriptlet: container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                  15/20 
  Installing       : containerd.io-1.6.21-3.1.el8.x86_64                                                                               16/20 
  Running scriptlet: containerd.io-1.6.21-3.1.el8.x86_64                                                                               16/20 
  Installing       : libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64                                                               17/20 
  Installing       : slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64                                                            18/20 
  Installing       : docker-ce-rootless-extras-24.0.0-1.el8.x86_64                                                                     19/20 
  Running scriptlet: docker-ce-rootless-extras-24.0.0-1.el8.x86_64                                                                     19/20 
  Installing       : docker-ce-3:24.0.0-1.el8.x86_64                                                                                   20/20 
  Running scriptlet: docker-ce-3:24.0.0-1.el8.x86_64                                                                                   20/20 
  Running scriptlet: container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                  20/20 
  Running scriptlet: docker-ce-3:24.0.0-1.el8.x86_64                                                                                   20/20 
  Verifying        : container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                   1/20 
  Verifying        : fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64                                                          2/20 
  Verifying        : libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64                                                                3/20 
  Verifying        : slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64                                                             4/20 
  Verifying        : checkpolicy-2.9-1.el8.x86_64                                                                                       5/20 
  Verifying        : fuse-common-3.2.1-12.el8.x86_64                                                                                    6/20 
  Verifying        : fuse3-3.2.1-12.el8.x86_64                                                                                          7/20 
  Verifying        : fuse3-libs-3.2.1-12.el8.x86_64                                                                                     8/20 
  Verifying        : libcgroup-0.41-19.el8.x86_64                                                                                       9/20 
  Verifying        : policycoreutils-python-utils-2.9-16.el8.noarch                                                                    10/20 
  Verifying        : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                                                              11/20 
  Verifying        : python3-libsemanage-2.9-6.el8.x86_64                                                                              12/20 
  Verifying        : python3-policycoreutils-2.9-16.el8.noarch                                                                         13/20 
  Verifying        : python3-setools-4.3.0-2.el8.x86_64                                                                                14/20 
  Verifying        : containerd.io-1.6.21-3.1.el8.x86_64                                                                               15/20 
  Verifying        : docker-buildx-plugin-0.10.4-1.el8.x86_64                                                                          16/20 
  Verifying        : docker-ce-3:24.0.0-1.el8.x86_64                                                                                   17/20 
  Verifying        : docker-ce-cli-1:24.0.0-1.el8.x86_64                                                                               18/20 
  Verifying        : docker-ce-rootless-extras-24.0.0-1.el8.x86_64                                                                     19/20 
  Verifying        : docker-compose-plugin-2.17.3-1.el8.x86_64                                                                         20/20 

Installed:
  checkpolicy-2.9-1.el8.x86_64                                 container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch              
  containerd.io-1.6.21-3.1.el8.x86_64                          docker-buildx-plugin-0.10.4-1.el8.x86_64                                      
  docker-ce-3:24.0.0-1.el8.x86_64                              docker-ce-cli-1:24.0.0-1.el8.x86_64                                           
  docker-ce-rootless-extras-24.0.0-1.el8.x86_64                docker-compose-plugin-2.17.3-1.el8.x86_64                                     
  fuse-common-3.2.1-12.el8.x86_64                              fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64                     
  fuse3-3.2.1-12.el8.x86_64                                    fuse3-libs-3.2.1-12.el8.x86_64                                                
  libcgroup-0.41-19.el8.x86_64                                 libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64                           
  policycoreutils-python-utils-2.9-16.el8.noarch               python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                          
  python3-libsemanage-2.9-6.el8.x86_64                         python3-policycoreutils-2.9-16.el8.noarch                                     
  python3-setools-4.3.0-2.el8.x86_64                           slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64                        

Complete!
[root@knode1 ~]# systemctl start docker 
[root@knode1 ~]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[root@knode1 ~]# docker -v
Docker version 24.0.0, build 98fdcd7
[root@knode1 ~]# systemctl is-active docker
active
[root@knode1 ~]# systemctl is-enabled docker
enabled

[root@knode2 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@knode2 ~]# yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64                3:24.0.0-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.6-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.5-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.4-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.3-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.2-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.1-1.el8                  docker-ce-stable
docker-ce.x86_64                3:23.0.0-1.el8                  docker-ce-stable
docker-ce.x86_64                3:20.10.9-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.8-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.7-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.6-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.5-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.4-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.3-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.24-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.2-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.23-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.22-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.21-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.20-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.19-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.18-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.17-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.16-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.15-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.14-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.1-3.el8                 docker-ce-stable
docker-ce.x86_64                3:20.10.13-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.12-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.11-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.10-3.el8                docker-ce-stable
docker-ce.x86_64                3:20.10.0-3.el8                 docker-ce-stable
docker-ce.x86_64                3:19.03.15-3.el8                docker-ce-stable
docker-ce.x86_64                3:19.03.14-3.el8                docker-ce-stable
docker-ce.x86_64                3:19.03.13-3.el8                docker-ce-stable
Docker CE Stable - x86_64                       162 kB/s |  44 kB     00:00    
Available Packages
[root@knode2 ~]# yum install -y docker-ce
Last metadata expiration check: 0:00:01 ago on Thu 18 May 2023 02:59:11 PM CST.
Dependencies resolved.
=============================================================================================================================================
 Package                                Architecture     Version                                            Repository                  Size
=============================================================================================================================================
Installing:
 docker-ce                              x86_64           3:24.0.0-1.el8                                     docker-ce-stable            24 M
Installing dependencies:
 checkpolicy                            x86_64           2.9-1.el8                                          BaseOS                     348 k
 container-selinux                      noarch           2:2.167.0-1.module_el8.5.0+911+f19012f9            AppStream                   54 k
 containerd.io                          x86_64           1.6.21-3.1.el8                                     docker-ce-stable            34 M
 docker-ce-cli                          x86_64           1:24.0.0-1.el8                                     docker-ce-stable           7.2 M
 docker-ce-rootless-extras              x86_64           24.0.0-1.el8                                       docker-ce-stable           4.9 M
 fuse-common                            x86_64           3.2.1-12.el8                                       BaseOS                      21 k
 fuse-overlayfs                         x86_64           1.7.1-1.module_el8.5.0+890+6b136101                AppStream                   73 k
 fuse3                                  x86_64           3.2.1-12.el8                                       BaseOS                      50 k
 fuse3-libs                             x86_64           3.2.1-12.el8                                       BaseOS                      94 k
 libcgroup                              x86_64           0.41-19.el8                                        BaseOS                      70 k
 libslirp                               x86_64           4.4.0-1.module_el8.5.0+890+6b136101                AppStream                   70 k
 policycoreutils-python-utils           noarch           2.9-16.el8                                         BaseOS                     252 k
 python3-audit                          x86_64           3.0-0.17.20191104git1c2f876.el8                    BaseOS                      86 k
 python3-libsemanage                    x86_64           2.9-6.el8                                          BaseOS                     127 k
 python3-policycoreutils                noarch           2.9-16.el8                                         BaseOS                     2.2 M
 python3-setools                        x86_64           4.3.0-2.el8                                        BaseOS                     626 k
 slirp4netns                            x86_64           1.1.8-1.module_el8.5.0+890+6b136101                AppStream                   51 k
Installing weak dependencies:
 docker-buildx-plugin                   x86_64           0.10.4-1.el8                                       docker-ce-stable            12 M
 docker-compose-plugin                  x86_64           2.17.3-1.el8                                       docker-ce-stable            12 M
Enabling module streams:
 container-tools                                         rhel8                                                                              

Transaction Summary
=============================================================================================================================================
Install  20 Packages

Total download size: 98 M
Installed size: 371 M
Downloading Packages:
(1/20): fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64.rpm                                        3.2 MB/s |  73 kB     00:00    
(2/20): libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64.rpm                                              2.7 MB/s |  70 kB     00:00    
(3/20): slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64.rpm                                           6.1 MB/s |  51 kB     00:00    
(4/20): fuse-common-3.2.1-12.el8.x86_64.rpm                                                                  3.2 MB/s |  21 kB     00:00    
(5/20): checkpolicy-2.9-1.el8.x86_64.rpm                                                                      22 MB/s | 348 kB     00:00    
(6/20): fuse3-3.2.1-12.el8.x86_64.rpm                                                                        7.1 MB/s |  50 kB     00:00    
(7/20): fuse3-libs-3.2.1-12.el8.x86_64.rpm                                                                    10 MB/s |  94 kB     00:00    
(8/20): libcgroup-0.41-19.el8.x86_64.rpm                                                                     7.7 MB/s |  70 kB     00:00    
(9/20): policycoreutils-python-utils-2.9-16.el8.noarch.rpm                                                    24 MB/s | 252 kB     00:00    
(10/20): python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64.rpm                                            7.9 MB/s |  86 kB     00:00    
(11/20): python3-libsemanage-2.9-6.el8.x86_64.rpm                                                             10 MB/s | 127 kB     00:00    
(12/20): python3-setools-4.3.0-2.el8.x86_64.rpm                                                               26 MB/s | 626 kB     00:00    
(13/20): python3-policycoreutils-2.9-16.el8.noarch.rpm                                                        46 MB/s | 2.2 MB     00:00    
(14/20): container-selinux-2.167.0-1.module_el8.5.0+911+f19012f9.noarch.rpm                                  7.5 kB/s |  54 kB     00:07    
(15/20): docker-buildx-plugin-0.10.4-1.el8.x86_64.rpm                                                        482 kB/s |  12 MB     00:25    
(16/20): docker-ce-cli-24.0.0-1.el8.x86_64.rpm                                                               473 kB/s | 7.2 MB     00:15    
(17/20): docker-ce-rootless-extras-24.0.0-1.el8.x86_64.rpm                                                   465 kB/s | 4.9 MB     00:10    
(18/20): docker-ce-24.0.0-1.el8.x86_64.rpm                                                                   474 kB/s |  24 MB     00:52    
(19/20): containerd.io-1.6.21-3.1.el8.x86_64.rpm                                                             472 kB/s |  34 MB     01:13    
(20/20): docker-compose-plugin-2.17.3-1.el8.x86_64.rpm                                                       451 kB/s |  12 MB     00:26    
---------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                        1.2 MB/s |  98 MB     01:18     
Docker CE Stable - x86_64                                                                                     14 kB/s | 1.6 kB     00:00    
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
 From       : https://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                     1/1 
  Installing       : docker-compose-plugin-2.17.3-1.el8.x86_64                                                                          1/20 
  Running scriptlet: docker-compose-plugin-2.17.3-1.el8.x86_64                                                                          1/20 
  Installing       : docker-buildx-plugin-0.10.4-1.el8.x86_64                                                                           2/20 
  Running scriptlet: docker-buildx-plugin-0.10.4-1.el8.x86_64                                                                           2/20 
  Installing       : docker-ce-cli-1:24.0.0-1.el8.x86_64                                                                                3/20 
  Running scriptlet: docker-ce-cli-1:24.0.0-1.el8.x86_64                                                                                3/20 
  Installing       : python3-setools-4.3.0-2.el8.x86_64                                                                                 4/20 
  Installing       : python3-libsemanage-2.9-6.el8.x86_64                                                                               5/20 
  Installing       : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                                                               6/20 
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                                       7/20 
  Installing       : libcgroup-0.41-19.el8.x86_64                                                                                       7/20 
  Running scriptlet: libcgroup-0.41-19.el8.x86_64                                                                                       7/20 
  Installing       : fuse3-libs-3.2.1-12.el8.x86_64                                                                                     8/20 
  Running scriptlet: fuse3-libs-3.2.1-12.el8.x86_64                                                                                     8/20 
  Installing       : fuse-common-3.2.1-12.el8.x86_64                                                                                    9/20 
  Installing       : fuse3-3.2.1-12.el8.x86_64                                                                                         10/20 
  Installing       : fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64                                                         11/20 
  Running scriptlet: fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64                                                         11/20 
  Installing       : checkpolicy-2.9-1.el8.x86_64                                                                                      12/20 
  Installing       : python3-policycoreutils-2.9-16.el8.noarch                                                                         13/20 
  Installing       : policycoreutils-python-utils-2.9-16.el8.noarch                                                                    14/20 
  Running scriptlet: container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                  15/20 
  Installing       : container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                  15/20 
  Running scriptlet: container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                  15/20 
  Installing       : containerd.io-1.6.21-3.1.el8.x86_64                                                                               16/20 
  Running scriptlet: containerd.io-1.6.21-3.1.el8.x86_64                                                                               16/20 
  Installing       : libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64                                                               17/20 
  Installing       : slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64                                                            18/20 
  Installing       : docker-ce-rootless-extras-24.0.0-1.el8.x86_64                                                                     19/20 
  Running scriptlet: docker-ce-rootless-extras-24.0.0-1.el8.x86_64                                                                     19/20 
  Installing       : docker-ce-3:24.0.0-1.el8.x86_64                                                                                   20/20 
  Running scriptlet: docker-ce-3:24.0.0-1.el8.x86_64                                                                                   20/20 
  Running scriptlet: container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                  20/20 
  Running scriptlet: docker-ce-3:24.0.0-1.el8.x86_64                                                                                   20/20 
  Verifying        : container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch                                                   1/20 
  Verifying        : fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64                                                          2/20 
  Verifying        : libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64                                                                3/20 
  Verifying        : slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64                                                             4/20 
  Verifying        : checkpolicy-2.9-1.el8.x86_64                                                                                       5/20 
  Verifying        : fuse-common-3.2.1-12.el8.x86_64                                                                                    6/20 
  Verifying        : fuse3-3.2.1-12.el8.x86_64                                                                                          7/20 
  Verifying        : fuse3-libs-3.2.1-12.el8.x86_64                                                                                     8/20 
  Verifying        : libcgroup-0.41-19.el8.x86_64                                                                                       9/20 
  Verifying        : policycoreutils-python-utils-2.9-16.el8.noarch                                                                    10/20 
  Verifying        : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                                                              11/20 
  Verifying        : python3-libsemanage-2.9-6.el8.x86_64                                                                              12/20 
  Verifying        : python3-policycoreutils-2.9-16.el8.noarch                                                                         13/20 
  Verifying        : python3-setools-4.3.0-2.el8.x86_64                                                                                14/20 
  Verifying        : containerd.io-1.6.21-3.1.el8.x86_64                                                                               15/20 
  Verifying        : docker-buildx-plugin-0.10.4-1.el8.x86_64                                                                          16/20 
  Verifying        : docker-ce-3:24.0.0-1.el8.x86_64                                                                                   17/20 
  Verifying        : docker-ce-cli-1:24.0.0-1.el8.x86_64                                                                               18/20 
  Verifying        : docker-ce-rootless-extras-24.0.0-1.el8.x86_64                                                                     19/20 
  Verifying        : docker-compose-plugin-2.17.3-1.el8.x86_64                                                                         20/20 

Installed:
  checkpolicy-2.9-1.el8.x86_64                                 container-selinux-2:2.167.0-1.module_el8.5.0+911+f19012f9.noarch              
  containerd.io-1.6.21-3.1.el8.x86_64                          docker-buildx-plugin-0.10.4-1.el8.x86_64                                      
  docker-ce-3:24.0.0-1.el8.x86_64                              docker-ce-cli-1:24.0.0-1.el8.x86_64                                           
  docker-ce-rootless-extras-24.0.0-1.el8.x86_64                docker-compose-plugin-2.17.3-1.el8.x86_64                                     
  fuse-common-3.2.1-12.el8.x86_64                              fuse-overlayfs-1.7.1-1.module_el8.5.0+890+6b136101.x86_64                     
  fuse3-3.2.1-12.el8.x86_64                                    fuse3-libs-3.2.1-12.el8.x86_64                                                
  libcgroup-0.41-19.el8.x86_64                                 libslirp-4.4.0-1.module_el8.5.0+890+6b136101.x86_64                           
  policycoreutils-python-utils-2.9-16.el8.noarch               python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                          
  python3-libsemanage-2.9-6.el8.x86_64                         python3-policycoreutils-2.9-16.el8.noarch                                     
  python3-setools-4.3.0-2.el8.x86_64                           slirp4netns-1.1.8-1.module_el8.5.0+890+6b136101.x86_64                        

Complete!
[root@knode2 ~]# systemctl start docker 
[root@knode2 ~]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[root@knode2 ~]# docker -v
Docker version 24.0.0, build 98fdcd7
[root@knode2 ~]# systemctl is-active docker
active
[root@knode2 ~]# systemctl is-enabled docker
enabled

7、开启转发及 iptables 过滤

[root@kmaster ~]# cat <<EOF > /etc/sysctl.d/k8s.conf
> net.bridge.bridge-nf-call-ip6tables = 1
> net.bridge.bridge-nf-call-iptables = 1
> net.ipv4.ip_forward = 1
> EOF
[root@kmaster ~]# sysctl -p /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1

[root@knode1 ~]# cat <<EOF > /etc/sysctl.d/k8s.conf
> net.bridge.bridge-nf-call-ip6tables = 1
> net.bridge.bridge-nf-call-iptables = 1
> net.ipv4.ip_forward = 1
> EOF
[root@knode1 ~]# sysctl -p /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1

[root@knode2 ~]# cat <<EOF > /etc/sysctl.d/k8s.conf
> net.bridge.bridge-nf-call-ip6tables = 1
> net.bridge.bridge-nf-call-iptables = 1
> net.ipv4.ip_forward = 1
> EOF
[root@knode2 ~]# sysctl -p /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1

8、修改 containerd 镜像源

[root@kmaster ~]# containerd config default > /etc/containerd/config.toml
[root@kmaster ~]# sed -i "s#registry.k8s.io/pause#registry.aliyuncs.com/google_containers/pause#g" /etc/containerd/config.toml
[root@kmaster ~]# grep sandbox_image /etc/containerd/config.toml
    sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.6"

[root@knode1 ~]# containerd config default > /etc/containerd/config.toml
[root@knode1 ~]# sed -i "s#registry.k8s.io/pause#registry.aliyuncs.com/google_containers/pause#g" /etc/containerd/config.toml
[root@knode1 ~]# grep sandbox_image /etc/containerd/config.toml
    sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.6"

[root@knode2 ~]# containerd config default > /etc/containerd/config.toml
[root@knode2 ~]# sed -i "s#registry.k8s.io/pause#registry.aliyuncs.com/google_containers/pause#g" /etc/containerd/config.toml
[root@knode2 ~]# grep sandbox_image /etc/containerd/config.toml
    sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.6"

9、配置 systemd cgroup 驱动

[root@kmaster ~]# sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
[root@kmaster ~]# systemctl restart containerd
[root@kmaster ~]# grep SystemdCgroup /etc/containerd/config.toml
            SystemdCgroup = true

[root@knode1 ~]# sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
[root@knode1 ~]# systemctl restart containerd
[root@knode1 ~]# grep SystemdCgroup /etc/containerd/config.toml
            SystemdCgroup = true

[root@knode2 ~]# sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
[root@knode2 ~]# systemctl restart containerd
[root@knode2 ~]# grep SystemdCgroup /etc/containerd/config.toml
            SystemdCgroup = true

10、添加 k8s 源文件

[root@kmaster ~]# 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=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

[root@knode1 ~]# 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=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

[root@knode2 ~]# 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=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF

三、集群搭建

1、安装Kube工具

[root@kmaster ~]# yum install -y kubelet-1.26.0 kubeadm-1.26.0 kubectl-1.26.0 --disableexcludes=kubernetes
Kubernetes                                                                                                   1.9 kB/s | 454  B     00:00    
Kubernetes                                                                                                    19 kB/s | 2.6 kB     00:00    
Importing GPG key 0x13EDEF05:
 Userid     : "Rapture Automatic Signing Key (cloud-rapture-signing-key-2022-03-07-08_01_01.pub)"
 Fingerprint: A362 B822 F6DE DC65 2817 EA46 B53D C80D 13ED EF05
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Importing GPG key 0xDC6315A3:
 Userid     : "Artifact Registry Repository Signer <artifact-registry-repository-signer@google.com>"
 Fingerprint: 35BA A0B3 3E9E B396 F59C A838 C0BA 5CE6 DC63 15A3
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Kubernetes                                                                                                   7.9 kB/s | 975  B     00:00    
Importing GPG key 0x3E1BA8D5:
 Userid     : "Google Cloud Packages RPM Signing Key <gc-team@google.com>"
 Fingerprint: 3749 E1BA 95A8 6CE0 5454 6ED2 F09C 394C 3E1B A8D5
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
Kubernetes                                                                                                   267 kB/s | 172 kB     00:00    
Dependencies resolved.
=============================================================================================================================================
 Package                                   Architecture              Version                             Repository                     Size
=============================================================================================================================================
Installing:
 kubeadm                                   x86_64                    1.26.0-0                            kubernetes                     10 M
 kubectl                                   x86_64                    1.26.0-0                            kubernetes                     11 M
 kubelet                                   x86_64                    1.26.0-0                            kubernetes                     22 M
Installing dependencies:
 conntrack-tools                           x86_64                    1.4.4-10.el8                        BaseOS                        204 k
 cri-tools                                 x86_64                    1.26.0-0                            kubernetes                    8.6 M
 kubernetes-cni                            x86_64                    1.2.0-0                             kubernetes                     17 M
 libnetfilter_cthelper                     x86_64                    1.0.0-15.el8                        BaseOS                         24 k
 libnetfilter_cttimeout                    x86_64                    1.0.0-11.el8                        BaseOS                         24 k
 libnetfilter_queue                        x86_64                    1.0.4-3.el8                         BaseOS                         31 k
 socat                                     x86_64                    1.7.4.1-1.el8                       AppStream                     323 k

Transaction Summary
=============================================================================================================================================
Install  10 Packages

Total download size: 69 M
Installed size: 296 M
Downloading Packages:
(1/10): libnetfilter_cthelper-1.0.0-15.el8.x86_64.rpm                                                        1.0 MB/s |  24 kB     00:00    
(2/10): conntrack-tools-1.4.4-10.el8.x86_64.rpm                                                              6.9 MB/s | 204 kB     00:00    
(3/10): socat-1.7.4.1-1.el8.x86_64.rpm                                                                       9.3 MB/s | 323 kB     00:00    
(4/10): libnetfilter_queue-1.0.4-3.el8.x86_64.rpm                                                            4.2 MB/s |  31 kB     00:00    
(5/10): libnetfilter_cttimeout-1.0.0-11.el8.x86_64.rpm                                                       1.3 MB/s |  24 kB     00:00    
(6/10): 3f5ba2b53701ac9102ea7c7ab2ca6616a8cd5966591a77577585fde1c434ef74-cri-tools-1.26.0-0.x86_64.rpm       310 kB/s | 8.6 MB     00:28    
(7/10): da58cbf31a0337a968e5a06cfcc00eee420cc2df8930ea817ed2a4227bd81d48-kubeadm-1.26.0-0.x86_64.rpm         318 kB/s |  10 MB     00:33    
(8/10): 23e112935127da08ffd1c32c392cbf62346305ee97ba6c5d070cda422945e4ff-kubectl-1.26.0-0.x86_64.rpm         302 kB/s |  11 MB     00:36    
(9/10): 0f2a2afd740d476ad77c508847bad1f559afc2425816c1f2ce4432a62dfe0b9d-kubernetes-cni-1.2.0-0.x86_64.rpm   279 kB/s |  17 MB     01:01    
(10/10): 9be8590c2de60e249f40726e979a3a7a046320079bc41d330834de74f5399383-kubelet-1.26.0-0.x86_64.rpm        286 kB/s |  22 MB     01:18    
---------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                        662 kB/s |  69 MB     01:46     
Kubernetes                                                                                                    22 kB/s | 2.6 kB     00:00    
Importing GPG key 0x13EDEF05:
 Userid     : "Rapture Automatic Signing Key (cloud-rapture-signing-key-2022-03-07-08_01_01.pub)"
 Fingerprint: A362 B822 F6DE DC65 2817 EA46 B53D C80D 13ED EF05
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Key imported successfully
Importing GPG key 0xDC6315A3:
 Userid     : "Artifact Registry Repository Signer <artifact-registry-repository-signer@google.com>"
 Fingerprint: 35BA A0B3 3E9E B396 F59C A838 C0BA 5CE6 DC63 15A3
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Key imported successfully
Kubernetes                                                                                                   7.6 kB/s | 975  B     00:00    
Importing GPG key 0x3E1BA8D5:
 Userid     : "Google Cloud Packages RPM Signing Key <gc-team@google.com>"
 Fingerprint: 3749 E1BA 95A8 6CE0 5454 6ED2 F09C 394C 3E1B A8D5
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                     1/1 
  Installing       : kubectl-1.26.0-0.x86_64                                                                                            1/10 
  Installing       : cri-tools-1.26.0-0.x86_64                                                                                          2/10 
  Installing       : libnetfilter_queue-1.0.4-3.el8.x86_64                                                                              3/10 
  Running scriptlet: libnetfilter_queue-1.0.4-3.el8.x86_64                                                                              3/10 
  Installing       : libnetfilter_cttimeout-1.0.0-11.el8.x86_64                                                                         4/10 
  Running scriptlet: libnetfilter_cttimeout-1.0.0-11.el8.x86_64                                                                         4/10 
  Installing       : libnetfilter_cthelper-1.0.0-15.el8.x86_64                                                                          5/10 
  Running scriptlet: libnetfilter_cthelper-1.0.0-15.el8.x86_64                                                                          5/10 
  Installing       : conntrack-tools-1.4.4-10.el8.x86_64                                                                                6/10 
  Running scriptlet: conntrack-tools-1.4.4-10.el8.x86_64                                                                                6/10 
  Installing       : socat-1.7.4.1-1.el8.x86_64                                                                                         7/10 
  Installing       : kubernetes-cni-1.2.0-0.x86_64                                                                                      8/10 
  Installing       : kubelet-1.26.0-0.x86_64                                                                                            9/10 
  Installing       : kubeadm-1.26.0-0.x86_64                                                                                           10/10 
  Running scriptlet: kubeadm-1.26.0-0.x86_64                                                                                           10/10 
  Verifying        : socat-1.7.4.1-1.el8.x86_64                                                                                         1/10 
  Verifying        : conntrack-tools-1.4.4-10.el8.x86_64                                                                                2/10 
  Verifying        : libnetfilter_cthelper-1.0.0-15.el8.x86_64                                                                          3/10 
  Verifying        : libnetfilter_cttimeout-1.0.0-11.el8.x86_64                                                                         4/10 
  Verifying        : libnetfilter_queue-1.0.4-3.el8.x86_64                                                                              5/10 
  Verifying        : cri-tools-1.26.0-0.x86_64                                                                                          6/10 
  Verifying        : kubeadm-1.26.0-0.x86_64                                                                                            7/10 
  Verifying        : kubectl-1.26.0-0.x86_64                                                                                            8/10 
  Verifying        : kubelet-1.26.0-0.x86_64                                                                                            9/10 
  Verifying        : kubernetes-cni-1.2.0-0.x86_64                                                                                     10/10 

Installed:
  conntrack-tools-1.4.4-10.el8.x86_64            cri-tools-1.26.0-0.x86_64                       kubeadm-1.26.0-0.x86_64                   
  kubectl-1.26.0-0.x86_64                        kubelet-1.26.0-0.x86_64                         kubernetes-cni-1.2.0-0.x86_64             
  libnetfilter_cthelper-1.0.0-15.el8.x86_64      libnetfilter_cttimeout-1.0.0-11.el8.x86_64      libnetfilter_queue-1.0.4-3.el8.x86_64     
  socat-1.7.4.1-1.el8.x86_64                    

Complete!

[root@knode1 ~]# yum install -y kubelet-1.26.0 kubeadm-1.26.0 kubectl-1.26.0 --disableexcludes=kubernetes
Kubernetes                                                                                                   1.9 kB/s | 454  B     00:00    
Kubernetes                                                                                                    16 kB/s | 2.6 kB     00:00    
Importing GPG key 0x13EDEF05:
 Userid     : "Rapture Automatic Signing Key (cloud-rapture-signing-key-2022-03-07-08_01_01.pub)"
 Fingerprint: A362 B822 F6DE DC65 2817 EA46 B53D C80D 13ED EF05
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Importing GPG key 0xDC6315A3:
 Userid     : "Artifact Registry Repository Signer <artifact-registry-repository-signer@google.com>"
 Fingerprint: 35BA A0B3 3E9E B396 F59C A838 C0BA 5CE6 DC63 15A3
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Kubernetes                                                                                                   6.9 kB/s | 975  B     00:00    
Importing GPG key 0x3E1BA8D5:
 Userid     : "Google Cloud Packages RPM Signing Key <gc-team@google.com>"
 Fingerprint: 3749 E1BA 95A8 6CE0 5454 6ED2 F09C 394C 3E1B A8D5
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
Kubernetes                                                                                                   241 kB/s | 172 kB     00:00    
Dependencies resolved.
=============================================================================================================================================
 Package                                   Architecture              Version                             Repository                     Size
=============================================================================================================================================
Installing:
 kubeadm                                   x86_64                    1.26.0-0                            kubernetes                     10 M
 kubectl                                   x86_64                    1.26.0-0                            kubernetes                     11 M
 kubelet                                   x86_64                    1.26.0-0                            kubernetes                     22 M
Installing dependencies:
 conntrack-tools                           x86_64                    1.4.4-10.el8                        BaseOS                        204 k
 cri-tools                                 x86_64                    1.26.0-0                            kubernetes                    8.6 M
 kubernetes-cni                            x86_64                    1.2.0-0                             kubernetes                     17 M
 libnetfilter_cthelper                     x86_64                    1.0.0-15.el8                        BaseOS                         24 k
 libnetfilter_cttimeout                    x86_64                    1.0.0-11.el8                        BaseOS                         24 k
 libnetfilter_queue                        x86_64                    1.0.4-3.el8                         BaseOS                         31 k
 socat                                     x86_64                    1.7.4.1-1.el8                       AppStream                     323 k

Transaction Summary
=============================================================================================================================================
Install  10 Packages

Total download size: 69 M
Installed size: 296 M
Downloading Packages:
(1/10): libnetfilter_cthelper-1.0.0-15.el8.x86_64.rpm                                                        1.0 MB/s |  24 kB     00:00    
(2/10): conntrack-tools-1.4.4-10.el8.x86_64.rpm                                                              7.1 MB/s | 204 kB     00:00    
(3/10): libnetfilter_cttimeout-1.0.0-11.el8.x86_64.rpm                                                       3.3 MB/s |  24 kB     00:00    
(4/10): socat-1.7.4.1-1.el8.x86_64.rpm                                                                       9.0 MB/s | 323 kB     00:00    
(5/10): libnetfilter_queue-1.0.4-3.el8.x86_64.rpm                                                            3.4 MB/s |  31 kB     00:00    
(6/10): 3f5ba2b53701ac9102ea7c7ab2ca6616a8cd5966591a77577585fde1c434ef74-cri-tools-1.26.0-0.x86_64.rpm       283 kB/s | 8.6 MB     00:31    
(7/10): da58cbf31a0337a968e5a06cfcc00eee420cc2df8930ea817ed2a4227bd81d48-kubeadm-1.26.0-0.x86_64.rpm         298 kB/s |  10 MB     00:35    
(8/10): 23e112935127da08ffd1c32c392cbf62346305ee97ba6c5d070cda422945e4ff-kubectl-1.26.0-0.x86_64.rpm         279 kB/s |  11 MB     00:39    
(9/10): 0f2a2afd740d476ad77c508847bad1f559afc2425816c1f2ce4432a62dfe0b9d-kubernetes-cni-1.2.0-0.x86_64.rpm   277 kB/s |  17 MB     01:02    
(10/10): 9be8590c2de60e249f40726e979a3a7a046320079bc41d330834de74f5399383-kubelet-1.26.0-0.x86_64.rpm        267 kB/s |  22 MB     01:23    
---------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                        615 kB/s |  69 MB     01:54     
Kubernetes                                                                                                    22 kB/s | 2.6 kB     00:00    
Importing GPG key 0x13EDEF05:
 Userid     : "Rapture Automatic Signing Key (cloud-rapture-signing-key-2022-03-07-08_01_01.pub)"
 Fingerprint: A362 B822 F6DE DC65 2817 EA46 B53D C80D 13ED EF05
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Key imported successfully
Importing GPG key 0xDC6315A3:
 Userid     : "Artifact Registry Repository Signer <artifact-registry-repository-signer@google.com>"
 Fingerprint: 35BA A0B3 3E9E B396 F59C A838 C0BA 5CE6 DC63 15A3
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Key imported successfully
Kubernetes                                                                                                    11 kB/s | 975  B     00:00    
Importing GPG key 0x3E1BA8D5:
 Userid     : "Google Cloud Packages RPM Signing Key <gc-team@google.com>"
 Fingerprint: 3749 E1BA 95A8 6CE0 5454 6ED2 F09C 394C 3E1B A8D5
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                     1/1 
  Installing       : kubectl-1.26.0-0.x86_64                                                                                            1/10 
  Installing       : cri-tools-1.26.0-0.x86_64                                                                                          2/10 
  Installing       : libnetfilter_queue-1.0.4-3.el8.x86_64                                                                              3/10 
  Running scriptlet: libnetfilter_queue-1.0.4-3.el8.x86_64                                                                              3/10 
  Installing       : libnetfilter_cttimeout-1.0.0-11.el8.x86_64                                                                         4/10 
  Running scriptlet: libnetfilter_cttimeout-1.0.0-11.el8.x86_64                                                                         4/10 
  Installing       : libnetfilter_cthelper-1.0.0-15.el8.x86_64                                                                          5/10 
  Running scriptlet: libnetfilter_cthelper-1.0.0-15.el8.x86_64                                                                          5/10 
  Installing       : conntrack-tools-1.4.4-10.el8.x86_64                                                                                6/10 
  Running scriptlet: conntrack-tools-1.4.4-10.el8.x86_64                                                                                6/10 
  Installing       : socat-1.7.4.1-1.el8.x86_64                                                                                         7/10 
  Installing       : kubernetes-cni-1.2.0-0.x86_64                                                                                      8/10 
  Installing       : kubelet-1.26.0-0.x86_64                                                                                            9/10 
  Installing       : kubeadm-1.26.0-0.x86_64                                                                                           10/10 
  Running scriptlet: kubeadm-1.26.0-0.x86_64                                                                                           10/10 
  Verifying        : socat-1.7.4.1-1.el8.x86_64                                                                                         1/10 
  Verifying        : conntrack-tools-1.4.4-10.el8.x86_64                                                                                2/10 
  Verifying        : libnetfilter_cthelper-1.0.0-15.el8.x86_64                                                                          3/10 
  Verifying        : libnetfilter_cttimeout-1.0.0-11.el8.x86_64                                                                         4/10 
  Verifying        : libnetfilter_queue-1.0.4-3.el8.x86_64                                                                              5/10 
  Verifying        : cri-tools-1.26.0-0.x86_64                                                                                          6/10 
  Verifying        : kubeadm-1.26.0-0.x86_64                                                                                            7/10 
  Verifying        : kubectl-1.26.0-0.x86_64                                                                                            8/10 
  Verifying        : kubelet-1.26.0-0.x86_64                                                                                            9/10 
  Verifying        : kubernetes-cni-1.2.0-0.x86_64                                                                                     10/10 

Installed:
  conntrack-tools-1.4.4-10.el8.x86_64            cri-tools-1.26.0-0.x86_64                       kubeadm-1.26.0-0.x86_64                   
  kubectl-1.26.0-0.x86_64                        kubelet-1.26.0-0.x86_64                         kubernetes-cni-1.2.0-0.x86_64             
  libnetfilter_cthelper-1.0.0-15.el8.x86_64      libnetfilter_cttimeout-1.0.0-11.el8.x86_64      libnetfilter_queue-1.0.4-3.el8.x86_64     
  socat-1.7.4.1-1.el8.x86_64                    

Complete!

[root@knode2 ~]# yum install -y kubelet-1.26.0 kubeadm-1.26.0 kubectl-1.26.0 --disableexcludes=kubernetes
Kubernetes                                                                                                   1.0 kB/s | 454  B     00:00    
Kubernetes                                                                                                    27 kB/s | 2.6 kB     00:00    
Importing GPG key 0x13EDEF05:
 Userid     : "Rapture Automatic Signing Key (cloud-rapture-signing-key-2022-03-07-08_01_01.pub)"
 Fingerprint: A362 B822 F6DE DC65 2817 EA46 B53D C80D 13ED EF05
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Importing GPG key 0xDC6315A3:
 Userid     : "Artifact Registry Repository Signer <artifact-registry-repository-signer@google.com>"
 Fingerprint: 35BA A0B3 3E9E B396 F59C A838 C0BA 5CE6 DC63 15A3
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Kubernetes                                                                                                   8.7 kB/s | 975  B     00:00    
Importing GPG key 0x3E1BA8D5:
 Userid     : "Google Cloud Packages RPM Signing Key <gc-team@google.com>"
 Fingerprint: 3749 E1BA 95A8 6CE0 5454 6ED2 F09C 394C 3E1B A8D5
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
Kubernetes                                                                                                   271 kB/s | 172 kB     00:00    
Dependencies resolved.
=============================================================================================================================================
 Package                                   Architecture              Version                             Repository                     Size
=============================================================================================================================================
Installing:
 kubeadm                                   x86_64                    1.26.0-0                            kubernetes                     10 M
 kubectl                                   x86_64                    1.26.0-0                            kubernetes                     11 M
 kubelet                                   x86_64                    1.26.0-0                            kubernetes                     22 M
Installing dependencies:
 conntrack-tools                           x86_64                    1.4.4-10.el8                        BaseOS                        204 k
 cri-tools                                 x86_64                    1.26.0-0                            kubernetes                    8.6 M
 kubernetes-cni                            x86_64                    1.2.0-0                             kubernetes                     17 M
 libnetfilter_cthelper                     x86_64                    1.0.0-15.el8                        BaseOS                         24 k
 libnetfilter_cttimeout                    x86_64                    1.0.0-11.el8                        BaseOS                         24 k
 libnetfilter_queue                        x86_64                    1.0.4-3.el8                         BaseOS                         31 k
 socat                                     x86_64                    1.7.4.1-1.el8                       AppStream                     323 k

Transaction Summary
=============================================================================================================================================
Install  10 Packages

Total download size: 69 M
Installed size: 296 M
Downloading Packages:
(1/10): libnetfilter_cthelper-1.0.0-15.el8.x86_64.rpm                                                        1.0 MB/s |  24 kB     00:00    
(2/10): conntrack-tools-1.4.4-10.el8.x86_64.rpm                                                              7.4 MB/s | 204 kB     00:00    
(3/10): libnetfilter_cttimeout-1.0.0-11.el8.x86_64.rpm                                                       2.5 MB/s |  24 kB     00:00    
(4/10): libnetfilter_queue-1.0.4-3.el8.x86_64.rpm                                                            3.6 MB/s |  31 kB     00:00    
(5/10): socat-1.7.4.1-1.el8.x86_64.rpm                                                                       8.1 MB/s | 323 kB     00:00    
(6/10): 3f5ba2b53701ac9102ea7c7ab2ca6616a8cd5966591a77577585fde1c434ef74-cri-tools-1.26.0-0.x86_64.rpm       311 kB/s | 8.6 MB     00:28    
(7/10): da58cbf31a0337a968e5a06cfcc00eee420cc2df8930ea817ed2a4227bd81d48-kubeadm-1.26.0-0.x86_64.rpm         306 kB/s |  10 MB     00:34    
(8/10): 23e112935127da08ffd1c32c392cbf62346305ee97ba6c5d070cda422945e4ff-kubectl-1.26.0-0.x86_64.rpm         301 kB/s |  11 MB     00:36    
(9/10): 0f2a2afd740d476ad77c508847bad1f559afc2425816c1f2ce4432a62dfe0b9d-kubernetes-cni-1.2.0-0.x86_64.rpm   269 kB/s |  17 MB     01:04    
(10/10): 9be8590c2de60e249f40726e979a3a7a046320079bc41d330834de74f5399383-kubelet-1.26.0-0.x86_64.rpm        284 kB/s |  22 MB     01:18    
---------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                        660 kB/s |  69 MB     01:46     
Kubernetes                                                                                                    14 kB/s | 2.6 kB     00:00    
Importing GPG key 0x13EDEF05:
 Userid     : "Rapture Automatic Signing Key (cloud-rapture-signing-key-2022-03-07-08_01_01.pub)"
 Fingerprint: A362 B822 F6DE DC65 2817 EA46 B53D C80D 13ED EF05
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Key imported successfully
Importing GPG key 0xDC6315A3:
 Userid     : "Artifact Registry Repository Signer <artifact-registry-repository-signer@google.com>"
 Fingerprint: 35BA A0B3 3E9E B396 F59C A838 C0BA 5CE6 DC63 15A3
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
Key imported successfully
Kubernetes                                                                                                   8.2 kB/s | 975  B     00:00    
Importing GPG key 0x3E1BA8D5:
 Userid     : "Google Cloud Packages RPM Signing Key <gc-team@google.com>"
 Fingerprint: 3749 E1BA 95A8 6CE0 5454 6ED2 F09C 394C 3E1B A8D5
 From       : https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                     1/1 
  Installing       : kubectl-1.26.0-0.x86_64                                                                                            1/10 
  Installing       : cri-tools-1.26.0-0.x86_64                                                                                          2/10 
  Installing       : libnetfilter_queue-1.0.4-3.el8.x86_64                                                                              3/10 
  Running scriptlet: libnetfilter_queue-1.0.4-3.el8.x86_64                                                                              3/10 
  Installing       : libnetfilter_cttimeout-1.0.0-11.el8.x86_64                                                                         4/10 
  Running scriptlet: libnetfilter_cttimeout-1.0.0-11.el8.x86_64                                                                         4/10 
  Installing       : libnetfilter_cthelper-1.0.0-15.el8.x86_64                                                                          5/10 
  Running scriptlet: libnetfilter_cthelper-1.0.0-15.el8.x86_64                                                                          5/10 
  Installing       : conntrack-tools-1.4.4-10.el8.x86_64                                                                                6/10 
  Running scriptlet: conntrack-tools-1.4.4-10.el8.x86_64                                                                                6/10 
  Installing       : socat-1.7.4.1-1.el8.x86_64                                                                                         7/10 
  Installing       : kubernetes-cni-1.2.0-0.x86_64                                                                                      8/10 
  Installing       : kubelet-1.26.0-0.x86_64                                                                                            9/10 
  Installing       : kubeadm-1.26.0-0.x86_64                                                                                           10/10 
  Running scriptlet: kubeadm-1.26.0-0.x86_64                                                                                           10/10 
  Verifying        : socat-1.7.4.1-1.el8.x86_64                                                                                         1/10 
  Verifying        : conntrack-tools-1.4.4-10.el8.x86_64                                                                                2/10 
  Verifying        : libnetfilter_cthelper-1.0.0-15.el8.x86_64                                                                          3/10 
  Verifying        : libnetfilter_cttimeout-1.0.0-11.el8.x86_64                                                                         4/10 
  Verifying        : libnetfilter_queue-1.0.4-3.el8.x86_64                                                                              5/10 
  Verifying        : cri-tools-1.26.0-0.x86_64                                                                                          6/10 
  Verifying        : kubeadm-1.26.0-0.x86_64                                                                                            7/10 
  Verifying        : kubectl-1.26.0-0.x86_64                                                                                            8/10 
  Verifying        : kubelet-1.26.0-0.x86_64                                                                                            9/10 
  Verifying        : kubernetes-cni-1.2.0-0.x86_64                                                                                     10/10 

Installed:
  conntrack-tools-1.4.4-10.el8.x86_64            cri-tools-1.26.0-0.x86_64                       kubeadm-1.26.0-0.x86_64                   
  kubectl-1.26.0-0.x86_64                        kubelet-1.26.0-0.x86_64                         kubernetes-cni-1.2.0-0.x86_64             
  libnetfilter_cthelper-1.0.0-15.el8.x86_64      libnetfilter_cttimeout-1.0.0-11.el8.x86_64      libnetfilter_queue-1.0.4-3.el8.x86_64     
  socat-1.7.4.1-1.el8.x86_64                    

Complete!

2、初始化集群(只需要master节点)

[root@kmaster ~]# kubeadm init --image-repository registry.aliyuncs.com/google_containers --kubernetes-version=v1.26.0 --pod-network-cidr=10.244.0.0/16
[init] Using Kubernetes version: v1.26.0
[preflight] Running pre-flight checks
	[WARNING FileExisting-tc]: tc not found in system path
	[WARNING Service-Kubelet]: kubelet service is not enabled, please run 'systemctl enable kubelet.service'
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [kmaster kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.100.180]
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "front-proxy-ca" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/ca" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [kmaster localhost] and IPs [192.168.100.180 127.0.0.1 ::1]
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [kmaster localhost] and IPs [192.168.100.180 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "sa" key and public key
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Starting the kubelet
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[apiclient] All control plane components are healthy after 6.001565 seconds
[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
[kubelet] Creating a ConfigMap "kubelet-config" in namespace kube-system with the configuration for the kubelets in the cluster
[upload-certs] Skipping phase. Please see --upload-certs
[mark-control-plane] Marking the node kmaster as control-plane by adding the labels: [node-role.kubernetes.io/control-plane node.kubernetes.io/exclude-from-external-load-balancers]
[mark-control-plane] Marking the node kmaster as control-plane by adding the taints [node-role.kubernetes.io/control-plane:NoSchedule]
[bootstrap-token] Using token: weeweh.39qt15mksqv3kobq
[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles
[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to get nodes
[bootstrap-token] Configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
[bootstrap-token] Configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
[bootstrap-token] Configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
[bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace
[kubelet-finalize] Updating "/etc/kubernetes/kubelet.conf" to point to a rotatable kubelet client certificate and key
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxy

Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

Alternatively, if you are the root user, you can run:

  export KUBECONFIG=/etc/kubernetes/admin.conf

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 192.168.100.180:6443 --token weeweh.39qt15mksqv3kobq \
	--discovery-token-ca-cert-hash sha256:6cce64581fa04e81c917f51cdc2623891463e0ac619dc62a88a1b3f8bab90ba0 

3、配置环境变量

[root@kmaster ~]# mkdir -p $HOME/.kube
[root@kmaster ~]# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
[root@kmaster ~]# sudo chown $(id -u):$(id -g) $HOME/.kube/config
[root@kmaster ~]# echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
[root@kmaster ~]# source  ~/.bash_profile
[root@kmaster ~]# kubectl get node
NAME      STATUS     ROLES           AGE   VERSION
kmaster   NotReady   control-plane   90s   v1.26.0

4、将节点加入集群

[root@knode1 ~]# kubeadm join 192.168.100.180:6443 --token weeweh.39qt15mksqv3kobq --discovery-token-ca-cert-hash sha256:6cce64581fa04e81c917f51cdc2623891463e0ac619dc62a88a1b3f8bab90ba0
[preflight] Running pre-flight checks
	[WARNING FileExisting-tc]: tc not found in system path
	[WARNING Service-Kubelet]: kubelet service is not enabled, please run 'systemctl enable kubelet.service'
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Starting the kubelet
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...

This node has joined the cluster:
* Certificate signing request was sent to apiserver and a response was received.
* The Kubelet was informed of the new secure connection details.

Run 'kubectl get nodes' on the control-plane to see this node join the cluster.

[root@knode2 ~]# kubeadm join 192.168.100.180:6443 --token weeweh.39qt15mksqv3kobq --discovery-token-ca-cert-hash sha256:6cce64581fa04e81c917f51cdc2623891463e0ac619dc62a88a1b3f8bab90ba0
[preflight] Running pre-flight checks
	[WARNING FileExisting-tc]: tc not found in system path
	[WARNING Service-Kubelet]: kubelet service is not enabled, please run 'systemctl enable kubelet.service'
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Starting the kubelet
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...

This node has joined the cluster:
* Certificate signing request was sent to apiserver and a response was received.
* The Kubelet was informed of the new secure connection details.

Run 'kubectl get nodes' on the control-plane to see this node join the cluster.

[root@kmaster ~]# kubectl get node
NAME      STATUS     ROLES           AGE     VERSION
kmaster   NotReady   control-plane   3m11s   v1.26.0
knode1    NotReady   <none>          37s     v1.26.0
knode2    NotReady   <none>          30s     v1.26.0

如果忘记加入集群链接可以用命令再次生成加入链接
kubeadm token create --print-join-command

5、修改默认端点连接

# 默认情况下,通过 crictl img 命令查询镜像会报错,因为 crictl 命令默认会去找 /var/run/dockershim.sock 文件,而自 1.24 版本起,Dockershim 已从 Kubernetes 项目中移除,找不到对应的文件所以报错。
[root@kmaster ~]# vim /etc/crictl.yaml
[root@kmaster ~]# cat /etc/crictl.yaml 
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 5
debug: false
[root@kmaster ~]# crictl img
IMAGE                                                             TAG                 IMAGE ID            SIZE
registry.aliyuncs.com/google_containers/coredns                   v1.9.3              5185b96f0becf       14.8MB
registry.aliyuncs.com/google_containers/etcd                      3.5.6-0             fce326961ae2d       103MB
registry.aliyuncs.com/google_containers/kube-apiserver            v1.26.0             a31e1d84401e6       35.3MB
registry.aliyuncs.com/google_containers/kube-controller-manager   v1.26.0             5d7c5dfd3ba18       32.2MB
registry.aliyuncs.com/google_containers/kube-proxy                v1.26.0             556768f31eb1d       21.5MB
registry.aliyuncs.com/google_containers/kube-scheduler            v1.26.0             dafd8ad70b156       17.5MB
registry.aliyuncs.com/google_containers/pause                     3.6                 6270bb605e12e       302kB
registry.aliyuncs.com/google_containers/pause                     3.9                 e6f1816883972       322kB

[root@kmaster ~]# scp -r /etc/crictl.yaml root@192.168.100.181:/etc
root@192.168.100.181's password: 
crictl.yaml                                                                                                100%  136   386.3KB/s   00:00    
[root@kmaster ~]# scp -r /etc/crictl.yaml root@192.168.100.182:/etc
root@192.168.100.182's password: 
crictl.yaml                                                                                                100%  136   353.0KB/s   00:00    

6、安装 calico 网络

[root@kmaster ~]# kubectl get node
NAME      STATUS     ROLES           AGE     VERSION
kmaster   NotReady   control-plane   8m49s   v1.26.0
knode1    NotReady   <none>          6m15s   v1.26.0
knode2    NotReady   <none>          6m8s    v1.26.0

# 安装 Tigera Calico operator
[root@kmaster ~]# wget https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/tigera-operator.yaml
--2023-05-18 15:23:40--  https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/tigera-operator.yaml
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 185.199.108.133, 185.199.109.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1230469 (1.2M) [text/plain]
Saving to: ‘tigera-operator.yaml’

tigera-operator.yaml                100%[================================================================>]   1.17M  11.8KB/s    in 1m 42s  

2023-05-18 15:25:24 (11.8 KB/s) - ‘tigera-operator.yaml’ saved [1230469/1230469]
[root@kmaster ~]# kubectl create -f tigera-operator.yaml
namespace/tigera-operator created
customresourcedefinition.apiextensions.k8s.io/bgpconfigurations.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/bgppeers.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/blockaffinities.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/caliconodestatuses.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/clusterinformations.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/felixconfigurations.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/globalnetworkpolicies.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/globalnetworksets.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/hostendpoints.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/ipamblocks.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/ipamconfigs.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/ipamhandles.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/ippools.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/ipreservations.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/kubecontrollersconfigurations.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/networkpolicies.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/networksets.crd.projectcalico.org created
customresourcedefinition.apiextensions.k8s.io/apiservers.operator.tigera.io created
customresourcedefinition.apiextensions.k8s.io/imagesets.operator.tigera.io created
customresourcedefinition.apiextensions.k8s.io/installations.operator.tigera.io created
customresourcedefinition.apiextensions.k8s.io/tigerastatuses.operator.tigera.io created
serviceaccount/tigera-operator created
clusterrole.rbac.authorization.k8s.io/tigera-operator created
clusterrolebinding.rbac.authorization.k8s.io/tigera-operator created
deployment.apps/tigera-operator created

# 配置 custom-resources.yaml
[root@kmaster ~]# wget https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/custom-resources.yaml
[root@kmaster ~]# vim custom-resources.yaml
#更改IP地址池中的 CIDR,和 kubeadm 初始化集群中的 --pod-network-cidr 参数保持一致
cidr: 10.244.0.0/16
[root@kmaster ~]# kubectl create -f custom-resources.yaml
installation.operator.tigera.io/default created
apiserver.operator.tigera.io/default created

[root@kmaster ~]# kubectl get node
NAME      STATUS   ROLES           AGE   VERSION
kmaster   Ready    control-plane   19m   v1.26.0
knode1    Ready    <none>          16m   v1.26.0
knode2    Ready    <none>          16m   v1.26.0

四、集群测试

# 创建nginx服务
[root@kmaster ~]# kubectl create deployment nginx  --image=nginx:1.14-alpine
deployment.apps/nginx created
# 暴露端口
[root@kmaster ~]# kubectl expose deploy nginx  --port=80 --target-port=80  --type=NodePort
service/nginx exposed
# 查看服务
[root@kmaster ~]# kubectl get pod,svc
NAME                         READY   STATUS    RESTARTS   AGE
pod/nginx-6db6dff665-8rd29   1/1     Running   0          85s

NAME                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
service/kubernetes   ClusterIP   10.96.0.1        <none>        443/TCP        24m
service/nginx        NodePort    10.110.168.191   <none>        80:30647/TCP   21s
# 查看pod
[root@kmaster ~]# kubectl get pod
NAME                     READY   STATUS    RESTARTS   AGE
nginx-6db6dff665-8rd29   1/1     Running   0          108s
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值