gpt4 book ai didi

kubernetes - 在K8S中,每个kube-proxy(在每个节点上运行)是否都具有相同的实现?

转载 作者:行者123 更新时间:2023-12-02 11:43:01 24 4
gpt4 key购买 nike

我是K8S的新手,我试图了解在集群中每个节点上运行的kube-proxy的确切作用。该文档提到“kube-proxy反射(reflect)了每个节点上Kubernetes API中定义的服务,并且可以在一组后端上执行简单的TCP,UDP和SCTP流转发或循环TCP,UDP和SCTP转发”。为了做到这一点,每个kube-proxy将需要具有有关集群中运行的所有服务的完整信息,因为kube-proxy的责任是提供对Pod上运行的应用程序所需的任何服务的访问权限(在相应节点上)​​。那么,这是否意味着K8S集群(在每个节点上运行)中的所有kube代理都是镜像?如果是这样,为什么在每个节点上都存在一个kube-proxy而不是整个集群的集中式代理?

链接到有关代理的K8S文档:https://kubernetes.io/docs/concepts/cluster-administration/proxies/

最佳答案

So does that mean that all the kube-proxies inside a K8S cluster (running on each node) are mirror images?



是的,它们是同一图像的实例。

If so, why is a kube-proxy present on each node instead of a centralized one for entire cluster?



kube-proxy使用操作系统数据包过滤层(如果有)并且可用,例如IPtable,IPVS。否则,kube-proxy会转发流量本身。 kube-proxy

Kube-Proxy本身就是 k8s Controller ,它监视群集的所需状态(服务和端点)并在节点上进行更改,因为它管理IPtabels(使用iptable模式)

For this to be true, each kube-proxy will need to have complete information about all the services running in the cluster .....



有以下标志来设置kube-proxy的行为
--iptables-min-sync-period duration
The minimum interval of how often the iptables rules can be refreshed as endpoints and services change (e.g. '5s', '1m', '2h22m').
--iptables-sync-period duration Default: 30s
The maximum interval of how often iptables rules are refreshed (e.g. '5s', '1m', '2h22m'). Must be greater than 0.

IMO,决定节点上Pod之间的连接(转发,接受)应由节点组件而不是中央平面组件决定。此外,K8的控制平面(API服务器等)保持集群的所需状态和当前状态,因此所有 Controller 都可以根据其设置的行为进行协调。

关于kubernetes - 在K8S中,每个kube-proxy(在每个节点上运行)是否都具有相同的实现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59513928/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com