You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
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.
The text was updated successfully, but these errors were encountered:
leifericf
changed the title
Automatically obtain certificates and tokens from ~/.kube/config
Automatically obtain hosts and tokens from ~/.kube/configOct 24, 2023
Here is how I'm currently shelling out to kubectl to obtain the K8s servers from my ~/.kube/config file. I'm working on a similar approach to load and decode the tokens, but I haven't been able to get it working (yet).
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) 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/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.
The text was updated successfully, but these errors were encountered: