When we look up which Kubernetes server to connect to we use the following order:
URL explicitly passed to kr8s in Python
Server configured in kubeconfig
Server set by service account
In #360 we added support for loading the default namespace from the context set in the kubeconfig even if we are falling all the way back to using a service account credentials.
I noticed today that this is not the case when a URL is explicitly passed to kr8s. In this situation we always use the default namespace "default".
In #360 it was reasonable to add this because users may be inside a Pod that has a service account, but want to configure their default namespace. In this case a very minimal kubeconfig is created with just this information in.
In the case where a URL is being provided we are intentionally overriding the kubeconfig, so perhaps we don't want to try and look up the default namespace from that config. It's not clear if the current behaviour is expected. It would be good to see that kubectl does.
Which project are you reporting a bug for?
kr8s
What happened?
When we look up which Kubernetes server to connect to we use the following order:
kr8s
in PythonIn #360 we added support for loading the default namespace from the context set in the kubeconfig even if we are falling all the way back to using a service account credentials.
I noticed today that this is not the case when a URL is explicitly passed to
kr8s
. In this situation we always use the default namespace"default"
.In #360 it was reasonable to add this because users may be inside a Pod that has a service account, but want to configure their default namespace. In this case a very minimal kubeconfig is created with just this information in.
In the case where a URL is being provided we are intentionally overriding the kubeconfig, so perhaps we don't want to try and look up the default namespace from that config. It's not clear if the current behaviour is expected. It would be good to see that
kubectl
does.Anything else?
No response