python/config
Eric Menendez 70b78cd848 Refresh exec-based API credentials when they expire
This is a fix for kubernetes-client/python#741.

As described in kubernetes-client/python#741, some of the authentication schemes supported by Kubernetes require updating the client's credentials from time to time. The Kubernetes Python client currently does not support this, except for when using the `gcp` auth scheme. This is because the OpenAPI-generated client code does not generally expect credentials to change after the client is configured.

However, in OpenAPITools/openapi-generator#3594, the OpenAPI generator added a (undocumented) hook on the `Configuration` object which provides a method for the client credentials to be refreshed as needed. Now that this hook exists, the `load_kube_config()` function, used by the Kubernetes API to set up the `Configuration` object from the client's local k8s config, just needs to be updated to take advantage of this hook.

This patch does this for `exec`-based authentication, which should resolve kubernetes-client/python#741.

Also, as noted above, `load_kube_config()` already has a special-case monkeypatch to refresh GCP tokens. I presume this functionality was added before the OpenAPI generator added support for the refresh hook. This patch also refactors the GCP token refreshing code to use the new hook instead of the monkeypatch.

Tests are also updated.
2021-09-03 15:53:25 -06:00
..
__init__.py do expanduser in load_config 2021-07-12 11:21:13 +02:00
config_exception.py Remove all shebangs from Python modules and checker 2019-08-27 22:18:52 +02:00
dateutil_test.py Remove all shebangs from Python modules and checker 2019-08-27 22:18:52 +02:00
dateutil.py Remove all shebangs from Python modules and checker 2019-08-27 22:18:52 +02:00
exec_provider_test.py Remove all shebangs from Python modules and checker 2019-08-27 22:18:52 +02:00
exec_provider.py Remove all shebangs from Python modules and checker 2019-08-27 22:18:52 +02:00
incluster_config_test.py Fix trivial typo in error messages - 'does not exist' vs. 'does not exists' 2021-03-19 05:56:27 +01:00
incluster_config.py Fix trivial typo in error messages - 'does not exist' vs. 'does not exists' 2021-03-19 05:56:27 +01:00
kube_config_test.py Refresh exec-based API credentials when they expire 2021-09-03 15:53:25 -06:00
kube_config.py Refresh exec-based API credentials when they expire 2021-09-03 15:53:25 -06:00