1.加载ipvs模块:
1)加载ipvs: [[email protected] ipvs]# vim ipvs.sh #!/bin/bash modprobe -- ip_vs modprobe -- ip_vs_sh modprobe -- ip_vs_rr modprobe -- ip_vs_wrr modprobe -- nf_conntrack_ipv4 2).执行脚本: [[email protected] ipvs]# chmod +x ipvs.sh [[email protected] ipvs]# bash ipvs.sh [[email protected] ipvs]# lsmod |grep ip_vs ip_vs_wrr 12697 0 ip_vs_rr 12600 0 ip_vs_sh 12688 0 ip_vs 145497 6 ip_vs_rr,ip_vs_sh,ip_vs_wrr nf_conntrack 133095 9 ip_vs,nf_nat,nf_nat_ipv4,nf_nat_ipv6,xt_conntrack,nf_nat_masquerade_ipv4,nf_conntrack_netlink,nf_conntrack_ipv4,nf_conntrack_ipv6 libcrc32c 12644 4 xfs,ip_vs,nf_nat,nf_conntrack [[email protected] ipvs]# echo "/root/kubernetes/ipvs/ipvs.sh" >>/etc/rc.local [[email protected] ipvs]# chmod +x /etc/rc.local ##此时ipvs已经加载成功,其他节点也需要加载ipvs。 3)分发其他node节点: [[email protected] ipvs]# for i in node1 node2; do scp ipvs.sh $i:/root/;done ##其他节点需要执行脚本,添加开启自启 4)所有节点验证开启了ipvs: [[email protected] ipvs]# lsmod |grep ip_vs
2.安装ipvsadm工具:(所有节点安装ipvsadm)
[[email protected] ipvs]#yum install ipset ipvsadm -y 2)编辑kube-proxy配置文件: [[email protected] ipvs]# kubectl edit configmap -n kube-system kube-proxy
3)重启kube-proxy: [[email protected] ~]# kubectl get pod -n kube-system ##查看[[email protected] ~]# kubectl delete pod -n kube-system kube-proxy-2nhf6 ##注意3个kube-proxy依次重启
3.查看:
[[email protected] ~]# ipvsadm -ln
原文地址:https://www.cnblogs.com/ccbyk-90/p/11795903.html
时间: 2024-11-14 13:16:29