Skip to content

preserveUnknownFields=false doesn't work with crdVersions=v1 #476

Closed
@jonnylangefeld

Description

@jonnylangefeld

crdVersions=v1 which is the new default, doesn't work in conjunction with preserveUnknownFields=false. The spec.preserveUnknownFields simply doesn't appear in the crd. There is an integration test for v1beta1, but not for v1.

I'm running the following command in a kubebuilder repo:

controller-gen "crd:preserveUnknownFields=false,crdVersions=v1" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases

I'm using defaults in my schema and if applying to a 1.16.13-gke.1 cluster, I get:

The CustomResourceDefinition "foo.example.com" is invalid: spec.preserveUnknownFields: Invalid value: true: must be false in order to use defaults in the schema

If I add spec.preserveUnknownFields manually to the crd it works

My workaround in the makefile right now is

yq w -i config/crd/bases/cluster.paas.getcruise.com_clusters.yaml spec.preserveUnknownFields false

Metadata

Metadata

Assignees

Labels

lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions