Kuberntes service 流量分发机制

2020-07-16  本文已影响0人  leeehao

介绍

在 kubernetes 中我们可以访问直接访问 service 与后端 pod 进行沟通,那么 Service 是如何选取 Deployment 的呢?

kube-proxy

service 的流量转发是通过 kube-proxy 进行的,kube-proxx 的实现目前有几种:

而 ipvs 支持较多,如下所示

userspace、iptables、ipvs 三种模式中默认的负载均衡策略都是通过 round-robin 算法来选择后端 pod 的

userspace、iptables、ipvs 三种模式中默认的负载均衡策略都是通过 round-robin 算法来选择后端 pod 的,在 service 中可以通过设置 service.spec.sessionAffinity 的值实现基于客户端 ip 的会话亲和性,service.spec.sessionAffinity 的值默认为"None",可以设置为 "ClientIP",此外也可以使用 service.spec.sessionAffinityConfig.clientIP.timeoutSeconds 设置会话保持时间。

相关参考

https://zhuanlan.zhihu.com/p/111244353

上一篇下一篇

猜你喜欢

热点阅读