1. 系统初始化 每台服务器
1.1.关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
sudo ufw status #查看防火墙状态 inactive关闭状态active开启状态
sudo ufw disable #关闭防火墙
1.2.关闭selinux
sed -i 's/enforcing/disabled/' /etc/selinux/config # 永久
setenforce 0 # 临时
sudo apt install selinux-utils
getenforce 查看状态 Disabled关闭的
$ sed -i 's/enforcing/disabled/' /etc/selinux/config # 永久
$ setenforce 0 # 临时
1.3.关闭swap分区
swapoff -a # 临时
sed -ri 's/.*swap.*/#&/' /etc/fstab #永久
echo "vm.swappiness=0" >> /etc/sysctl.conf
sysctl -p /etc/sysctl.conf
sed -i 's$/dev/mapper/centos-swap$#/dev/mapper/centos-swap$g' /etc/fstab
1.4.修改ubuntu主机名
hostnamectl set-hostname master
1.5 master中添加hosts
使用kubesphere安装此处可不添加hosts,kubesphere会自动添加
sudo cat >>/etc/hosts <<EOF
192.168.32.135 master
192.168.32.136 node1
192.168.32.137 node2
EOF
1.6.IPV4流量传递到iptales链
cat >/etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
#### 执行以下命令生效
modprobe br_netfilter && sysctl -p /etc/sysctl.d/k8s.conf
1.7.时间同步
sudo yum install ntpdate -y
sudo ntpdate time.windows.com
##设置为上海时区
timedatectl set-timezone Asia/Shanghai
#### 安装chrony
yum -y install chrony
#### 修改同步服务器地址为阿里云
sed -i.bak '3,6d' /etc/chrony.conf && sed -i '3cserver ntp1.aliyun.com iburst' /etc/chrony.conf
#### 启动chronyd及加入开机自启
systemctl start chronyd && systemctl enable chronyd
#### 查看同步结果
chronyc sources
1.8安装ipvs
cat > /etc/sysconfig/modules/ipvs.modules <<EOF
#!/bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack_ipv4
EOF
#### 修改权限以及查看是否已经正确加载所需的内核模块
chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep -e ip_vs -e nf_conntrack_ipv4
#### 安装ipvsadm
yum -y install ipset ipvsadm
### 安装依赖组件### 安装依赖组件
yum install -y ebtables socat ipset conntrack
1.9 安装需要的依赖项
yum install -y socat conntrack ipset ebtables ipvsadm
apt install socat conntrack ipset
原文链接:https://blog.csdn.net/qq_33174891/article/details/129889969