Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make connections to k8s API server persistent #1390

Merged

Conversation

andrzej-stencel
Copy link
Contributor

Description

The Fluentd plugins we use make a good amount of HTTP connections to the Kubernetes API server for Kubernetes metadata enrichment. Until now, the HTTP connections were being closed after each HTTP request, requiring a new HTTP connection to be established on every request to API server. This was a suboptimal solution, and the root cause for SNAT port exhaustion in AKS clusters.

With this change, we are using a yet unreleased version of Kubeclient library to be able to create persistent HTTP connections. The Kubeclient library (which is used by our Fluentd plugins to make requests to k8s API server) originally used RestClient gem under the hood, which does not make it possible to create persistent connections. With the unreleased version of Kubeclient, the underlying HTTP library has been changed from RestClient to Faraday, which, when used with NetHttpPersistent adapter, makes connections persistent by default.

Testing in AKS showed that SNAT port usage with persistent connections is constant, no matter how many requests our plugins make to API server.

Testing performed
  • Redeploy fluentd and fluentd-events pods
  • Confirm events, logs, and metrics are coming in

@pmalek-sumo pmalek-sumo added this to the v1.3 milestone Jan 29, 2021
@andrzej-stencel andrzej-stencel marked this pull request as draft January 29, 2021 10:39
@pmalek-sumo
Copy link
Contributor

I guess you'll be fixing tests now right?

...
  NameError: undefined local variable or method `client' for #<Fluent::Plugin::KubernetesMetadataFilter:00555d3c6a2400>
  Did you mean?  @client
...

This should prevent SNAT port usage exhaustion in AKS.
@andrzej-stencel andrzej-stencel force-pushed the use-kubeclient-with-persistent-connections branch from 61032f5 to 2339b2f Compare January 29, 2021 14:28
@andrzej-stencel andrzej-stencel marked this pull request as ready for review January 29, 2021 15:01
@andrzej-stencel andrzej-stencel changed the title Make persistent connections to k8s API server Make connections to k8s API server persistent Feb 2, 2021
@andrzej-stencel andrzej-stencel merged commit f9f5147 into release-v1.3 Feb 2, 2021
@andrzej-stencel andrzej-stencel deleted the use-kubeclient-with-persistent-connections branch February 2, 2021 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants