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

Support re-reading apiserver token at a set interval / built-in support for in-cluster config #98

Closed
oyvindio opened this issue Nov 8, 2021 · 3 comments · Fixed by #104

Comments

@oyvindio
Copy link
Member

oyvindio commented Nov 8, 2021

Starting from Kubernetes 1.21, the BoundServiceAccountTokenVolume feature is enabled by default. This means that the service account token at /var/run/secrets/kubernetes.io/serviceaccount/token, will be temporary and will expire after some time period. Because of this, the token must be re-read from file periodically to ensure that the client can continue to have valid authentication for requests to the apiserver. The changelog recommends reading the token every 1 minute.
Currently in-cluster configuration with this client is typically handled at the application level, i.e. applications using in-cluster configuration read the service account token from file on startup and use that to set config.api_token. To avoid having to reimplement the same token refresh mechanism in each application using the client, it probably makes sense to implement some level of support for in-cluster configuration in the client, including periodically refreshing the service account token from file.

@mortenlj
Copy link
Member

mortenlj commented Nov 8, 2021

Should take a look at #62 at the same time. It might be that the best option is to use the official clients config loading mechanism. I've had a look at it earlier, and looks possible to get something working, either by loading a config that we can use as we do today or even changing from using requests to using the api_client (iirc) from the official client library.

@oyvindio
Copy link
Member Author

oyvindio commented Dec 3, 2021

I've opened #104 to address this. I'm not sure it is necessary to couple this to #62 right now since as I understand it, using the official client library's config loading mechanism right now would require a dependency on the full client library. That doesn't seem like a ideal solution to me.
I think it makes sense to do this separately now, since implementing support for BoundServiceAccountTokenVolume here from seems relatively straightforward, and is necessary to support Kubernetes 1.21.

@oyvindio
Copy link
Member Author

oyvindio commented Dec 8, 2021

#104 is included in release v0.20.0+.

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 a pull request may close this issue.

2 participants