hashicorp / vault-plugin-auth-kubernetes

Vault authentication plugin for Kubernetes Service Accounts
https://www.vaultproject.io/docs/auth/kubernetes.html
Mozilla Public License 2.0
208 stars 61 forks source link

Cache httpClient for connection re-use #142

Closed imthaghost closed 2 years ago

imthaghost commented 2 years ago

Overview

Currently, the Review function for this backend creates a new HTTP client every time it gets called. This can be quite expensive and does not allow the backend to re-use connections.

Design of Change

In this implementation, the kubeAuthBackend struct stores and instantiates a DefaultPooledHTTPClient for connection re-use. The client is then passed by reference down to the reviewFactory for use in the Kubernetes API. This will ensure that we only create and use one HTTP client.