I'm trying to use the client-go to create pods and other resources on my cluster.
From what I understand the best way to create stuff on your cluster using client-go is to use the dynamic-create version (in the examples there is a dynamic-create-update-delete example). Because I can just take my yaml and make it into unstructured.Unstructured and then create the resource.
This is working fine for me while creating pods using kind: Deployment
but when I try to create a pod with the kind: PersistentVolumeClaim
I get an error:
panic: PersistentVolumeClaim in version "v1" cannot be handled as a Deployment: converting (v1.PersistentVolumeClaim).v1.PersistentVolumeClaimSpec to (apps.Deployment).apps.DeploymentSpec: Replicas not present in src
If I understand the error correctly this happen because I declare my deploymentRes with the resource: "deployments"
deploymentRes := schema.GroupVersionResource{Group: "apps", Version: "v1", Resource: "deployments"}
And then create with the:
client.Resource(deploymentRes).Namespace(namespace).Create(context.TODO(), deployment, metav1.CreateOptions{})
The problem here is that I can't find what to put instead of Resource: "deployments"
when I want to create a pvc. I have tried to put in persistentvolumeclaim
but just get the err:
"panic: the server could not find the requested resource"
Please if you know anything that could help, or put me in the right direction would be super helpful!
Thanks!