-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting 'crd.spec.preserveUnknownFields: false' on CRD resources #116
Comments
@munnerz , I started looking into this, and was about to write an E2E test for
|
I had this issue on |
Some versions of kubernetes incorrectly served openapi schemas for non-structural CRDs, so you may be using one of these affected versions. We should set this to false regardless though as our schema is already structural/valid 😀 |
In order to make features like
kubectl explain
work to easily inspect the schema of custom resources, settingpreserveUnknownFields
to false is required.You can read more details here: https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#pruning-versus-preserving-unknown-fields
It is required because the apiserver will only publish complete OpenAPI schemas for structural CRDs. The side effect of setting this field is that any fields submitted that are not recognised in the schema will be automatically rejected by kubectl unless
--validate=false
is set, and the apiserver will also drop fields it does not recognise automatically.If we are concerned our schema is not accurate/complete due to potential bugs in our project, you can use the
crd-schema-fuzz
project to run fuzz tests against our CRDs: https://github.com/munnerz/crd-schema-fuzzYou can see an example of this in use here: https://github.com/jetstack/cert-manager/blob/ba354e40784fbed5a25e7796aa54472a3d38a058/pkg/internal/apis/certmanager/install/pruning_test.go#L29-L30
The text was updated successfully, but these errors were encountered: