Description
Hey there,
I'm working on a project that involves Kuberentes and Agones. (Note that I'm pretty new to both so I'm maybe doing it wrong)
The issue I have is that KubernetesObjectApi.read
requires a name to perform the request and return a result. If we don't give them a name it will throw a Required spec property name is not set
Error.
If I understand this correctly this mean we cannot use this method to list resources.
I found a (very ugly) workaround, by giving a /
as the name of the resource, and now it will list them correctly.
import { KubeConfig, KubernetesObjectApi } from '@kubernetes/client-node';
const kc = new KubeConfig();
kc.loadFromDefault();
const client = KubernetesObjectApi.makeApiClient(kc);
client
.read({
apiVersion: 'v1',
kind: 'Pod',
metadata: { name: '/' }, // if we remove this line, we can not list pods
})
.then(console.log)
Note that I used Pods in this example to show the basic idea, in my particular case I'm trying to list Agones Game Servers.
Is that a known issue? Or is there an other method to list resources? Would it be possible to remove the constraint on the name for the read
action, so we can use it to list resources?