I've been struggling to obtain the correct hosts and (decoded) tokens from the ~/.kube/config directory on my developer machine to use this library for a few days. This has become a bigger challenge than I anticipated, as my organization uses Azure CLI with certificates to obtain these tokens for several environments via Azure Active Directory/SSO with 2FA.
Upon researching, I discovered that the official Kubernetes clients support automatically loading config files from ~/.kube/config. Here is the relevant code from their Java client, and for their JavaScript client. In particular, loadFromDetault (link) or loadFromCluster (link) seem to be the relevant functions from the JavaScript client.
The Clojure library kube-api (link) also contains an implementation in kubeconfig.clj (link) and auth.clj (link).
Another reference that might be useful is the K9s codebase (here is their config-related Go package).
Would it be interesting to have a similar feature implemented in k8s-api? This could make it easier for people with their requisite hosts and tokens in their ~/.kube/config directory to use the library with less hassle.
One possible implementation might be to use the official Kubernetes Java client to avoid porting all that code to Clojure. However, creating that dependency and using Java interop might not be desirable.
I've been struggling to obtain the correct hosts and (decoded) tokens from the
~/.kube/configdirectory on my developer machine to use this library for a few days. This has become a bigger challenge than I anticipated, as my organization uses Azure CLI with certificates to obtain these tokens for several environments via Azure Active Directory/SSO with 2FA.Upon researching, I discovered that the official Kubernetes clients support automatically loading config files from
~/.kube/config. Here is the relevant code from their Java client, and for their JavaScript client. In particular,loadFromDetault(link) orloadFromCluster(link) seem to be the relevant functions from the JavaScript client.The Clojure library
kube-api(link) also contains an implementation inkubeconfig.clj(link) andauth.clj(link).Another reference that might be useful is the K9s codebase (here is their config-related Go package).
Would it be interesting to have a similar feature implemented in
k8s-api? This could make it easier for people with their requisite hosts and tokens in their~/.kube/configdirectory to use the library with less hassle.One possible implementation might be to use the official Kubernetes Java client to avoid porting all that code to Clojure. However, creating that dependency and using Java interop might not be desirable.