gocardless / theatre

GoCardless' collection of Kubernetes extensions
MIT License
23 stars 17 forks source link

Preserve metadata in console template CRD #230

Closed dyson closed 3 years ago

dyson commented 3 years ago

Now that we are using apiextensions.k8s.io/v1 for our CRDs kubernetes will prune unknown fields during validation of the resource. Unfortunately, controller-gen currently assumes that validation of the ObjectMeta fields will happen server side by the API server and so it doesn't generate any validation information for it. This is true for the root ObjectMeta but not true for nested ObjectMeta fields, resulting in the API server stripping all fields from metadata as all fields look unknown to it. Creating our own PodTemplateSpec and telling the API server to preserve unknown fields for the metadata object is a workaround until controller-gen fixes the issue.

See https://github.com/kubernetes-sigs/controller-tools/blob/master/pkg/crd/known_types.go#L37-L41 for the offending code in controller-gen.