Failed to create MongoDB operator and DB cluster in different namespaces

Hello there,

Trying to create operator and cluster into different namespaces, i.e.,
operator: percona-mongo-operator
db: percona-mongo-db
Kubernetes: OCI OKE
Code is checked out from: GitHub - percona/percona-server-mongodb-operator: Percona Operator for MongoDB
Instructions: Install Percona server for MongoDB on Kubernetes

After apply cr.yaml with command, no pods created in namespace: percona-mongo-db

kubectl apply -f deploy/cr.yaml -n  percona-mongo-db

Below is a snippet from cr.yaml

apiVersion: psmdb.percona.com/v1-12-0
kind: PerconaServerMongoDB
metadata:
  name: my-cluster-name
  namespace: percona-mongo-db

Anyone please advise anything is missed?

Best regards,

Arthur

1 Like

You have to apply the namespace to all resources, so in your case for ex :

namespace: percona-mongo-db-1
1 Like

Thanks, Jamoser.

I had typo in my first post. Just fixed it.

kubectl apply -f deploy/cr.yaml -n  percona-mongo-db
1 Like

May be you should post a little bit more, how about kubectl -n percona-mongo-db get all

Besides you need to deploy more then cr.yaml → operator.yaml and secrets

1 Like

I followed the instructions from Generic Kubernetes installation - Percona Operator for MongoDB

crd, operator, secrets, rbac have been created.

Below is my console output with command: kubectl -n percona-mongo-db get all

percona-server-mongodb-operator $ kubectl delete -f deploy/cr.yaml -n percona-mongo-db --v=5

perconaservermongodb.psmdb.percona.com "my-cluster-name" deleted

percona-server-mongodb-operator $ kubectl apply -f deploy/cr.yaml -n percona-mongo-db --v=5

perconaservermongodb.psmdb.percona.com/my-cluster-name created

percona-server-mongodb-operator $ kubectl -n percona-mongo-db get all

No resources found in percona-mongo-db namespace.

percona-server-mongodb-operator $
1 Like

the operator log is attached, hope it helps to figure out what is wrong.

$ k get crd |grep mongo
perconaservermongodbbackups.psmdb.percona.com    2022-01-23T17:18:16Z
perconaservermongodbrestores.psmdb.percona.com   2022-01-23T17:18:16Z
perconaservermongodbs.psmdb.percona.com          2022-01-23T17:18:16Z

$ k get all -n percona-mongo-operator -o wide
NAME                                                   READY   STATUS    RESTARTS   AGE   IP            NODE            NOMINATED NODE   READINESS GATES
pod/percona-server-mongodb-operator-58c459565b-gr228   1/1     Running   0          23h   10.51.0.194   172.30.137.36   <none>           <none>

NAME                                              READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS                        IMAGES                                            SELECTOR
deployment.apps/percona-server-mongodb-operator   1/1     1            1           23h   percona-server-mongodb-operator   perconalab/percona-server-mongodb-operator:main   name=percona-server-mongodb-operator

NAME                                                         DESIRED   CURRENT   READY   AGE   CONTAINERS                        IMAGES                                            SELECTOR
replicaset.apps/percona-server-mongodb-operator-58c459565b   1         1         1       23h   percona-server-mongodb-operator   perconalab/percona-server-mongodb-operator:main   name=percona-server-mongodb-operator,pod-template-hash=58c459565b
[operator.log|attachment](upload://kzDXXeV3c2OYf2k4NAFQaGjNXFv.log) (199.0 KB)
1 Like

you must put the whole cluster in a namespace - that means the operator and mongodb

2 Likes

It says:

Deploying a database with Percona Operators creates pods that are namespace scoped. This provides interesting opportunities to run workloads on different namespaces for different teams, projects, and potentially, customers too.

Example: Percona Distribution for MongoDB Operator and Percona Server for MongoDB can be run on two different namespaces by adding namespace metadata fields.
from document: Multi-Tenant Kubernetes Cluster with Percona Operators.

1 Like

Well works perfectly fine for me to run the whole cluster incl operator in a single namespace. You can make things complicated.

1 Like

Hi @A_Niu,

In the blog post you quote there is a operator deployment for each namespace. MongoDB Operator doesn’t support cluster wide deployments and you need to deploy the operator and the database cluster into same namespace.

1 Like

Thanks for clarification!

1 Like