香港服务器便宜kubernetes1.31.3集群搭建(上)

阿里云服务器云盾关闭 1 集群规划 1.1 物理机环境 电脑 操作系统 CPU 内存 硬盘 网卡 IP地址(静态) 虚拟机软件 服务器操作

阿里云服务器云盾关闭

1 集群规划

1.1 物理机环境

电脑

操作系统

CPU

内存

硬盘

网卡

IP地址(静态)

虚拟机软件

服务器操作系统

联想

Windows11

Intel 12900K 24核

128GB

4TB PcIE4.0

无线网卡

192.168.3.6

VMware WorkStation Pro 17.6.1

RockyLinux9.5

微星

Windows11

Intel 12900hx 24核

64GB

4TB PcIE4.0

无线网卡

192.168.3.197

VMware WorkStation Pro 17.6.1

RockyLinux9.5

1.3 K8S集群节点配置

电脑

节点

CPU

内存

硬盘

网络连接模式

IP地址

微星

k8s-master-1

8核

16G

200G

桥接模式

192.168.3.60

k8s-master-2

8核

16G

200G

桥接模式

192.168.3.61

k8s-master-3

8核

16G

200G

桥接模式

192.168.3.62

联想

k8s-node-1

16核

32G

200G

桥接模式

192.168.3.70

k8s-node-2

16核

32G

200G

桥接模式

192.168.3.71

k8s-node-3

16核

32G

200G

桥接模式

192.168.3.72

1.4 K8s版本

K8s版本:https://github.com/kubernetes/kubernetes/releases

目前主流的K8s版本有1.31、1.30、1.29、1.29、1.27五个大版本,本次我们选择1.31.3

测试环境可以选择最新的正式版本,例如选择1.31.3或者1.30.6生产环境为了稳定,建议选择小版本大于5的K8s版本,例如选择1.30.6

软件

版本

HA Proxy

HAProxy version 2.4.22-f8e3218

Keepliaved

Keepalived v2.2.8 (04/04,2023)

docker

docker-ce-3:27.3.1-1.el9.x86_64

containerd

containerd.io-1.7.24-3.1.el9.x86_64

K8s

戴尔云计算服务器

1.31.3

1.5 集群规划注意事项

网络配置

请确认你的IP地址、子网掩码和默认网关

合理使用虚拟机快照功能

K8s集群搭建大致分成15大步,如果不能确保K8s集群一次性搭建成功,那么建议每完成1大步拍摄快照,集群搭建失败时方便恢复快照

3 K8s节点基本配置及配置优化

3.1 所有节点配置yum源

https://developer.aliyun.com/mirror/rockylinux

sed-es|^mirrorlist=|mirrorlist=|g -es|^baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.aliyun.com/rockylinux|g -i.bak /etc/yum.repos.d/rocky*.repo
它会将所有以 mirrorlist= 开始的行注释掉(在行首添加一个 符号)。它会将所有原本被注释掉(以 baseurl=http://dl.rockylinux.org/$contentdir 开始)的行取消注释,并且更改 URL 为阿里云的镜像源地址 (https://mirrors.aliyun.com/rockylinux)。同时它会对每个被修改的文件创建一个备份,备份文件会在原文件名后加上 .bak 后缀。dnfmakecache

3.2 所有节点必备工具安装

dnfinstallwget jq psmisc vim net-tools telnet yum-utils device-mapper-persistent-datalvm2 git rsyslog -y

您正在尝试在基于Red Hat的系统(如CentOS或Fedora)上使用dnf包管理器来安装一系列软件包。以下是命令的解析:

wget: 用于从网络下载文件。jq: 用于处理JSON数据的命令行工具。psmisc: 包含一些进程管理工具,如killall。vim: 一个高度可配置的文本编辑器。net-tools: 包含网络配置工具,如ifconfig。telnet: 用于通过Telnet协议连接到远程主机。yum-utils: 提供一些辅助工具,如package-cleanup和repoquery。device-mapper-persistent-data : 是一个用于逻辑卷管理(LVM)和设备映射器(Device Mapper)的软件包。lvm2: 用于逻辑卷管理(LVM)的工具。git: 分布式版本控制系统。rsyslog: 增强的日志处理系统。

3.3 所有节点配置hosts

vim/etc/hosts
192.168.3.60k8s-master-01192.168.3.61k8s-master-02192.168.3.62k8s-master-03192.168.3.70k8s-node-01192.168.3.71k8s-node-02192.168.3.72k8s-node-03

修改完成后测试指定的主机名是否能够ping通,ping通过后使用Ctrl+c停止ping

pingk8s-master-02 -c 3pingk8s-master-03 -c 3pingk8s-node-01 -c 3pingk8s-node-02 -c 3pingk8s-node-03 -c 3

3.4 所有节点禁用防火墙、SELinux、swap分区

所有节点禁用防火墙systemctldisable--now firewalld
所有节点禁用SELinuxsetenforce0sed -is/SELINUX=enforcing/SELINUX=disabled/g/etc/selinux/configsed -is/SELINUX=enforcing/SELINUX=disabled/g/etc/sysconfig/selinux
所有节点禁用swap分区swapoff-a && sysctl -w vm.swappiness=0sed -ri/^[^]*swap/s@^@@/etc/fstab

3.5 所有节点开启rsyslog

systemctlenable--now rsyslog
tail -f /var/log/messages实时查看系统日志 使用Ctrl+C中断

3.6 所有节点同步时间

ntpdate方案和chrony方案二选一即可,我这里选ntpdate

3.6.1 ntpdate方案

安装并启用Extra Packages for Enterprise Linux (EPEL)仓库dnfinstallepel-release-y dnf config-manager--set-enable epel
安装ntpdatednfinstall ntpsec -y
配置时区为亚洲上海ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtimeechoAsia/Shanghai> /etc/timezone
连接阿里云的NTP服务器同步系统时间ntpdatetime2.aliyun.com
编辑当前用户的定时任务crontab-e
设置每5分钟连接到阿里云的NTP服务器 time2.aliyun.com 并同步系统时间*/5 ** ** /usr/sbin/ntpdate time2.aliyun.com

3.6.2 chrony方案(没有测试)

安装chrony (Rocky Linux 9 默认包含chrony)dnfinstall chrony
配置chrony使用NTP服务器

编辑 /etc/chrony.conf 文件来添加或修改 NTP 服务器。您可以选择公共 NTP 服务器或者使用阿里云提供的 NTP 服务器。

添加阿里云的 NTP 服务器

vim/etc/chrony.confpoolntp1.aliyun.comiburstpoolntp2.aliyun.comiburstpoolcn.pool.ntp.orgiburst
设置时区为亚洲上海timedatectlset-timezone Asia/Shanghai
启动并启用Chrony服务systemctlenable chronydsystemctlstart chronyd
验证chrony的工作状态chronyctracking查看本地系统时间与NTP服务器之间的偏移量
强制立即时间同步chronycmakestep

3.7 所有节点配置limit

ulimit-SHn 65535
vim/etc/security/limits.conf

在文件末尾添加如下内容

*soft nofile 65536*hard nofile 131072*soft nproc 65535*hard nproc 655350*soft memlock unlimited*hard memlock unlimited
nofile:控制单个进程可以打开的最大文件描述符数量。soft nofile 65536:软限制为 65536,表示普通情况下一个进程可以打开的最大文件数。hard nofile 131072:硬限制为 131072,表示即使有权限提升,一个进程最多也只能打开这么多文件。nproc:限制一个用户可以启动的最大进程数。soft nproc 65535:软限制为 65535,表示普通情况下该用户可以创建的最大进程数。hard nproc 655350:硬限制为 655350,表示即使有权限提升,该用户最多也只能创建这么多进程。memlock:设置最大锁定内存地址空间(以字节为单位),即允许程序锁定在物理内存中不被交换出去的数据量。soft memlock unlimited 和 hard memlock unlimited:意味着没有对锁定内存大小的限制,程序可以根据需要锁定任意量的内存。

3.8 所有节点所有已安装软件包到最新版本

此过程会比较耗时

dnfupdate -y

3.9 k8s-master-01节点免密码登录

k8s-master-01节点免密钥登录其他节点,安装过程中生成配置文件和证书均在Master01上操作,集群管理也在Master01上操作,阿里云或者AWS上需要单独一台kubectl服务器。

生成密钥ssh-keygen -t rsa

执行ssh-keygen -t rsa后回车三次

将本地的 SSH 公钥复制到多个远程主机上foriink8s-master-01 k8s-master-02 k8s-master-03 k8s-node-01 k8s-node-02 k8s-node-03;dossh-copy-id -i .ssh/id_rsa.pub$i;done

因为有6台服务器,需要输入6次yes和其他实例的密码

配置完成后从k8s-master-01使用ssh免密钥登录其他节点

sshk8s-master-02

按Ctrl+D退出

3.10 k8s-master-01节点下载安装文件

cd/root; gitclonehttps://gitee.com/boy_tony_cto/k8s-ha-install.git

K8s节点内核配置优化

4.1 所有节点安装ipvsadm

dnfinstall ipvsadm ipset sysstat conntrack libseccomp -y
ipvsadm:用于管理和配置 IP 虚拟服务器 (IPVS),它实现了 Linux 内核中的负载均衡功能。这对于设置高可用性和负载均衡集群非常有用。ipset:允许创建和管理 IP 地址或端口集合,可以与 iptables 结合使用来简化复杂的防火墙规则。sysstat:提供了一套工具用于监控系统性能,包括 CPU、内存、磁盘 I/O 和网络等资源的使用情况。常用的工具如 sar、iostat、mpstat 都属于这个套件。conntrack:用于查看和操作 netfilter/iptables 连接跟踪表,这对于调试和优化 NAT 或防火墙规则非常有帮助。libseccomp:是一个库,提供了简单易用的接口来限制应用程序的系统调用,增强了系统的安全性。

4.2 所有节点配置ipvs模块

modprobe-- ip_vsmodprobe-- ip_vs_rrmodprobe-- ip_vs_wrrmodprobe-- ip_vs_shmodprobe-- nf_conntrack
modprobe -- ip_vs加载核心的 IPVS 模块,这是实现 IP 虚拟服务器功能的基础。modprobe -- ip_vs_rr加载轮询调度算法(Round Robin Scheduling Algorithm),这是一种简单的负载均衡算法,依次将请求分发给后端服务器。modprobe -- ip_vs_wrr加载加权轮询调度算法(Weighted Round Robin Scheduling Algorithm),它根据权重分配流量,权重越高的服务器会收到更多的请求。modprobe -- ip_vs_sh加载基于源地址哈希的调度算法(Source Hashing Scheduling Algorithm),该算法确保来自同一客户端的请求总是被发送到同一台服务器。modprobe -- nf_conntrack加载 Netfilter 连接跟踪模块,这对于状态防火墙、NAT 和其他需要跟踪连接状态的功能至关重要。

4.3 所有节点创建ipvs.conf,并配置开机自动加载

vim /etc/modules-load.d/ipvs.conf
ip_vsip_vs_lc ip_vs_wlc ip_vs_rr ip_vs_wrr ip_vs_lblc ip_vs_lblcr ip_vs_dh ip_vs_sh ip_vs_fo ip_vs_nq ip_vs_sed ip_vs_ftp ip_vs_sh nf_conntrack ip_tables ip_set xt_set ipt_set ipt_rpfilter ipt_REJECT ipip

确保在系统启动时自动加载指定内核模块,并立即启动该服务的命令

systemctlenable--now systemd-modules-load.service

如下报错不用管

4.4 所有节点内核优化配置

编辑k8s.confcat<>/etc/sysctl.d/k8s.confnet.ipv4.ip_forward=1net.bridge.bridge-nf-call-iptables=1net.bridge.bridge-nf-call-ip6tables=1fs.may_detach_mounts=1net.ipv4.conf.all.route_localnet=1vm.overcommit_memory=1vm.panic_on_oom=0fs.inotify.max_user_watches=89100fs.file-max=52706963fs.nr_open=52706963net.netfilter.nf_conntrack_max=2310720net.ipv4.tcp_keepalive_time=600net.ipv4.tcp_keepalive_probes=3net.ipv4.tcp_keepalive_intvl=15net.ipv4.tcp_max_tw_buckets=36000net.ipv4.tcp_tw_reuse=1net.ipv4.tcp_max_orphans=327680net.ipv4.tcp_orphan_retries=3net.ipv4.tcp_syncookies=1net.ipv4.tcp_max_syn_backlog=16384net.ipv4.ip_conntrack_max=65536net.ipv4.tcp_max_syn_backlog=16384net.ipv4.tcp_timestamps=0net.core.somaxconn=16384EOF
所有节点应用配置sysctl--system
所有节点配置完内核以后,重启机器reboot
查看内核模块是否已经自动加载lsmod|grep --color=auto -e ip_vs -e nf_conntrack列出当前已加载的内核模块,并高亮显示包含 ip_vs 或 nf_conntrack 的行

5 K8s集群高可用组件安装

注意:如果安装的不是高可用集群,haproxy和keepalived无需要安装

注意:公有云要有 公有云自带的负载均衡,比如阿里云的SLB、NLB,腾讯云的ELB,用来替代haproxy和keepalived,因为公有云大部分不支持keepalived

5.1 所有Master节点安装、配置HAProxy

Master节点包括(k8s-master-01、k8s-master-02、k8s-master-03)

云数据库mysql数据库服务器

dnfinstall haproxy -y

所有Master节点配置HAProxy,所有Master节点的HAProxy配置相同

备份HAProxy配置文件cp/etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.bak清空HAProxy配置文件>/etc/haproxy/haproxy.cfg
编辑HAProxy配置文件vim/etc/haproxy/haproxy.cfg
globalmaxconn2000ulimit-n16384log127.0.0.1 local0 errstatstimeout 30sdefaultslogglobalmodehttpoptionhttplogtimeoutconnect 5000timeoutclient 50000timeoutserver 50000timeouthttp-request 15stimeouthttp-keep-alive 15sfrontendmonitor-inbind*:33305modehttpoptionhttplogmonitor-uri/monitorfrontendk8s-masterbind0.0.0.0:16443bind127.0.0.1:16443modetcpoptiontcplogtcp-requestinspect-delay 5sdefault_backendk8s-masterbackendk8s-mastermodetcpoptiontcplogoptiontcp-checkbalanceroundrobindefault-serverinter 10s downinter 5s rise 2 fall 2 slowstart 60s maxconn 250 maxqueue 256 weight 100serverk8s-master-01 192.168.3.60:6443 checkserverk8s-master-02 192.168.3.61:6443 checkserverk8s-master-03 192.168.3.62:6443 check

全局设置 (global)

maxconn 2000: 设置HAProxy进程可接受的最大并发连接数为2000。ulimit-n 16384: 设置每个HAProxy进程可以打开的最大文件描述符数量为16384,这对于处理大量并发连接非常重要。log 127.0.0.1 local0 err: 指定日志记录的目标和级别,这里只记录错误级别的日志。stats timeout 30s: 设置统计数据收集的超时时间为30秒。

默认设置 (defaults)

这些设置适用于所有未明确指定其他行为的前端和后端部分。

mode http: 定义默认模式为HTTP层(第7层)。log global: 使用全局定义的日志设置。option httplog: 启用HTTP请求的日志记录。timeout connect 5000: 设置与服务器建立连接的超时时间。timeout client 50000: 设置客户端连接的超时时间。timeout server 50000: 设置服务器端连接的超时时间。timeout http-request 15s: HTTP请求的超时时间。timeout http-keep-alive 15s: HTTP保持连接的超时时间。

前端 (frontend) 配置

监控页面 (monitor-in)

bind *:33305: 监听所有网络接口上的33305端口。mode http: 操作模式为HTTP。option httplog: 启用HTTP请求的日志记录。monitor-uri /monitor: 提供一个监控检查点,通过访问/monitor来检测HAProxy是否正常运行。

Kubernetes Master (k8s-master)

bind 0.0.0.0:16443 和 bind 127.0.0.1:16443: 监听所有网络接口以及本地回环接口上的16443端口。mode tcp: 操作模式为TCP层(第4层),因为Kubernetes API通信是基于TLS加密的。option tcplog: 启用TCP流量的日志记录。tcp-request inspect-delay 5s: 设置TCP请求的检查延迟为5秒,以便有足够的时间去检查TLS握手信息。default_backend k8s-master: 将所有接收到的请求转发给名为k8s-master的后端。

后端 (backend) 配置

Kubernetes Master (k8s-master)

mode tcp: 操作模式为TCP层。option tcplog: 启用TCP流量的日志记录。option tcp-check: 启用对后端服务器的TCP健康检查。balance roundrobin: 使用轮询算法在后端服务器之间分配连接。default-server ...: 定义了所有服务器的默认参数,包括检查间隔、失败次数、最大连接数等。server ... check: 列出了后端服务器及其健康检查配置。

此配置文件已经很好地设置了一个面向Kubernetes集群的HAProxy实例,它不仅能够提供高可用性,还能够通过监控页面方便地进行状态检查。如果您有任何特定的需求或需要进一步优化,请根据实际情况调整配置。

5.2 所有Master节点安装、配置Keepalived

5.2.1 所有Master节点安装Keepalived

dnfinstall keepalived -y

5.2.2 所有Master节点配置Keepalived

所有Master节点的Keepalived配置不相同

备份Keepalived配置文件cp/etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bak
清空Keepalived配置文件>/etc/keepalived/keepalived.conf
配置k8s-master-01节点keepalivedvim/etc/keepalived/keepalived.conf
! Configuration File for keepalivedglobal_defs{router_idLVS_DEVELscript_userrootenable_script_security}vrrp_scriptchk_apiserver {script"/etc/keepalived/check_apiserver.sh"interval5weight-5fall2rise1}vrrp_instanceVI_1 {stateMASTERinterfaceens160mcast_src_ip192.168.3.60virtual_router_id51priority101advert_int2authentication{auth_typePASSauth_passK8SHA_KA_AUTH}virtual_ipaddress{192.168.3.50}track_script{chk_apiserver}}
配置k8s-master-02节点keepalivedvim/etc/keepalived/keepalived.conf
global_defs{router_idLVS_DEVELscript_userrootenable_script_security}vrrp_scriptchk_apiserver {script"/etc/keepalived/check_apiserver.sh"interval5weight-5fall2rise1}vrrp_instanceVI_1 {stateBACKUPinterfaceens160mcast_src_ip192.168.3.61virtual_router_id51priority100advert_int2authentication{auth_typePASSauth_passK8SHA_KA_AUTH}virtual_ipaddress{192.168.3.50}track_script{chk_apiserver}}
配置k8s-master-03节点keepalivedvim/etc/keepalived/keepalived.conf
! Configuration File for keepalivedglobal_defs{router_idLVS_DEVELscript_userrootenable_script_security}vrrp_scriptchk_apiserver {script"/etc/keepalived/check_apiserver.sh"interval5weight-5fall2rise1}vrrp_instanceVI_1 {stateBACKUPinterfaceens160mcast_src_ip192.168.3.62virtual_router_id51priority100advert_int2authentication{auth_typePASSauth_passK8SHA_KA_AUTH}virtual_ipaddress{192.168.3.50}track_script{chk_apiserver}}

global_defs 段

router_id LVS_DEVEL: 定义了一个唯一的路由器 ID。script_user root: 指定执行脚本的用户为 root。请确保这是必要的,因为以 root 权限运行脚本可能存在安全风险。enable_script_security: 启用脚本安全功能。

vrrp_script 段

chk_apiserver: 定义了一个 VRRP 脚本,用于检查 API 服务器的状态。script "/etc/keepalived/check_apiserver.sh": 执行的脚本路径。interval 5: 每5秒检查一次。weight -5: 如果脚本失败,则将优先级减少5。fall 2: 当连续两次检查失败时,认为服务不可用。rise 1: 当一次检查成功后,认为服务可用。

vrrp_instance VI_1 段

state MASTER: 此实例被设置为 Master 状态。 state BACKUP:初始状态被设置为BACKUP,意味着这个节点准备作为备用。interface ens160: 使用 ens160 接口进行 VRRP 广播。mcast_src_ip 192.168.3.62: 设置多播源 IP 地址为 192.168.3.62。virtual_router_id 51: 定义虚拟路由器 ID。priority 101: 设置优先级。advert_int 2: 设置通告间隔为2秒。authentication: 定义认证信息。auth_type PASS: 使用密码认证。auth_pass K8SHA_KA_AUTH: 认证密码,请确保这是一个强密码。virtual_ipaddress: 定义虚拟 IP 地址为 192.168.3.50。track_script: 引用之前定义的 chk_apiserver 脚本。

5.2.3 所有Master节点配置keepalived健康检查文件

编辑keepalived健康检查文件vim/etc/keepalived/check_apiserver.sh
!/bin/bash初始化错误计数器err=0尝试检查haproxy进程最多三次forkin$(seq 1 3 )docheck_code=$(pgrep haproxy)if[["$check_code"==""]];thenerr=$(expr$err+1) sleep 1continueelseerr=0breakfidone如果三次尝试后仍未找到haproxy进程,则停止keepalived服务if[[$err!="0"]];thenecho"systemctl stop keepalived"/usr/bin/systemctl stop keepalivedexit1elseexit0fi
check_apiserver.sh脚本添加执行权限chmodu+x /etc/keepalived/check_apiserver.sh

5.3 所有master节点启动haproxy和keepalived

重新加载 systemd 的单元配置文件systemctldaemon-reload
启用并立即启动 HAProxy 服务systemctlenable--now haproxy
启用并立即启动 Keepalived 服务systemctlenable--now keepalived

5.4 所有节点测试vip

ping192.168.3.50-c4
telnet192.168.3.5016443

如果 ping不通且 telnet 没有出现 ] ,则认为 VIP 不可以,不可在继续往下执行,

需要排查keepalived 的问题,比如防火墙和 selinux,haproxy 和 keepalived 的状态,监听端口等

所有节点查看防火墙状态必须为disable和inactive:systemctl status firewalld

所有节点查看selinux状态,必须为disable:getenforce

master节点查看haproxy和keepalived状态:systemctl status keepalived haproxy

master节点查看监听端口:netstat-lntp

如果以上都没有问题,需要确认:

是否是公有云机器是否是私有云机器(类似0penStack)

上述公有云一般都是不支持keepalived,私有云可能也有限制,需要和自己的私有云管理员咨询

6 K8s Runtime安装

如果安装的版本低于1.24,选择Docker和Containerd均可,高于1.24选择Containerd作为Runtime。

6.1 所有节点配置安装源

dnf config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

6.2 所有节点安装docker-ce、containerd

dnfinstall docker-ce containerd -y

可以无需启动Docker,只需要配置和启动Containerd即可。

6.3 所有节点配置Containerd

配置Containerd所需的模块cat<
加载模块modprobe-- overlaymodprobe-- br_netfilter
配置Containerd所需的内核cat<
加载内核sysctl--system
配置Containerd的配置文件mkdir-p /etc/containerd
containerdconfigdefault | tee /etc/containerd/config.toml
将Containerd的Cgroup改为Systemdsed -isSystemdCgroup = falseSystemdCgroup= true g/etc/containerd/config.toml sed -isk8s.gcr.io/pauseregistry.cn-hangzhou.aliyuncs.com/google_containers/pauseg/etc/containerd/config.toml sed -isregistry.gcr.io/pauseregistry.cn-hangzhou.aliyuncs.com/google_containers/pauseg/etc/containerd/config.toml sed -isregistry.k8s.io/pauseregistry.cn-hangzhou.aliyuncs.com/google_containers/pauseg/etc/containerd/config.toml
vim /etc/containerd/config.toml

你提供的 sed 命令用于修改/etc/containerd/config.toml 文件中的特定配置项。这些命令将:

将 SystemdCgroup = false 修改为 SystemdCgroup = true。将所有出现的 k8s.gcr.io/pause 替换为 registry.cn-hangzhou.aliyuncs.com/google_containers/pause。将所有出现的 registry.gcr.io/pause 替换为 registry.cn-hangzhou.aliyuncs.com/google_containers/pause。将所有出现的 registry.k8s.io/pause 替换为 registry.cn-hangzhou.aliyuncs.com/google_containers/pause。启动Containerd,并配置开机启动systemctldaemon-reloadsystemctlenable --now containerd
检查containerd状态是否正常ctrplugin ls

确认ID为overlayfscri的状态必须OK

配置crictl客户端连接的运行时位置(可选)cat>/etc/crictl.yaml<runtime-endpoint:unix:///run/containerd/containerd.sockimage-endpoint:unix:///run/containerd/containerd.socktimeout:10debug:falseEOF

安装完成k8s后,会同步安装crictl

没有安装k8s前使用crictl会提示command not found

7 K8s集群组件安装

7.1 所有节点配置源(注意版本号)

https://developer.aliyun.com/mirror/kubernetes

阿里云k8s镜像仓库配置cat<[kubernetes]name=Kubernetesbaseurl=https://mirrors.aliyun.com/kubernetes-new/core/stable/v1.31/rpm/enabled=1gpgcheck=1gpgkey=https://mirrors.aliyun.com/kubernetes-new/core/stable/v1.31/rpm/repodata/repomd.xml.keyEOF
k8s-master-01节点查看最新的Kubernates版本是多少dnflistkubeadm.x86_64 --showduplicates | sort -r

7.2 所有节点安装1.31最新版本kubeadm、kubelet和kubectl

注意:公有云环境下,可能需要将kubectl放在一个非master节点上

dnfinstallkubeadm-1.31*kubelet-1.31*kubectl-1.31*-y

7.3所有节点设置Kubelet开机自启动

所有节点设置Kubelet开机自启动systemctlenable--now kubelet
查看系统日志,Ctrl+c中断查看tail -f /var/log/messages

由于还未初始化,没有kubelet的配置文件,此时kubelet无法启动,无需管理

云服务器免费云服务器

您好:云优数据云计算 www.yunyoushuju.cn 2核2G6M最低19.9元/月 欢迎开机

发表评论

评论列表
未查询到任何数据!