1

I have kubernetes cluster on my GCP platform and I want to get Node's list in my cluster by using client-node lib.

    const cluster = {
        name: 'my-cluster-1',
        server: 'https://endpoints.googleapis.com',
    };

    const user = {
        name: 'myemail@gmail.com',
        password: 'mypassword',
    };
    const kc = new k8s.KubeConfig();
    kc.loadFromClusterAndUser(cluster, user);

    const k8sApi = kc.makeApiClient(k8s.CoreV1Api);

    k8sApi.listNode()
        .then((res) => {
            console.log('RESULT: ' + JSON.stringify(res));
        })
        .catch((err) => {
            console.log('ERROR: ' + err);
        });

But this code fails with Bad Gateway message.

Tummala Dhanvi
  • 3,007
  • 2
  • 19
  • 35
Ted
  • 1,682
  • 3
  • 25
  • 52

1 Answers1

0

Kubernetes client lib expects the Kubernetes user credentials which are not the same as the Gmail/Gsuite credentials.

Get the user credentials for cluster using gcloud container clusters get-credentials [CLUSTER_NAME]

and then load the config as below

const kc = new k8s.KubeConfig();
kc.loadFromDefault();
Tummala Dhanvi
  • 3,007
  • 2
  • 19
  • 35