环境:已安装完成Kubernetes
master节点192.168.1.10/centos7
node节点 192.168.1.11/centos7
配置IPVS
[root@master ~]# touch /etc/sysconfig/modules/ipvs.modules [root@master ~]# vim /etc/sysconfig/modules/ipvs.modules #写入以下内容 #!/bin/bash modprobe -- ip_vs modprobe -- ip_vs_rr modprobe -- ip_vs_wrr modprobe -- ip_vs_sh modprobe -- nf_conntrack_ipv4
[root@master ~]# chmod 755 /etc/sysconfig/modules/ipvs.modules [root@master ~]# bash /etc/sysconfig/modules/ipvs.modules
#验证
[root@master ~]# lsmod|grep -e ip_vs -e nf_conntrack_ipv4 nf_conntrack_ipv4 15053 0 nf_defrag_ipv4 12729 1 nf_conntrack_ipv4 ip_vs_sh 12688 0 ip_vs_wrr 12697 0 ip_vs_rr 12600 0 ip_vs 145497 6 ip_vs_rr,ip_vs_sh,ip_vs_wrr nf_conntrack 139224 2 ip_vs,nf_conntrack_ipv4 libcrc32c 12644 3 xfs,ip_vs,nf_conntrack [root@master ~]# yum -y install ipset ipvsadm
node节点相同操作
开启IPVS
修改ConfigMap的kube-system/kube-proxy中的config.conf文件,修改为 mode: "ipvs"
[root@master .kube]# kubectl edit cm kube-proxy -n kube-system configmap/kube-proxy edited
#进入后编辑方法同vim
重启kube-proxy
此处执行删除会自动创建
[root@master .kube]# kubectl get pod -n kube-system | grep kube-proxy kube-proxy-8ndgz 1/1 Running 0 92m kube-proxy-lxdbj 1/1 Running 0 96m [root@master .kube]# kubectl delete pod kube-proxy-8ndgz -n kube-system pod "kube-proxy-8ndgz" deleted [root@master .kube]# kubectl delete pod kube-proxy-lxdbj -n kube-system pod "kube-proxy-lxdbj" deleted
或者执行
[root@master .kube]# kubectl get pod -n kube-system | grep kube-proxy kube-proxy-8ndgz 1/1 Running 0 92m kube-proxy-lxdbj 1/1 Running 0 96m [root@master .kube]# kubectl delete pod kube-proxy-8ndgz -n kube-system pod "kube-proxy-8ndgz" deleted [root@master .kube]# kubectl delete pod kube-proxy-lxdbj -n kube-system pod "kube-proxy-lxdbj" deleted
测试IPVS
使用命令ipvsadm –Ln查看创建的服务是否使用ipvs创建集群
查询kube-proxy日志
如图已经显示使用ipvs