We noticed when we exec -it
to connect into a pod, after certain idle time the connection get destroyed. Is there any option to leave the connection open longer?
I see there is an open PR, but wondering if there is any workaround for this issue.
The short answer is no. And that's why:
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
The other possible way is to start some kind of proxy server on the client side and connect to Kubernetes apiserver through it. I haven’t tested it myself and it could be tricky, but here is an example of how to enable keepalives to backend for Nginx.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With