spec.preserveUnknownFields nok

Hello

I have currently operator v1.11 running.

When I want to apply :

kubectl -n abc apply --server-side -f https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/v1.12.0/deploy/bundle.yaml

customresourcedefinition.apiextensions.k8s.io/perconaservermongodbbackups.psmdb.percona.com serverside-applied
customresourcedefinition.apiextensions.k8s.io/perconaservermongodbrestores.psmdb.percona.com serverside-applied
role.rbac.authorization.k8s.io/percona-server-mongodb-operator serverside-applied
serviceaccount/percona-server-mongodb-operator serverside-applied
rolebinding.rbac.authorization.k8s.io/service-account-percona-server-mongodb-operator serverside-applied
deployment.apps/percona-server-mongodb-operator serverside-applied

The CustomResourceDefinition “perconaservermongodbs.psmdb.percona.com” is invalid: spec.preserveUnknownFields: Invalid value: true: must be false in order to use defaults in the schema

Then I get the error above.

Question: Can I / Do I have to change all the

        x-kubernetes-preserve-unknown-fields: true -> false

in bundle.yaml and apply it ?

Or is there an alternative way to do apply the bundle.yaml ?

For ex. delete the specific CustomResourceDefinition and then apply bundle.yaml ?

Hello @jamoser

We believe the error is coming due to the fact that there is default value of

                                        protocol:
                                          default: TCP

for some of the fields and the field spec.reserveUnknownFields is true.

One of the option is to set the field for PSMDB CRD like this

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: perconaservermongodbs.psmdb.percona.com
spec:
  preserveUnknownFields: false
  group: psmdb.percona.com
  names:
    kind: PerconaServerMongoDB

As the new CRD will eventually handle all the fields, we don’t see a risk in it. But please try to test before applying to a critical environment.

Hope this helps!

1 Like

Thank you - it worked.

Nice, glad to hear that!

1 Like