Two clusters in same namespace

my question is simple

I have one working cluster and I created another one. The only issue is visible that operators are conflicting between each other.

So second operator is:

apiVersion: apps/v1

kind: Deployment

metadata:

 name: percona-xtradb-cluster-operator-2

 namespace: ptest

spec:

 replicas: 1

 selector:

  matchLabels:

   name: percona-xtradb-cluster-operator-2

 template:

  metadata:

   labels:

    name: percona-xtradb-cluster-operator-2

  spec:

   serviceAccountName: percona-xtradb-cluster-operator-2

   containers:

    - name: percona-xtradb-cluster-operator-2

     image: percona/percona-xtradb-cluster-operator:1.4.0

     ports:

     - containerPort: 60000

      name: metrics

     command:

     - percona-xtradb-cluster-operator

     imagePullPolicy: Always

     env:

      - name: WATCH_NAMESPACE

       valueFrom:

        fieldRef:

         fieldPath: metadata.namespace

      - name: OPERATOR_NAME

       value: "percona-xtradb-cluster-operator-2"

Any way to specify that it should use cluster2 instead of cluster1?

$ k get pods -n ptest

NAME                                                READY   STATUS    RESTARTS   AGE

cluster1-proxysql-0                                 3/3     Running   0          45m

cluster1-proxysql-1                                 3/3     Running   0          46m

cluster1-proxysql-2                                 3/3     Running   0          46m

cluster1-pxc-0                                      1/1     Running   0          44m

cluster1-pxc-1                                      1/1     Running   0          46m

cluster1-pxc-2                                      1/1     Running   0          45m

cluster2-proxysql-0                                 3/3     Running   0          7m23s

cluster2-proxysql-1                                 3/3     Running   0          8m11s

cluster2-proxysql-2                                 3/3     Running   0          13m

cluster2-pxc-0                                      1/1     Running   0          15m

cluster2-pxc-1                                      1/1     Running   0          16m

cluster2-pxc-2                                      1/1     Running   0          17m

percona-xtradb-cluster-operator-2-556564484-pwdj9   1/1     Running   0          26m

percona-xtradb-cluster-operator-7f96c796d7-tpmk8    1/1     Running   0          48m

In operator’s log I can see that these names of “cluster1” and “cluster2” are conflicting. So not right name used in first or second operator.

{"level":"error","ts":1605774801.487967,"logger":"controller_perconaxtradbcluster","caller":"pxc/controller.go:124","msg":"Update status","error":"send update: Operation cannot be fulfilled on perconaxtradbclusters.pxc.percona.com \"cluster2\": the object has been modified; please apply your changes to the latest version and try again","stacktrace":"github.com/percona/percona-xtradb-cluster-operator/vendor/github.com/go-logr/zapr.(*zapLogger).Error
\t/go/src/github.com/percona/percona-xtradb-cluster-operator/vendor/github.com/go-logr/zapr/zapr.go:128
github.com/percona/percona-xtradb-cluster-operator/pkg/controller/pxc.(*ReconcilePerconaXtraDBCluster).Reconcile.func1
\t/go/src/github.com/percona/percona-xtradb-cluster-operator/pkg/controller/pxc/controller.go:124
github.com/percona/percona-xtradb-cluster-operator/pkg/controller/pxc.(*ReconcilePerconaXtraDBCluster).Reconcile
\t/go/src/github.com/percona/percona-xtradb-cluster-operator/pkg/controller/pxc/controller.go:254
github.com/percona/percona-xtradb-cluster-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
\t/go/src/github.com/percona/percona-xtradb-cluster-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:207
github.com/percona/percona-xtradb-cluster-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func1
\t/go/src/github.com/percona/percona-xtradb-cluster-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:157
github.com/percona/percona-xtradb-cluster-operator/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil.func1
\t/go/src/github.com/percona/percona-xtradb-cluster-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:133
github.com/percona/percona-xtradb-cluster-operator/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil
\t/go/src/github.com/percona/percona-xtradb-cluster-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:134
github.com/percona/percona-xtradb-cluster-operator/vendor/k8s.io/apimachinery/pkg/util/wait.Until\n\t/go/src/github.com/percona/percona-xtradb-cluster-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:88"}

You only need one operator per namespace.

With one operator you can start multiple cluster instances in that namespace.