Mongodb percona operator CRD kustomize incorrectly merging yamls with patchesStrategicMerge

Details:
Operator Version 1.13.0 (Deployed with kubectl apply)

Kustomize strategic merge patch omit properties when applied over percona mongofb operator CRD.

For example base/percona-mongo:

apiVersion: psmdb.percona.com/v1
kind: PerconaServerMongoDB
metadata:
  name: db-platform-mongo
spec:
replsets:
    - name: rs0
      size: 1
      affinity:
        antiAffinityTopologyKey: "kubernetes.io/hostname"
      volumeSpec:
        persistentVolumeClaim:
          storageClassName: standard

overlay/qa/percona-mongo:

apiVersion: psmdb.percona.com/v1
kind: PerconaServerMongoDB
metadata:
  name: db-platform-mongo
spec:
  replsets:
    - name: rs0
      size: 1
      volumeSpec:
        persistentVolumeClaim:
          storageClassName: rook-cephfs-replica-3

kustomization result misses:

      affinity:
        antiAffinityTopologyKey: "kubernetes.io/hostname"

It seems to be caused by kustomize not knowing which openapi schema the operator CRD follows, as described in this article: https://blog.argoproj.io/argo-crds-and-kustomize-the-problem-of-patching-lists-5cfc43da288c.

In this forum post I found a reference to a migration to openapi schema. Would you mind providing me a url to that resource? So I can apply it in a kustomization file like this:

...
openapi:
  path: https://github.com/argoproj/argo-schema-generator/raw/main/schema/argo_all_k8s_kustomize_schema.json
2 Likes

Hi @Alejandro_Recalde,

We generate the OpenAPI schema and include it into our CRD but the blog post you linked explains the need of exporting the schema as json. Currently there’s no URL to provide, unfortunately. I created [K8SPSMDB-805] Generate OpenAPI schema separately as json - Percona JIRA to understand the problem and provide the schema if needed.

2 Likes

Thanks @Ege_Gunes,

As a workaround we decided to use kustomize patchesJson6902 as it is only the storage class that varies between environments. However applying patchesStrategicMerge would prove very convenient when other customizations per environment might be required

1 Like