Skip to content

Rate this page
☆ ☆ ☆ ☆ ☆
Thanks for your feedback
Thank you! The feedback has been submitted.

Get free database assistance or contact our experts for personalized support.

Install Percona Operator for MongoDB in multi-namespace (cluster-wide) mode

This document walks you through installing the Operator and Percona Server for MongoDB in multi-namespace (cluster-wide) mode with default parameters.

To learn more about available deployment modes, see Single-namespace and multi-namespace deployment modes.

To install Percona Operator for MongoDB with custom parameters, see Install Percona Operator for MongoDB with custom parameters.

To install the Operator cluster-wide, use the YAML files in the deploy folder with the cw- prefix, such as deploy/cw-bundle.yaml.

Key configuration steps:

Edit the Operator deployment section of the deploy/cw-bundle.yaml and specify the following:

  • Set subjects.namespace to the namespace where the Operator will run.
  • In the env section, set WATCH_NAMESPACE to a comma-separated list of namespaces you want the Operator to watch.
  • To watch all namespaces, set WATCH_NAMESPACE to an empty string (“”).

Below is a streamlined example for cluster-wide setup on Kubernetes:

  1. Clone the percona-server-mongodb-operator repository:

    git clone -b v1.23.1 https://github.com/percona/percona-server-mongodb-operator
    cd percona-server-mongodb-operator
    
  2. Create the namespaces: one for the Operator and another one for the database cluster:

    kubectl create namespace psmdb-operator
    kubectl create namespace psmdb  # Namespace to be watched by the Operator
    
  3. Edit deploy/cw-bundle.yaml and set the namespaces accordingly:

    ...
    subjects:
    - kind: ServiceAccount
      name: percona-server-mongodb-operator
      namespace: "psmdb-operator"
    ...
    env:
      - name: WATCH_NAMESPACE
        value: "psmdb"
    
  4. Apply the cluster-wide bundle:

    kubectl apply -f deploy/cw-bundle.yaml --server-side -n psmdb-operator
    

    This creates Custom Resource Definitions, role-based access control, clusterrolebindings and the Operator Deployment.

  5. Verify the Deployment:

    kubectl get deploy -n psmdb-operator
    
  6. Once the Operator is running, create a MongoDB cluster:

    kubectl apply -f deploy/cr.yaml -n psmdb
    
  7. Check the cluster’s status:

    kubectl get psmdb -n psmdb
    
    Expected output
    NAME              ENDPOINT                                         STATUS   AGE
    my-cluster-name   my-cluster-name-mongos.psmdb.svc.cluster.local   ready    5m26s
    

Next steps

Verify the cluster operation


Last update: September 17, 2026
Created: September 15, 2022