简体   繁体   English

用户空间模式在kube-proxy的代理模式中意味着什么?

[英]What does userspace mode means in kube-proxy's proxy mode?

kube-proxy has an option called --proxy-mode,and according to the help message, this option can be userspace or iptables .(See below) kube-proxy有一个名为--proxy-mode的选项,根据帮助消息,这个选项可以是userspaceiptables 。(见下文)

# kube-proxy -h
Usage of kube-proxy:
...
      --proxy-mode="": Which proxy mode to use: 'userspace' (older, stable) or 'iptables' (experimental). If blank, look at the Node object on the Kubernetes API and respect the 'net.experimental.kubernetes.io/proxy-mode' annotation if provided.  Otherwise use the best-available proxy (currently userspace, but may change in future versions).  If the iptables proxy is selected, regardless of how, but the system's kernel or iptables versions are insufficient, this always falls back to the userspace proxy.
...

I can't figure out what does userspace mode means here. 我无法弄清楚用户空间模式在这里意味着什么。

Anyone can tell me what the working principle is when kube-proxy runs under userspace mode? 任何人都可以告诉我kube-proxy在用户空间模式下运行时的工作原理是什么?

Userspace and iptables refer to what actually handles the connection forwarding. Userspace和iptables指的是实际处理连接转发的内容。 In both cases, local iptables rules are installed to intercept outbound TCP connections that have a destination IP address associated with a service. 在这两种情况下,都会安装本地iptables规则来拦截具有与服务关联的目标IP地址的出站TCP连接。

In the userspace mode, the iptables rule forwards to a local port where a go binary (kube-proxy) is listening for connections. 在用户空间模式下,iptables规则转发到go二进制(kube-proxy)正在侦听连接的本地端口。 The binary (running in userspace) terminates the connection, establishes a new connection to a backend for the service, and then forwards requests to the backend and responses back to the local process. 二进制文件(在用户空间中运行)终止连接,建立与服务后端的新连接,然后将请求转发给后端并将响应转发回本地进程。 An advantage of the userspace mode is that because the connections are created from an application, if the connection is refused, the application can retry to a different backend. 用户空间模式的一个优点是,因为连接是从应用程序创建的,如果连接被拒绝,应用程序可以重试到不同的后端。

In iptables mode, the iptables rules are installed to directly forward packets that are destined for a service to a backend for the service. 在iptables模式下,安装iptables规则以直接将发往服务的数据包转发到服务的后端。 This is more efficient than moving the packets from the kernel to kube-proxy and then back to the kernel so it results in higher throughput and better tail latency. 这比将数据包从内核移动到kube-proxy然后再返回内核更有效,因此可以提高吞吐量和延迟尾部延迟。 The main downside is that it is more difficult to debug, because instead of a local binary that writes a log to /var/log/kube-proxy you have to inspect logs from the kernel processing iptables rules. 主要缺点是调试起来比较困难,因为不是将日志写入/var/log/kube-proxy的本地二进制文件,而是必须从内核处理iptables规则中检查日志。

In both cases there will be a kube-proxy binary running on your machine. 在这两种情况下,都会在您的计算机上运行kube-proxy二进制文件。 In userspace mode it inserts itself as the proxy; 在用户空间模式下,它将自身作为代理插入; in iptables mode it will configure iptables rather than to proxy connections itself. 在iptables模式下,它将配置iptables而不是代理连接本身。 The same binary works in both modes, and the behavior is switched via a flag or by setting an annotation in the apiserver for the node. 相同的二进制文件在两种模式下都有效,并且通过标志或在节点的apiserver中设置注释来切换行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM