kubernetes-client / python

Official Python client library for kubernetes
http://kubernetes.io/
Apache License 2.0
6.74k stars 3.27k forks source link

Set tcp keepalive for http connections #2067

Open felixhuettner opened 1 year ago

felixhuettner commented 1 year ago

What is the feature and why do you need it:

Currently when a watch is opened to the kubernetes api we do not send regular keepalives on the connection. That means that if the watch is not receiving any updates a reverse proxy in the path might terminate the tcp connection.

The go client is currently sending a tcp keepalive every 30 seconds: https://github.com/kubernetes/client-go/blob/release-1.27/transport/cache.go#L104-L107

Describe the solution you'd like to see:

On linux set a socket options to update the keepalive time, just like it is done in go here: https://go.dev/src/net/tcpsockopt_unix.go

I do not have particular feelings regarding other operating systems

roycaihw commented 1 year ago

/help

k8s-ci-robot commented 1 year ago

@roycaihw: This request has been marked as needing help from a contributor.

Guidelines

Please ensure that the issue body includes answers to the following questions:

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed by commenting with the /remove-help command.

In response to [this](https://github.com/kubernetes-client/python/issues/2067): >/help Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
polivbr commented 1 month ago

Any updates on this? The lack of keepalive on connections renders it impossible to watch logs on pods in certain environments and situations. I'm happy to submit a PR if desired.