kubernetes - kubectl 命令在空闲几分钟后断开连接

标签 kubernetes kubectl

我们注意到当我们exec -it连接到 pod,在一定的空闲时间后连接被破坏。是否有任何选项可以让连接打开更长时间?

我看到有一个开放PR ,但想知道是否有解决此问题的方法。

最佳答案

最简洁的答案是不。这就是为什么:

Enabling TCP keepalive for console connections

TCP keepalive is a TCP option that causes packets to be exchanged over a connection even if there is no traffic to transport. It should be enabled on both ends of the connection. TCP keepalive must be enabled at the operating-system level and by the application/program opening TCP connections.

On Linux, edit the "/etc/sysctl.conf" file and add these lines:

net.ipv4.tcp_keepalive_time = 200
net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_keepalive_intvl = 50

(feel free to adapt the values as you see fit). When done editing, you must make the new values known to the kernel:

# sysctl --load=/etc/sysctl.conf


Custom Configuration of TCP Socket Keep-Alive Timeouts

Default values for these properties is:

tcp_keepalive_time = 7200 seconds
tcp_keepalive_probes = 9
tcp_keepalive_intvl = 75 seconds


另一种可能的方法是在客户端启动某种代理服务器并通过它连接到 Kubernetes apiserver。
我自己没有测试过,这可能很棘手,但是 here是如何为 Nginx 启用 Keepalive 后端的示例。

关于kubernetes - kubectl 命令在空闲几分钟后断开连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50691104/

相关文章:

google-compute-engine - 在Google Compute Engine上运行Kubernetes集群后,是否应该编辑Salt tar文件?

kubernetes - 从另一个容器复制 Kubernetes pod 内的文件

azure - 无法进入 kubernetes pod。来自服务器 : error dialing backend: dial tcp: lookup (node hostname) on 168. 63.129.16:53 的错误:没有这样的主机

Kubernetes 使用 "Kubectl delete -f PVC_NAME"防止 PVC 被删除

kubernetes - 我如何在 or 条件下使用 kubectl 标签选择器?

docker - 错误 : unable to find container in kubectl set image

kubernetes - Kubectl推出重新启动以实现有状态集

docker - 如何让kubernetes pod可以访问PostgreSQL Pod

java - Pod OOM - Xmx 未被尊重

kubernetes - kubelet 动态配置不起作用