kr8s-org / kr8s

A batteries-included Python client library for Kubernetes that feels familiar for folks who already know how to use kubectl
https://kr8s.org
BSD 3-Clause "New" or "Revised" License
839 stars 45 forks source link

Read namespace from kubeconfig when explicitly passing URL #425

Open jacobtomlinson opened 4 months ago

jacobtomlinson commented 4 months ago

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:

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.

Anything else?

No response