- Install and Configure the Kubernetes Operator >
- Install the MongoDB Enterprise Kubernetes Operator
Install the MongoDB Enterprise Kubernetes Operator¶
On this page
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 and links to relevant Kubernetes documentation. If you are unfamiliar with Kubernetes, please review that documentation first.
Choose one of the following installation procedures to install the Kubernetes Operator:
Install with Kubernetes¶
The installation procedure varies based on how you want to configure your environment:
- 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
:
Install the CustomResourceDefinitions for MongoDB deployments using the following kubectl
command:¶
Invoke the following kubectl
command:
Optional: Customize the Kubernetes Operator YAML before installing it.¶
To learn about optional Kubernetes Operator installation settings, see Operator kubectl and oc Installation Settings.
Use the MongoDB Helm Charts for Kubernetes.
You can install the Kubernetes Operator with Helm 3.
Add the MongoDB Helm Charts for Kubernetes repository to Helm.¶
Install the Kubernetes Operator:¶
Install MongoDB Helm Charts for Kubernetes.
The following command installs the CustomResourceDefinitions and the Kubernetes Operator
in the current namespace named default
. By default, the
Kubernetes Operator uses the default
namespace.
The following command installs the Kubernetes Operator in the mongodb
namespace with the optional --create-namespace
option.
To learn about optional Kubernetes Operator installation settings, see Operator Helm Installation Settings.
Use the MongoDB Helm Charts for Kubernetes.
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 version of the MongoDB Enterprise Database image that you want to use.
See also
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 version of the MongoDB Enterprise Database image that you want to use.
See also
Copy these .tar
files to the host running the Kubernetes docker
daemon.¶
Import the .tar
files into docker
.¶
Add the MongoDB Helm Charts for Kubernetes repository to Helm.¶
Install the Kubernetes Operator with modified pull policy values using the following helm
command:¶
Install MongoDB Helm Charts for Kubernetes
and set the value of registry.pullPolicy
to IfNotPresent
.
To learn about optional Kubernetes Operator installation settings, see
Operator Helm Installation Settings.
Install with OpenShift¶
Before you begin, ensure that the MANAGED_SECURITY_CONTEXT
flag is set
to true
when you deploy the Kubernetes Operator to OpenShift. This value is
pre-defined in the values-openshift.yaml file.
The installation procedure varies based on how you want to configure your environment:
- 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
:
Navigate to the directory in which you cloned the MongoDB Enterprise Kubernetes Operator repository.¶
For example, if you cloned the repository in your home directory, run:
Install the CustomResourceDefinitions for MongoDB deployments.¶
Invoke the following oc
command:
Optional: Customize the Kubernetes Operator YAML before installing it.¶
To learn about optional Kubernetes Operator installation settings, see Operator kubectl and oc Installation Settings.
Add your <openshift-pull-secret>
to the ServiceAccount
definitions in the Kubernetes Operator YAML before installing it.¶
To learn more, see the registry.imagePullSecrets
setting in the
Helm installation settings.
Use the MongoDB Helm Charts for Kubernetes.
You can install the Kubernetes Operator with Helm 3.
Add the MongoDB Helm Charts for Kubernetes repository to Helm.¶
Install the Kubernetes Operator using helm
.¶
Install MongoDB Helm Charts for Kubernetes:
Use the values-openshift.yaml settings. To learn about optional Kubernetes Operator installation settings, see Operator Helm Installation Settings.
Use the MongoDB Helm Charts for Kubernetes.
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 version of the MongoDB Enterprise Database image that you want to use.
See also
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 version of the MongoDB Enterprise Database image that you want to use.
See also
Copy these .tar
files to the host running the Kubernetes docker
daemon.¶
Import the .tar
files into docker
.¶
Add the MongoDB Helm Charts for Kubernetes repository to Helm.¶
Install the Kubernetes Operator with modified pull policy values.¶
Install MongoDB Helm Charts for Kubernetes:
Use the values-openshift.yaml
settings, registry.pullPolicy=IfNotPresent
, and
registry.imagePullSecrets=<openshift-pull-secret>
. To learn
about optional Kubernetes Operator installation settings, see
Operator Helm Installation Settings.
Verify the Installation¶
To verify that the Kubernetes Operator installed correctly, run the following command and verify the output:
- Using kubectl
- Using oc
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 and other troubleshooting topics.
Important
If you need to remove the Kubernetes Operator or the namespace, you first must remove MongoDB resources.
Install a Specific Daily Build with Helm¶
MongoDB rebuilds Kubernetes Operator images every day to integrate the latest security and OS updates.
By default, helm
installs the latest build for the version of
the Kubernetes Operator you specify.
To install an earlier build, specify the build ID as a parameter with
--set build=<build-id>
. Build IDs are always in the format
-b<YYYYMMDD>T000000Z
, where <YYYYMMDD>
is the date that the
build you want to use was created.
Example
This example shows how to install the Kubernetes Operator with the latest image:
This example shows how to install the Kubernetes Operator with the image created at midnight on February 5th, 2021:
Note
MongoDB recommends using the default (latest) build.
Next Steps¶
After installing the MongoDB Enterprise Kubernetes Operator, you can: