PS:基于kubeadm部署的k8s集群
1、开启netfilter模块
modprobe br_netfilter
2、修改内核参数,开启内核转发
cat >> /etc/sysctl.conf << mm
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
mm
sysctl -p #立即生效
3、启用ipvs模块,下面是启用脚本
#!/bin/bash
ipvs_mods_dir="/usr/lib/modules/$(uname -r)/kernel/net/netfilter/ipvs"
for i in $(ls $ipvs_mods_dir|grep -o "^[^.]*")
do
/sbin/modinfo -F filename $i &>/dev/null
if [ $? -eq 0 ];then
/sbin/modprobe $i
fi
done
4、修改kube-proxy在k8s中的cm文件,修改完记得重启proxy的pod,并查看log
kubectl edit cm kube-proxy -n kube-system
kind: KubeProxyConfiguration
metricsBindAddress: ""
mode: "ipvs"
nodePortAddresses: null