One-line enhancement description (can be used as a release note): Pruning for Custom Resources
Kubernetes Enhancement Proposal:
CustomResources store arbitrary JSON data without following the typical Kubernetes API behaviour to prune unknown fields. This makes CRDs different, but also leads to security and general data consistency concerns because it is unclear what is actually stored in etcd.
This KEP proposes to add pruning of all fields which are not specified in the OpenAPI validation schemas given in the CRD.
Pruning will be opt-in in v1beta1 of apiextensions.k8s.io via
i.e. CRDs created in v1beta1 default to disabled pruning.
Pruning will be enabled for every CRD created in v1 and we will hide preserveUnknownFields in v1 in that case.
Pruning can be disabled for subtrees of CustomResources by setting the x-kubernetes-preserve-unknown-fields: true vendor extension. This allows to store arbitrary JSON or RawExtensions. This will even be possible at the root level, even in v1. Adding that in every to each object in a schema leads to the old behaviour.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.