- Install and Configure the Kubernetes Operator >
- Plan your MongoDB Enterprise Kubernetes Operator Installation >
- Set Scope for MongoDB Enterprise Kubernetes Operator Deployment
Set Scope for MongoDB Enterprise Kubernetes Operator Deployment¶
On this page
Before you install the Kubernetes Operator, you can set the scope of the Kubernetes Operator deployment. The scopes depend on the namespaces in which you choose to deploy Ops Manager and MongoDB Kubernetes resources.
Kubernetes Operator Deployment Scopes¶
You can set one of these scopes:
- Operator Uses Same Namespace as Resources (Default)
- Operator Uses Different Namespace than Resources
- Operator Uses Cluster-Wide Scope
Operator Uses Same Namespace as Resources¶
You can set the scope for the Kubernetes Operator to use the same namespace as resources. In this case, the Kubernetes Operator watches Ops Manager and MongoDB Kubernetes resources in that same namespace.
When you install the Kubernetes Operator, it uses the default namespace.
Operator Uses Different Namespace than Resources¶
You can set the scope for the Kubernetes Operator to use a different namespace than its resources. In this case, the Kubernetes Operator watches Ops Manager and MongoDB Kubernetes resources in a namespace that you specify.
You can use helm
to install the Kubernetes Operator with this scope.
Follow the relevant installation instructions for helm
, but use the following command to
set the namespace for the Kubernetes Operator to watch:
Setting the namespace ensures that:
- The namespace you want the Kubernetes Operator to watch has the correct
ClusterRole and ClusterRoleBinding. The
clusterRole
andclusterRoleBinding
are included in the default configuration files that you apply during the installation. To create theclusterRole
andclusterRoleBinding
, you must have cluster-admin privileges. - The Kubernetes Operator can watch and create resources in this namespace.
Operator Uses Cluster-Wide Scope¶
You can set the scope for the Kubernetes Operator to the Kubernetes cluster. In this case, the Kubernetes Operator watches Ops Manager and MongoDB Kubernetes resources in all namespaces in the Kubernetes cluster.
Important
You can deploy only one instance of the Kubernetes Operator with a cluster-wide scope per Kubernetes cluster.
To set a cluster-wide scope for the Kubernetes Operator, follow the instructions for your preferred installation method.
- Kubernetes
- OpenShift
- Using kubectl
- Using Helm
Before you deploy the Kubernetes Operator, configure the following items:
Use the mongodb-enterprise.yaml sample YAML file from the MongoDB Enterprise Kubernetes Operator GitHub repository.
Set the
spec.template.spec.containers.name.env.name:WATCH_NAMESPACE
in mongodb-enterprise.yaml to*
.In mongodb-enterprise.yaml, change:
to:
Add the following code to the
ClusterRole
that you have just modified:In mongodb-enterprise.yaml, change:
to:
Create all required local Kubernetes service accounts and secrets.
In the following sample YAML file, replace
<namespace>
with the namespace in which you want the Kubernetes Operator to deploy resources.
Before you deploy the Kubernetes Operator, configure the following items:
Configure the Kubernetes Operator to watch all namespaces:
Create the required service accounts for each namespace where you want to deploy Ops Manager and MongoDB Kubernetes resources:
- Using oc
- Using Helm
Before you deploy the Kubernetes Operator, configure the following items:
Use the mongodb-enterprise-openshift.yaml sample YAML file from the MongoDB Enterprise Kubernetes Operator GitHub repository.
Set the
spec.template.spec.containers.name.env.name:WATCH_NAMESPACE
in mongodb-enterprise-openshift.yaml to*
.In mongodb-enterprise-openshift.yaml, change:
to:
Add the following code to the
ClusterRole
that you have just modified:In mongodb-enterprise-openshift.yaml, change:
to:
Create all required local Kubernetes service accounts and secrets.
In the following sample YAML file, replace
<namespace>
with the namespace in which you want the Kubernetes Operator to deploy resources. Useoc
or the OpenShift Container Platform user interface to apply the resulting YAML file.
Before you deploy the Kubernetes Operator, configure the following items:
Configure the Kubernetes Operator to watch all namespaces:
Create the required service accounts for each namespace where you want to deploy Ops Manager and MongoDB Kubernetes resources:
Next Steps¶
After setting up the scope for the MongoDB Enterprise Kubernetes Operator, you can:
- Read the Considerations.
- Complete the Prerequisites.
- Install the Kubernetes Operator.