- Install and Configure the Kubernetes Operator >
- Install the MongoDB Enterprise Kubernetes Operator
Install the MongoDB Enterprise Kubernetes Operator¶
Prerequisites and Considerations¶
Before you install the Kubernetes Operator, make sure you plan for your installation:
- Choose a deployment topology.
- Read the Considerations.
- Complete the Prerequisites.
Note
This tutorial presumes some knowledge of Kubernetes, but does link to relevant Kubernetes documentation where possible. If you are unfamiliar with Kubernetes, please review that documentation first.
Procedure¶
The install procedure varies based on how you want to configure your environment:
- Kubernetes
- OpenShift
- Online using kubectl
- Online using Helm
- Offline using Helm and Docker
Use the same namespace throughout
The following examples assume that you created a namespace
using the default Kubernetes Operator namespace of mongodb
.
If you specified a different label for your namespace when
you created it, change all
values for metadata.namespace
to that namespace.
To change the label for the namespace for the following
deployment to production
, edit all values for
metadata.namespace
in mongodb-enterprise.yaml
:
Change to the directory in which you cloned the repository.¶
Install the CustomResourceDefinitions for MongoDB deployments using the following kubectl
command:¶
You can edit the Operator YAML file to further customize your Operator before installing it.¶
Open your
mongodb-enterprise.yaml
in your preferred text editor.You may need to add one or more of the following options:
Environment Variable When to Use OPERATOR_ENV
Label for the Operator’s deployment environment. The
env
value affects default timeouts and the format and level of logging.If OPERATOR_ENV
isLog Level is set to Log Format is set to dev
debug text prod
info json Accepted values are:
dev
,prod
.Default value is:
prod
.You can set the following pair of values:
Example
WATCH_NAMESPACE
Namespace that the Operator watches for MongoDB Kubernetes resource changes. If this namespace differs from the default, ensure that the Operator’s ServiceAccount can access that different namespace.
*
means all namespaces and requires the ClusterRole assigned to themongodb-enterprise-operator
ServiceAccount which is the ServiceAccount used to run the Kubernetes Operator.Default value is:
<metadata.namespace>
.Important
To watch Ops Manager and MongoDB Kubernetes resources in a different namespace to which you deploy the Kubernetes Operator, see Kubernetes Operator Deployment Scopes for values you must use and additional steps you might have to perform.
You can set the following pair of values:
Example
MONGODB_ENTERPRISE_DATABASE_IMAGE
URL of the MongoDB Enterprise Database image the Kubernetes Operator deploys.
Default value is
quay.io/mongodb/mongodb-enterprise-database
.Example
IMAGE_PULL_POLICY
Pull policy for the MongoDB Enterprise database image the Kubernetes Operator deploys.
Accepted values are
Always
,IfNotPresent
,Never
.Default value is
Always
.Example
OPS_MANAGER_IMAGE_REPOSITORY
URL of the repository from which the image for an Ops Manager resource is downloaded.
Default value is
quay.io/mongodb/mongodb-enterprise-ops-manager
.Example
OPS_MANAGER_IMAGE_PULL_POLICY
Pull policy for the Ops Manager images the Kubernetes Operator deploys.
Accepted values are:
Always
,IfNotPresent
,Never
.Default value is
Always
.Example
INIT_OPS_MANAGER_IMAGE_REPOSITORY
URL of the repository from which the initContainer image that contains Ops Manager start-up scripts and the readiness probe is downloaded.
Default value is
quay.io/mongodb/mongodb-enterprise-ops-manager-init
.Example
INIT_OPS_MANAGER_VERSION
Version of the initContainer image that contains Ops Manager start-up scripts and the readiness probe.
Default value is 1.0.1.
Example
APPDB_IMAGE_REPOSITORY
URL of the repository from which the Application Database image is downloaded.
Default value is
quay.io/mongodb/mongodb-enterprise-appdb
.Example
INIT_APPDB_IMAGE_REPOSITORY
URL of the repository from which the initContainer image that contains Application Database start-up scripts and the readiness probe is downloaded.
Default value is
quay.io/mongodb/mongodb-enterprise-appdb-init
.Example
INIT_APPDB_VERSION
Version of the initContainer image that contains Ops Manager start-up scripts and the readiness probe.
Default value is 1.0.2.
Example
MANAGED_SECURITY_CONTEXT
Flag that determines if the Kubernetes Operator inherits the
securityContext
settings that your Kubernetes cluster manages.Set this field to
true
if you want to run the Kubernetes Operator in OpenShift or in a restrictive environment.Default value is
false
.Example
You can install the Kubernetes Operator with Helm 3.
Change to the directory in which you cloned the repository.¶
Install the Kubernetes Operator using the following helm
command:¶
Invoke the following helm
command:
You can customize your Helm Chart before installing it. To modify it,
add one or more of the following options to the values.yaml
file:
Setting | Purpose | Default | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
namespace |
To use a different namespace, specify that |
mongodb |
|||||||||
managedSecurityContext |
Flag that determines if the Kubernetes Operator inherits the
Set this field to Example |
false |
|||||||||
operator .env |
Label for the Operator’s deployment environment. The
Accepted values are: |
prod |
|||||||||
operator .watchNamespace |
Namespace that the Operator watches for MongoDB Kubernetes resource changes. If this namespace differs from the default, ensure that the Operator’s ServiceAccount can access that different namespace.
Important To watch Ops Manager and MongoDB Kubernetes resources in a different namespace to which you deploy the Kubernetes Operator, see Kubernetes Operator Deployment Scopes for values you must use and additional steps you might have to perform. |
<metadata.namespace> |
|||||||||
operator .watchedResources |
Custom resources that the Kubernetes Operator watches. The Kubernetes Operator installs the CustomResourceDefinitions for and watches only the resources you specify. Accepted values are:
|
|
|||||||||
registry .appDb |
Repository from which the Application Database image is pulled. Specify this value if you want to pull the Ops Manager image from a private repository. |
||||||||||
registry .initAppDb |
Repository from which the Application Database initContainer image is pulled. This image contains the start-up scripts and readiness probe for the Application Database. Specify this value if you want to pull the Application Database initContainer image from a private repository. Example |
||||||||||
registry .initOpsManager |
Repository from which the Ops Manager initContainer image is pulled. This image contains the start-up scripts and readiness probe for Ops Manager. Specify this value if you want to pull the Ops Manager
Example |
||||||||||
registry .operator |
Repository from which the Kubernetes Operator image is pulled. Specify this value if you want to pull the Kubernetes Operator image from a private repository. Example |
||||||||||
registry .opsManager |
Repository from which the Ops Manager image is pulled. Specify this value if you want to pull the Ops Manager image from a private repository. Example |
Note
Alternatively, you can pass these values as options when you apply the Helm Chart:
You can install the Kubernetes Operator with Helm 3.
To install the Kubernetes Operator on a host not connected to the Internet:
Use docker
to request the files on a host connected to the Internet.¶
Replace the following values:
<op-version>
with the Kubernetes Operator version you’re installing<om-version>
with the Ops Manager version you’re installing.<db-version>
with the MongoDB Enterprise database version you’re installing.
Export the Kubernetes Operator images as .tar
archive files:¶
Replace the following values:
<op-version>
with the Kubernetes Operator version you’re installing<om-version>
with the Ops Manager version you’re installing.<db-version>
with the MongoDB Enterprise database version you’re installing.
Copy these .tar
files to the host running the Kubernetes docker
daemon.¶
Import the .tar
files into docker
.¶
Replace the following values:
<op-version>
with the Kubernetes Operator version you’re installing<om-version>
with the Ops Manager version you’re installing.<db-version>
with the MongoDB Enterprise database version you’re installing.
Install the Kubernetes Operator with modified pull policy values using the following helm
command:¶
Invoke the following helm
command:
You can customize your Helm Chart before installing it. To modify it,
add one or more of the following options to the values.yaml
file:
Setting | Purpose | Default | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
namespace |
To use a different namespace, specify that |
mongodb |
|||||||||
managedSecurityContext |
Flag that determines if the Kubernetes Operator inherits the
Set this field to Example |
false |
|||||||||
operator .env |
Label for the Operator’s deployment environment. The
Accepted values are: |
prod |
|||||||||
operator .watchNamespace |
Namespace that the Operator watches for MongoDB Kubernetes resource changes. If this namespace differs from the default, ensure that the Operator’s ServiceAccount can access that different namespace.
Important To watch Ops Manager and MongoDB Kubernetes resources in a different namespace to which you deploy the Kubernetes Operator, see Kubernetes Operator Deployment Scopes for values you must use and additional steps you might have to perform. |
<metadata.namespace> |
|||||||||
operator .watchedResources |
Custom resources that the Kubernetes Operator watches. The Kubernetes Operator installs the CustomResourceDefinitions for and watches only the resources you specify. Accepted values are:
|
|
|||||||||
registry .appDb |
Repository from which the Application Database image is pulled. Specify this value if you want to pull the Ops Manager image from a private repository. |
||||||||||
registry .initAppDb |
Repository from which the Application Database initContainer image is pulled. This image contains the start-up scripts and readiness probe for the Application Database. Specify this value if you want to pull the Application Database initContainer image from a private repository. Example |
||||||||||
registry .initOpsManager |
Repository from which the Ops Manager initContainer image is pulled. This image contains the start-up scripts and readiness probe for Ops Manager. Specify this value if you want to pull the Ops Manager
Example |
||||||||||
registry .operator |
Repository from which the Kubernetes Operator image is pulled. Specify this value if you want to pull the Kubernetes Operator image from a private repository. Example |
||||||||||
registry .opsManager |
Repository from which the Ops Manager image is pulled. Specify this value if you want to pull the Ops Manager image from a private repository. Example |
Note
Alternatively, you can pass these values as options when you apply the Helm Chart:
- Online using oc
- Online using Helm
- Offline using Helm and Docker
Use the same namespace throughout
The following examples assume that you created a namespace
using the default Kubernetes Operator namespace of mongodb
.
If you specified a different label for your namespace when
you created it, change all
values for metadata.namespace
to that namespace.
To change the label for the namespace for the following
deployment to production
, edit all values for
metadata.namespace
in mongodb-enterprise-openshift.yaml
:
Change to the directory in which you cloned the repository.¶
Install the CustomResourceDefinitions for MongoDB deployments.¶
OpenShift 3.11 or earlier
If you run OpenShift 3.11 or earlier, you must first manually edit the CustomResourceDefinitions to remove subresources. In each CustomResourceDefinition, remove the following option:
Invoke the following oc
command:
You can edit the Operator YAML file to further customize your Operator before installing it.¶
Open your
mongodb-enterprise-openshift.yaml
in your preferred text editor.You must add your
<openshift-pull-secret>
to theServiceAccount
definitions:You may need to add one or more of the following options:
Environment Variable Purpose OPERATOR_ENV
Label for the Operator’s deployment environment. The
env
value affects default timeouts and the format and level of logging.If OPERATOR_ENV
isLog Level is set to Log Format is set to dev
debug text prod
info json Accepted values are:
dev
,prod
.Default value is:
prod
.You can set the following pair of values:
Example
WATCH_NAMESPACE
Namespace that the Operator watches for MongoDB Kubernetes resource changes. If this namespace differs from the default, ensure that the Operator’s ServiceAccount can access that different namespace.
*
means all namespaces and requires the ClusterRole assigned to themongodb-enterprise-operator
ServiceAccount which is the ServiceAccount used to run the Kubernetes Operator.Default value is:
<metadata.namespace>
.Important
To watch Ops Manager and MongoDB Kubernetes resources in a different namespace to which you deploy the Kubernetes Operator, see Kubernetes Operator Deployment Scopes for values you must use and additional steps you might have to perform.
You can set the following pair of values:
Example
MONGODB_ENTERPRISE_DATABASE_IMAGE
URL of the MongoDB Enterprise Database image the Kubernetes Operator deploys.
Default value is
registry.connect.redhat.com/mongodb/mongodb-enterprise-database
.Example
IMAGE_PULL_POLICY
Pull policy for the MongoDB Enterprise database image the Kubernetes Operator deploys.
Accepted values are
Always
,IfNotPresent
,Never
.Default value is
Always
.Example
OPS_MANAGER_IMAGE_REPOSITORY
URL of the repository from which the image for an Ops Manager resource is downloaded.
Default value is
registry.connect.redhat.com/mongodb/mongodb-enterprise-ops-manager
.Example
OPS_MANAGER_IMAGE_PULL_POLICY
Pull policy for the image deployed to an Ops Manager resource.
Accepted values are
Always
,IfNotPresent
,Never
.Default value is
Always
.Example
INIT_OPS_MANAGER_IMAGE_REPOSITORY
URL of the repository from which the initContainer image that contains Ops Manager start-up scripts and the readiness probe is downloaded.
Default value is
registry.connect.redhat.com/mongodb/mongodb-enterprise-ops-manager-init
.Example
INIT_OPS_MANAGER_VERSION
Version of the initContainer image that contains Ops Manager start-up scripts and the readiness probe.
Default value is 1.0.1.
Example
APPDB_IMAGE_REPOSITORY
URL of the repository from which the Application Database image is downloaded.
Default value is
registry.connect.redhat.com/mongodb/mongodb-enterprise-appdb
.Example
INIT_APPDB_IMAGE_REPOSITORY
URL of the repository from which the
initContainer
image that contains Application Database start-up scripts and the readiness probe is downloaded.Default value is
registry.connect.redhat.com/mongodb/mongodb-enterprise-appdb-init
.Example
INIT_APPDB_VERSION
Version of the
initContainer
image that contains Ops Manager start-up scripts and the readiness probe.Default value is 1.0.2.
Example
MANAGED_SECURITY_CONTEXT
Flag that determines if the Kubernetes Operator inherits the
securityContext
settings that your Kubernetes cluster manages.For OpenShift,
MANAGED_SECURITY_CONTEXT
must always betrue
.Default value is
true
.Example
You can install the Kubernetes Operator with Helm 3.
Change to the directory in which you cloned the repository.¶
Add your OpenShift Pull Secret to the OpenShift Values file.¶
Add the name of your <openshift-pull-secret>
to the
registry.imagePullSecrets
setting in the
helm_chart/values-openshift.yaml
file:
Install the Kubernetes Operator using helm
.¶
OpenShift 3.11 or earlier
If you run OpenShift 3.11 or earlier, you must first manually edit the CustomResourceDefinitions to remove subresources. In each CustomResourceDefinition, remove the following option:
Invoke the following helm
command:
You can customize your Helm Chart before installing it. To modify it,
add one or more of the following options to the
values-openshift.yaml
file:
Setting | Purpose | Default | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
namespace |
To use a different namespace, specify that Example |
mongodb |
|||||||||
managedSecurityContext |
Flag that determines if the Kubernetes Operator inherits the
For OpenShift, Example |
true |
|||||||||
operator .env |
Label for the Operator’s deployment environment. The
Accepted values are: Example |
prod |
|||||||||
operator .watchNamespace |
Namespace that the Operator watches for MongoDB Kubernetes resource changes. If this namespace differs from the default, ensure that the Operator’s ServiceAccount can access that different namespace.
Example Important To watch Ops Manager and MongoDB Kubernetes resources in a different namespace to which you deploy the Kubernetes Operator, see Kubernetes Operator Deployment Scopes for values you must use and additional steps you might have to perform. |
<metadata.namespace> |
|||||||||
operator .watchedResources |
Custom resources that the Kubernetes Operator watches. The Kubernetes Operator installs the CustomResourceDefinitions for and watches only the resources you specify. Accepted values are:
Example |
|
|||||||||
registry .appDb |
Repository from which the Application Database image is pulled. Specify this value if you want to pull the Ops Manager image from a private repository. Example |
||||||||||
registry .imagePullSecrets |
secret that contains the credentials required to pull imagePullSecrets from the repository. Important OpenShift requires this setting. Define it in this file or pass it when you install the Kubernetes Operator using Helm. Example |
||||||||||
registry .operator |
Repository from which the Kubernetes Operator image is pulled. Specify this value if you want to pull the Kubernetes Operator image from a private repository. Example |
||||||||||
registry .opsManager |
Repository from which OpenShift pulls the Ops Manager image. Specify this value if you want to pull the Ops Manager image from a private repository. Example |
||||||||||
registry .initAppDb |
Repository from which the Application Database Specify this value if you want to pull the Application Database
Example |
||||||||||
registry .initOpsManager |
Repository from which the Ops Manager Specify this value if you want to pull the Ops Manager
Example |
Note
Alternatively, you can pass these values as options when you apply the Helm Chart:
You can install the Kubernetes Operator with Helm 3.
To install the Kubernetes Operator on a host not connected to the Internet:
Use docker
to request the files on a host connected to the Internet.¶
Replace the following values:
<op-version>
with the Kubernetes Operator version you’re installing<om-version>
with the Ops Manager version you’re installing.<db-version>
with the MongoDB Enterprise database version you’re installing.
Export the Kubernetes Operator images as .tar
archive files:¶
Replace the following values:
<op-version>
with the Kubernetes Operator version you’re installing<om-version>
with the Ops Manager version you’re installing.<db-version>
with the MongoDB Enterprise database version you’re installing.
Copy these .tar
files to the host running the Kubernetes docker
daemon.¶
Import the .tar
files into docker
.¶
Replace the following values:
<op-version>
with the Kubernetes Operator version you’re installing<om-version>
with the Ops Manager version you’re installing.<db-version>
with the MongoDB Enterprise database version you’re installing.
Add your OpenShift Pull Secret to the OpenShift Values file.¶
Add the name of your <openshift-pull-secret>
to the
registry.imagePullSecrets
setting in the
helm_chart/values-openshift.yaml
file:
Install the Kubernetes Operator with modified pull policy values.¶
OpenShift 3.11 or earlier
If you run OpenShift 3.11 or earlier, you must first manually edit the CustomResourceDefinitions to remove subresources. In each CustomResourceDefinition, remove the following option:
Invoke the following helm
command:
You can customize your Helm Chart before installing it. To modify it,
add one or more of the following options to the
values-openshift.yaml
file:
Setting | Purpose | Default | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
namespace |
To use a different namespace, specify that Example |
mongodb |
|||||||||
managedSecurityContext |
Flag that determines if the Kubernetes Operator inherits the
For OpenShift, Example |
true |
|||||||||
operator .env |
Label for the Operator’s deployment environment. The
Accepted values are: Example |
prod |
|||||||||
operator .watchNamespace |
Namespace that the Operator watches for MongoDB Kubernetes resource changes. If this namespace differs from the default, ensure that the Operator’s ServiceAccount can access that different namespace.
Example Important To watch Ops Manager and MongoDB Kubernetes resources in a different namespace to which you deploy the Kubernetes Operator, see Kubernetes Operator Deployment Scopes for values you must use and additional steps you might have to perform. |
<metadata.namespace> |
|||||||||
operator .watchedResources |
Custom resources that the Kubernetes Operator watches. The Kubernetes Operator installs the CustomResourceDefinitions for and watches only the resources you specify. Accepted values are:
Example |
|
|||||||||
registry .appDb |
Repository from which the Application Database image is pulled. Specify this value if you want to pull the Ops Manager image from a private repository. Example |
||||||||||
registry .imagePullSecrets |
secret that contains the credentials required to pull imagePullSecrets from the repository. Important OpenShift requires this setting. Define it in this file or pass it when you install the Kubernetes Operator using Helm. Example |
||||||||||
registry .operator |
Repository from which the Kubernetes Operator image is pulled. Specify this value if you want to pull the Kubernetes Operator image from a private repository. Example |
||||||||||
registry .opsManager |
Repository from which OpenShift pulls the Ops Manager image. Specify this value if you want to pull the Ops Manager image from a private repository. Example |
||||||||||
registry .initAppDb |
Repository from which the Application Database Specify this value if you want to pull the Application Database
Example |
||||||||||
registry .initOpsManager |
Repository from which the Ops Manager Specify this value if you want to pull the Ops Manager
Example |
Note
Alternatively, you can pass these values as options when you apply the Helm Chart:
Verify the Installation¶
To verify that the Kubernetes Operator installed correctly, run the following command and verify the output:
By default, deployments exist in the mongodb
namespace. If the
following error message appears, ensure you use the correct
namespace:
To troubleshoot your Kubernetes Operator, see Review Logs from the Kubernetes Operator.
Important
If you need to remove the Kubernetes Operator or the namespace, you first must remove MongoDB resources.
Next Steps¶
After installing the MongoDB Enterprise Kubernetes Operator, you can: