COOKBOOK-Kubernetes二进制高可用部署-准备

版本说明

  • kubernetes:1.31.2
  • containerd:1.7.7
  • etcd:3.5.14
  • nerdctl:1.7.7

虚拟机信息

  • IP
    • 192.168.56.109,hostname:centos1
    • 192.168.56.110,hostname:centos2
    • 192.168.56.111,hostname:centos3
  • 操作系统:CentOS7
  • 内核版本:3.10.0

系统准备

所有虚拟机禁用swap虚拟内存

1
2
3
4
5
6
7
8
# 查看默认是否开启swap虚拟内存,swap端不为0则说明开启
free -h
# 临时禁用swap
swapoff -a
# 永久禁用swap,需重启服务生效
sed -i 's/.*swap.*/#&/' /etc/fstab
# 再次查看swap是否已关闭
free -h

所有虚拟机禁用SELinux

1
2
3
4
5
6
7
8
# 查看默认是否已关闭
getenforce
# 临时禁用
setenforce 0
# 永久禁用,需重启服务器生效
sed -i "s/^SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config
# 再次查看是否已关闭
getenforce

所有虚拟机关闭防火墙

1
2
3
# 所有主机执行
systemctl stop firewalld
systemctl disable firewalld

所有虚拟机开启ipv4转发内核能力

1
2
3
4
5
6
7
8
9
10
# 创建k8s特有的内核能力配置文件
cat << EOF > /etc/sysctl.d/k8s-sysctl.conf
net.ipv4.ip_forward = 1
EOF

# 开启内核能力
sysctl -p /etc/sysctl.d/k8s-sysctl.conf

# 查看内核能力开启情况
sysctl -a |grep ipv4.ip-forward

所有虚拟机配置host

1
2
3
4
5
cat << EOF >> /etc/hosts
192.168.56.109 centos1
192.168.56.110 centos2
192.168.56.111 centos3
EOF

所有虚拟机安装必要工具

1
yum install -y net-tools tree wget

(•̀ᴗ•́)و ̑̑

Share