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

Fix kubeconfig with no clusters #360

Conversation

jacobtomlinson
Copy link
Member

Closes #358

In cases where you are using a service account for authentication there may still be a kubeconfig file containing other configuration items. The example in #358 shows using the kubeconfig to store the default namespace.

In these cases the list of clusters in the kubeconfig is None. This PR updates the config to handle that situation. Config objects correctly report None when there are no clusters, but it is still possible to read the namespace from the config.

The auth module has then been updated to load the namespace from the config and then fall back to service account authentication.

I also took this opportunity to update KubeConfig and KubeConfigSet to accept dicts instead of paths for programatically creating a kubeconfig as this was useful when writing the tests. This partially implements #357.

@jacobtomlinson jacobtomlinson added bug Something isn't working kr8s auth Authenticating with Kubernetes labels Apr 23, 2024
@github-actions github-actions bot added the tests label Apr 23, 2024
@jacobtomlinson jacobtomlinson merged commit 6dba956 into kr8s-org:main Apr 24, 2024
10 checks passed
@jacobtomlinson jacobtomlinson deleted the kubeconfig-settings-with-service-account branch April 24, 2024 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Authenticating with Kubernetes bug Something isn't working kr8s tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fails to load KubeConfig if "clusters" is null
1 participant