Closed Cosrider closed 2 years ago
Inserting the entire corev1.PersistentVolumeClaim golang struct into your struct probably isn't a good idea; at the very least there will be a bunch of stuff in there like the Status that you don't need. It would probably be a better idea to only specify the specific fields you care about (name, size, maybe other things), and manually add those fields to the spec of your custom type.
I need some additional information to specifically help you, though. What exactly are you using the PVC for? Is this intended to create a dependent PVC or point to an existing one or something else?
to create a dependent PVC. my operator will generate a statefulset, the cr's VolumeClaimTemplate information is used for statefulset's volumeClaimTemplates. as the VolumeClaimTemplate's name lost, pvc can’t be created.
Ok, then you should only manually add the fields to your object spec that are strictly necessary to instantiate the PVC, and have the controller create it, like how the Deployments are created in the memcached example controller. We don't insert the entire deployment object into our CRD, we only collect the information we want the user to specify (the number of nodes).
ok, thanks.
Bug Report
What did you do?
k8s.io\api\core\v1\types.go
contents of crds generated by operator-sdk
in the generated crd, volumeClaimTemplate's metadata type is ojbect and lost properties
What did you expect to see?
when get crd crName -oyaml ; expect to see :
What did you see instead? Under which circumstances?
metadata' field name is lost, Actually {}
Environment
Possible Solution
i have to edit crd Manually and add some needed fields