Examples are pretty limited, so going off what my IDE shows me and what I dig up from the source code. Having trouble.
I created my CRD already. I want to post it. Currently, its just a github webhook with a payload that I plan to trim later. I can't seem to find the right constructor to pass to KubeConfig's makeApiClient function. I have the CRD, and I originally thought it was Custom_objectsApi, but that's only for the CRD creation and not a new Custom Object of my type.
Is there a way to do this? Do I have to make a new class myself? Can I just post raw yaml if that's the case?
Here is my CRD as well as the json I am trying to post.
const yamlString = k8s.dumpYaml({
"apiVersion": "hook-to-k8s.sfxworks.net/v1",
"kind": "Payload",
"metadata": {
"type": "github",
"name": event.payload.repository.name,
"sha": event.payload.after,
"head commit author": event.payload.head_commit.author.name
},
"spec": {
"payload": event.payload
}
})
Edit: Could we possibly go into explaining our down-vote actions instead of not doing so? I don't see a reason to at this point. Other users may also have this question.
To clarify I am trying to post a object that has a kind using the CRD I created. Not a new CRD.
Edit 2: For reference, using https://www.npmjs.com/package/@kubernetes/client-node
If you've already built your CRD, you can access the objects in the kubernetes api like this.
const k8s = require('@kubernetes/client-node');
const kc = new k8s.KubeConfig()
kc.loadFromDefault();
const k8sClient = kc.makeApiClient(k8s.CustomObjectsApi);
resp = k8sClient.getNamespacedCustomObjectStatus('api.yourorg.io', apiVersion', namespace, crdKind, objName)
// resp.body is your object. for example resp.body.spec.