一. 准备材料
1.环境相关(可选)
1)ipvs
新增ipvs.module
vim /etc/sysconfig/modules/ipvs.module
#!/bin/bash
ipvs_modules="ip_vs ip_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 nf_conntrack"
for kernel_module in ${ipvs_modules}; do
/sbin/modinfo -F filename ${kernel_module} > /dev/null 2>&1
if [ $? -eq 0 ]; then
/sbin/modprobe ${kernel_module}
fi
done
执行生效
chmod 755 /etc/sysconfig/modules/ipvs.modules
sh /etc/sysconfig/modules/ipvs.modules
lsmod | grep ip_vs
2)防火墙
K8s集群每个节点都需要关闭防火墙
systemctl stop firewalld && systemctl disable firewalld
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
3)swap
swapoff -a
cp /etc/fstab /etc/fstab.bak
cat /etc/fstab.bak | grep -v swap > /etc/fstab
4)iptables
直接关闭(测试环境)、/etc/sysctl.conf添加
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
避免偶现dns解析失败
5)sysctl修改
/etc/sysctl.conf添加
vm.swappiness = 0
net.ipv4.ip_forward = 1
6)配置生效
sysctl -p
7)注意如果是K8s 集群, 主机名不可一致,