K8S: Can I get my cluster's KUBECONFIG via Google's Kubernetes Engine API? (not via gcloud container clusters get-credentials)

1/29/2019

I'm writing a Node app that's designed to monitor (and patch parts of) a Kubernetes cluster hosted on Google's Kubernetes Engine.

I'd like to do this using the kubernetes-client module, however in order to access the cluster, I need to first supply it with a KUBECONFIG for that cluster. Now I gather that i'd do this locally using the gcloud container clusters get-credentials [CLUSTER_NAME] command which would populate my local KUBECONFIG file for me.

However is there a way to do this using Google's Kubernetes Engine API, within my NodeJS app?

-- John Bergqvist
kubernetes
node.js

1 Answer

1/31/2019

There is no straight way on how to achieve GKE API connection from godaddy/kubernetes-client as not much information is available in this project, developed by community enthusiasts. Seems it requires kubectl proxy to be enabled on GKE side to get authorized with Kubernetes REST API, which was confirmed by some Stack contributors. However, it's feasible to manage connection to GKE API with Go and Python via appropriate plugins as described here.

I would search something more about the other NodeJS client libraries, like: github.com/Goyoo/node-k8s-client or github.com/tenxcloud/node-kubernetes-client.

-- mk_sta
Source: StackOverflow