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.
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.