
k8s网络iptables和ipvs
service功能:
负载均衡:iptables、ipvs
服务发现:是用endpoint控制器实现的(iptables规则,kube-proxy)
1.iptables负载均衡
流量入口
1、浏览器访问(nodePort)-A KUBE-NODEPORTS -p tcp -m comment --comment "default/web" -m tcp --dport 31849 -j KUBE-SVC-LOLE4ISW44XBNF3G1、集群中其他Pod访问(ClusterIP)service功能:
负载均衡:iptables、ipvs
服务发现:是用endpoint控制器实现的(iptables规则,kube-proxy)-A KUBE-SERVICES -d 10.111.63.235/32 -p tcp -m comment --comment "default/web cluster IP" -m tcp --dport 80 -j KUBE-SVC-LOLE4ISW44XBNF3G2、负载均衡(轮训)
-A KUBE-SVC-LOLE4ISW44XBNF3G -m comment --comment "default/web" -m statistic --mode random --probability 0.33333333349 -j KUBE-SEP-2AKROEM6BFYCZLBR -A KUBE-SVC-LOLE4ISW44XBNF3G -m comment --comment "default/web" -m statistic --mode random --probability 0.50000000000 -j KUBE-SEP-HMDHLPUCR63SDNRP -A KUBE-SVC-LOLE4ISW44XBNF3G -m comment --comment "default/web" -j KUBE-SEP-SEAKQJDGREXSF5EV3条(pod副本数)时各33%
2条时各50%
1条时100%
3、具体转发到某个Pod(节点与Pod通信)
-A KUBE-SEP-2AKROEM6BFYCZLBR -p tcp -m comment --comment "default/web" -m tcp -j DNAT --to-destination 10.244.169.134:80.