kube-proxy 的代理模式中用户空间模式是什么意思? [英] What does userspace mode means in kube-proxy's proxy mode?

查看:38
本文介绍了kube-proxy 的代理模式中用户空间模式是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

kube-proxy有一个选项叫--proxy-mode,根据帮助信息,这个选项可以是userspaceiptables.(见下文)

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 -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.

谁能告诉我kube-proxy在用户空间模式下运行的工作原理是什么?

Anyone can tell me what the working principle is when kube-proxy runs under userspace mode?

推荐答案

用户空间和 iptables 指的是实际处理连接转发的内容.在这两种情况下,都会安装本地 iptables 规则来拦截具有与服务关联的目标 IP 地址的出站 TCP 连接.

Userspace and iptables refer to what actually handles the connection forwarding. In both cases, local iptables rules are installed to intercept outbound TCP connections that have a destination IP address associated with a service.

在用户空间模式下,iptables 规则转发到本地端口,go 二进制文件(kube-proxy)正在监听连接.二进制文件(在用户空间中运行)终止连接,为服务建立到后端的新连接,然后将请求转发到后端并将响应返回给本地进程.用户空间模式的一个优点是,因为连接是从应用程序创建的,如果连接被拒绝,应用程序可以重试到不同的后端.

In the userspace mode, the iptables rule forwards to a local port where a go binary (kube-proxy) is listening for connections. 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.

在 iptables 模式下,安装 iptables 规则以将目的地为服务的数据包直接转发到服务的后端.这比将数据包从内核移动到 kube-proxy 然后返回内核更有效,因此它会导致更高的吞吐量和更好的尾部延迟.主要的缺点是它更难调试,因为不是将日志写入 /var/log/kube-proxy 的本地二进制文件,您必须检查内核处理 iptables 规则中的日志.

In iptables mode, the iptables rules are installed to directly forward packets that are destined for a service to a backend for the service. 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. 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.

在这两种情况下,您的机器上都会运行一个 kube-proxy 二进制文件.在用户空间模式下,它插入自己作为代理;在 iptables 模式下,它将配置 iptables 而不是代理连接本身.相同的二进制文件在两种模式下都可以工作,并且通过标志或通过在节点的 apiserver 中设置注释来切换行为.

In both cases there will be a kube-proxy binary running on your machine. In userspace mode it inserts itself as the proxy; in iptables mode it will configure iptables rather than to proxy connections itself. 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.

这篇关于kube-proxy 的代理模式中用户空间模式是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆