# Error deploying PerconaServerMongoDB .spec.secrets.key: field not declared in schema

**URL:** <https://forums.percona.com/t/error-deploying-perconaservermongodb-spec-secrets-key-field-not-declared-in-schema/31885>\
**Category:** Percona Server for MongoDB\
**Tags:** percona, mongodb\
**Created:** [July 29, 2024, 1:51pm UTC](https://forums.percona.com/t/error-deploying-perconaservermongodb-spec-secrets-key-field-not-declared-in-schema/31885 "2024-07-29T13:51:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Biju\_Seoane](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/biju_seoane/32/11970_2.png) [@Biju\_Seoane](https://forums.percona.com/u/Biju_Seoane)\
**Post date:** [July 29, 2024, 1:51pm UTC](https://forums.percona.com/t/error-deploying-perconaservermongodb-spec-secrets-key-field-not-declared-in-schema/31885/1 "2024-07-29T13:51:26Z")

</div>

Hello there,

We are trying to deploy PerconaServerMongDB (percona-server-mongodb-4.0) in the GKE environment. We do need to deploy it using a custom mongo internal authentication key. Following this documentation ([Application and system users - Percona Operator for MongoDB](https://docs.percona.com/percona-operator-for-mongodb/users.html#mongodb-internal-authentication-key-optional)) seems you can “overwrite” the default random key generated by specifying a pre-existing secret as follows (as we did with users):

```auto
 spec:
   secrets:
     users: percona-server-mongodb-users
     key: percona-server-mongodb-keyfile

```

However, when applying this .yaml, we got the following error:

> Warning ReconciliationFailed 20s (x4 over 2m42s) kustomize-controller PerconaServerMongoDB/databases-legacy/mongo-4-0-legacy-percona dry-run failed: failed to create typed patch object: .spec.secrets.key: field not declared in schema

In fact, it seems attribute “key” is not defined in the template [percona-server-mongodb-operator/deploy/crd.yaml at v1.13.0 · percona/percona-server-mongodb-operator · GitHub](https://github.com/percona/percona-server-mongodb-operator/blob/v1.13.0/deploy/crd.yaml#L7443)

More context:

- Percona Operator version is 1.13, but we are setting it up as an unmanaged cluster.
- May PerconaServerMongDB 4.0 is a little bit old. However, using newer versions, we get the same error.

Is the documentation misleading? Is this feature not yet implemented? Are we not implementing it correctly?

---

<div class="post-metadata">

**Author:** ![Ivan\_Groenewold](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ivan_groenewold/32/6299_2.png) [@Ivan\_Groenewold](https://forums.percona.com/u/Ivan_Groenewold)\
**Post date:** [July 29, 2024, 3:18pm UTC](https://forums.percona.com/t/error-deploying-perconaservermongodb-spec-secrets-key-field-not-declared-in-schema/31885/2 "2024-07-29T15:18:10Z")

</div>

Hi, it appears there is a bug with the keyfile auth. I have created [[K8SPSMDB-1132] - Percona JIRA](https://perconadev.atlassian.net/browse/K8SPSMDB-1132) to track this down. Feel free to subscribe and upvote.

---

<div class="post-metadata">

**Author:** ![Biju\_Seoane](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/biju_seoane/32/11970_2.png) [@Biju\_Seoane](https://forums.percona.com/u/Biju_Seoane)\
**Post date:** [August 2, 2024, 9:44am UTC](https://forums.percona.com/t/error-deploying-perconaservermongodb-spec-secrets-key-field-not-declared-in-schema/31885/3 "2024-08-02T09:44:15Z")

</div>

Hello again,

As a workaround, we found a way to use a custom mongo internal authentication key by creating a Kubernetes secret with the same default secret name than Percona Operator expects before deploying Percona Server Mongo DB, as documentation [states](https://docs.percona.com/percona-operator-for-mongodb/users.html#mongodb-internal-authentication-key-optional):

> If you would like to deploy a different key, create the secret manually before starting the operator.

For instance, a Percona Server Mongo DB cluster named ‘percona-mongo’ would expect a secret named ‘percona-mongo-mongodb-keyfile’. We leave an example of a secret created before deploying Percona Server Mongo DB:

```auto
apiVersion: v1
kind: Secret
metadata:
  name: percona-mongo-mongodb-keyfile
type: Opaque
data:
  mongodb-key: <replace-this-value-with-base-64-encoded-text>

```

As mentioned before, this is a workaround to be able to use a custom mongo keyfile. However, may not work in all scenarios.

Cheers,
