1、环境初始化(所有节点都要操作)
(1) 此环境下安装k8s集群要求centos版本在7.5或以上。
[root@Master ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
(2)添加主机名解析
[root@Master ~]# vim /etc/hosts
192.168.194.100 Master
192.168.194.101 node1
192.168.194.103 node3
(3)时间同步
1)使用软件包安装工具安装chrony和ntp
- Arch Linux系列:
sudo pacman -S ntp chrony - Debian系列:
sudo apt install ntp chrony - Red Hat系列:
sudo yum install ntp chrony
或者
sudo dnf install ntp chrony
[root@Master ~]# systemctl start chronyd
[root@Master ~]# systemctl enable chronyd
[root@Master ~]# date
(4)禁用防火墙服务
[root@Master ~]# systemctl stop firewalld
[root@Master ~]# systemctl disable firewalld
[root@Master ~]# systemctl stop iptables
[root@Master ~]# systemctl disable iptables
(5)禁用selinux
编辑 /etc/selinux/config 文件,修改SELINUX的值为disabled,注意修改完毕后需要重启linux服务。
[root@Master ~]# vim /etc/selinux/config
SELINUX=disabled
(6)禁用swap分区
编辑分区文件 /etc/fstab,注释掉swap分区一行,注意修改完毕后需要重启linux服务。
[root@Master ~]# vim /etc/fstab
UUID=e64931ff-6f96-4b05-838b-ebabaefe52e5 /boot xfs defaults 0 0
#/dev/mapper/centos-swap swap swap defaults 0 0
(7)修改linux的内核参数
echo vm.max_map_count=262144 >> /etc/sysctl.conf
echo net.ipv6.conf.all.disable_ipv6 = 1 >> /etc/sysctl.conf
echo net.ipv6.conf.default.disable_ipv6 = 1 >> /etc/sysctl.conf
echo net.ipv4.ip_forward = 1 >> /etc/sysctl.conf
[root@Master ~]# sysctl -p
(8)重启服务器
完成以上步骤之后,需要重新启动linux系统。
[root@Master ~]# reboot