Open functicons opened 4 years ago
This doesn't seem to be supported by Kubebuilder https://github.com/kubernetes-sigs/kubebuilder/issues/1174. Still not aware of how to solve it.
Do you mean pruning function? If so, since version 1.15 it seems to be supported by k8s apiserver.
I tested this feature in 1.15, but there were another problem. controller-tools included in kubebuilder is not able to create a "structural schema" intact. To use the pruning feature, the openapi validation schema must be defined as "structural schema". There are two issues with structural schema that are problematic.
https://github.com/kubernetes-sigs/controller-tools/issues/304 (resolved recently) https://github.com/kubernetes-sigs/controller-tools/issues/279
controller-tools 0.2.4 included in kubebuilder v2.2.0 supports the generation of CRD V1 and structural schema, which allows you to use preserveUnknownFields. If you are using k8s 1.15 this issue seems to be resolved.
I have tested generating CRD with controller-tools 0.2.4, deploying CRD to k8s 1.15 cluster and deploying CR with unknown field, and api-server-validation works well.
Thanks, will check!
Currently, the operator doesn't reject unknown fields in the CR which makes it error-prone. We need to validate this.