deno-kubernetes_apis
deno-kubernetes_apis copied to clipboard
getConfigMap is not a function
Hi,
I'm trying to run this code
import { autoDetectClient, readAllItems, Reflector} from "https://deno.land/x/[email protected]/mod.ts";
import { CoreV1Api } from 'https://deno.land/x/kubernetes_apis/builtin/core@v1/mod.ts';
const client = await autoDetectClient();
const coreApi = new CoreV1Api(client);
await coreApi.getConfigMap("cluster-info");
but I get this error
error: Uncaught (in promise) TypeError: coreApi.getConfigMap is not a function
await coreApi.getConfigMap("cluster-info");
Could this be related to the fact that on deno.land/x the latest version is 0.5? https://deno.land/x/[email protected]/builtin/core@v1/mod.ts
Hello, it looks like you are interacting with CoreV1Api when you expect to have a CoreV1NamespacedApi instead. This is important when working with any namespaced resource.
You can select either the default namespace (from kubeconfig, or based on the pod when running in-cluster):
await coreApi.myNamespace().getConfigMap("cluster-info");
Or you can name a particular namespace:
await coreApi.namespace("kube-public").getConfigMap("cluster-info");
If you're only working with one particular namespace, you may find it cleaner to change the declaration of coreApi instead:
const client = await autoDetectClient();
const coreApi = new CoreV1Api(client).namespace("kube-public");
await coreApi.getConfigMap("cluster-info");
Hope this helps
Closing for inactivity. Feel free to comment still if you have further concerns with this.