准备工作
- 准备好3台服务器 ,每台机器内存2GB以上, master节点cpu 2C以上。
- 同步服务器时间(NTP)
- 设置服务器ssh免密配置
安装步骤
设置hosts
vi /etc/hosts
192.168.0.110 master110
192.168.0.109 node109
192.168.0.112 node112
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
关闭swap
关闭swap (为保证系统的稳定性和性能,k8s建议关闭swap)
临时关闭:swapoff -a
永久关闭(需要重启机子)
vi etc/fstab
[root@master110 ~]# less /etc/fstab
#
# /etc/fstab
# Created by anaconda on Wed Mar 27 06:37:15 2024
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=ae1ef289-9c30-4338-af1f-6be0af376392 /boot xfs defaults 0 0
#/dev/mapper/centos-swap swap swap defaults 0 0
禁用SELinux
vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
#SELINUX=enforcing
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
#SELINUXTYPE=targeted
SELINUX=disabled
设置iptables
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF
cat <<EOF | sudo tee /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
sysctl --system
安装容器运行时 containerd
yum install -y yum-utils
# 添加docker镜像源
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 安装
yum install -y containerd
# 启动containerd
sudo systemctl start containerd