-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Cannot change kube config at runtime #2240
Comments
def load_kube_config(config_file=None, context=None,
client_configuration=None,
persist_config=True,
temp_file_path=None):
...
if config_file is None:
config_file = KUBE_CONFIG_DEFAULT_LOCATION As you can see here, this appears to be because it does not use the KUBECONFIG environment variable, but rather uses global variables within the library. |
Thanks for the answer. But from the code I would expect an config.load_kube_config(config_file="/path/to/second.kubeconfig") to be working. But that also does not change the config in the client. |
I wonder if the default config behavior is related here: https://github.com/kubernetes-client/python/blob/master/CHANGELOG.md#v1201. Could you take a look? |
/assign @roycaihw |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
Hey, guys! |
Hello, guys! Do you have any plans to support reset/change config for this client? |
Hello there! It seems this issue has affected many people. Guys, please add an option to reset/replace the config; it significantly impacts tests when we need to rebuild the cluster. Thanks! |
could you send a PR? thanks. |
What happened (please include outputs or screenshots):
For unit testing, I want to change the kubeconfig file at runtime and after the import of the config module. As my tests module imports the productive module, the imports are executed before fixtures and patches are executed. When I then change the value of the KUBECONFIG environment variable, the Kubernetes client ignores that change.
What you expected to happen:
Cluster can be switched at runtime by changing the KUBECONFIG env var.
How to reproduce it (as minimally and precisely as possible):
This is a short example that shows, that changes to the KUBECONFIG environment variable after the import of the configmodule are ignored. Changes to the env var before the import are followed.
Anything else we need to know?:
I've already tried without success:
Successful was to run kubectl from Python with subprocess.run(...), that way the updated KUBECONFIG env var is followed. But I need it in this package.
Environment:
Kubernetes version (
kubectl version
):Client Version: v1.29.3
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.28.3
OS (e.g., MacOS 10.13.6): MacOS 14.4.1
Python version (
python --version
): 3.12.3Python client version (
pip list | grep kubernetes
): 29.0.0The text was updated successfully, but these errors were encountered: