k8s开启ipvs

k8s开启ipvs

1.加载内核模快

lsmod|grep ip_vs

modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack_ipv4

yum install ipvsadm ipset -y

2.修改kube-proxy配置

kubectl edit configmap kube-proxy -n kube-system

   minSyncPeriod: 0s
      scheduler: ""
      syncPeriod: 30s
    kind: KubeProxyConfiguration
    metricsBindAddress: 127.0.0.1:10249
    mode: "ipvs"                          # 修改此处
    nodePortAddresses: null

3.删除所有kube-proxy的pod

kubectl delete pod xxx -n kube-system

4.校验

kubectl logs kube-proxy-xxx -n kube-system
日志出现Using ipvs Proxier即可

5.检查ipvs代理规则

kubectl get svc --all-namespaces
# ipvsadm -ln
#可以看到service对应的很多规则