Natasha Grosella
Natasha Grosella

Reputation: 25

how i may get name of all namespaces (@kubernetes/client-node)

I work with API kuberneteswith (library is @kubernetes/client-node). I can to get a list of pods of specigic namespace, but i don`t understand to get a list of name all namespaces How i may code with @kubernetes/client-node?

Upvotes: 0

Views: 1658

Answers (1)

coderanger
coderanger

Reputation: 54181

In the corev1 API, it's listNamespace.

const k8s = require('@kubernetes/client-node');

const kc = new k8s.KubeConfig();
kc.loadFromDefault();

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

k8sApi.listNamespace().then((res) => {
    console.log(res.body);
});

Upvotes: 1

Related Questions