Upgrade the MongoDB Enterprise Kubernetes Operator
On this page
The following procedure outlines how to upgrade the Kubernetes Operator to its latest version. This upgrade process parallels the Kubernetes Operator installation process.
Upgrade the MongoDB Enterprise Kubernetes Operator Running in Kubernetes
Note
Use the same namespace throughout
By default, the Kubernetes Operator deploys all resources in your Kubernetes cluster
to the namespace mongodb
. You can deploy Kubernetes Operator resources
to a different namespace by editing all values for
metadata.namespace
in mongodb-enterprise.yaml
:
##--- # Source: mongodb-enterprise-operator/templates/serviceaccount.yaml apiVersion: v1 kind: ServiceAccount metadata: name: mongodb-enterprise-operator namespace: production ##--- # Source: mongodb-enterprise-operator/templates/operator.yaml apiVersion: apps/v1 kind: Deployment metadata: name: mongodb-enterprise-operator namespace: production # Example truncated ...
Customize your Kubernetes Operator YAML before upgrading it.
To avoid breaking changes, you should ensure that you select the same settings as those in your existing deployment. To learn about optional Kubernetes Operator installation settings, see Operator Helm Installation Settings.
Upgrade to the new version of the Kubernetes Operator.
Populate the <version>
placeholder and run the following kubectl
command to deploy your chosen version of the Kubernetes Operator to your Kubernetes cluster:
kubectl apply -f https://raw.githubusercontent.com/mongodb/mongodb-enterprise-kubernetes/<version>/mongodb-enterprise.yaml
Use the MongoDB Helm Charts for Kubernetes.
Update to the latest version of the MongoDB Helm Charts for Kubernetes.
Run the following command to check the version of your current Helm template:
helm search repo mongodb/enterprise-operator
If your currently installed version is not the latest release, run the following commmand to update your Helm repo:
helm repo update mongodb
If you don't have the Helm repo installed locally, you can install it by running:
helm repo add mongodb https://mongodb.github.io/helm-charts
Customize your Helm Chart before upgrading it.
To avoid breaking changes, you should ensure that you select the same settings as those in your existing deployment. To learn about optional Kubernetes Operator installation settings, see Operator Helm Installation Settings.
Upgrade the Kubernetes Operator.
Run the following helm
command to deploy the Kubernetes Operator to the
default namespace in your Kubernetes cluster:
helm install enterprise-operator mongodb/enterprise-operator
You can pass the --namespace
and --namespace-create
flags to deploy
the Kubernetes Operator to a non-default namespace, like so:
helm install enterprise-operator mongodb/enterprise-operator \ --namespace mongodb \ --create-namespace
Upgrade the MongoDB Enterprise Kubernetes Operator Running in OpenShift
The following steps depend on how your environment is configured:
Note
Use the same namespace throughout
By default, the Kubernetes Operator deploys all resources in your Kubernetes cluster
to the namespace mongodb
. You can deploy Kubernetes Operator resources
to a different namespace by editing all values for
metadata.namespace
in mongodb-enterprise-openshift.yaml
:
##--- # Source: mongodb-enterprise-operator/templates/serviceaccount.yaml apiVersion: v1 kind: ServiceAccount metadata: name: enterprise-operator namespace: production ##--- # Source: mongodb-enterprise-operator/templates/operator.yaml apiVersion: apps/v1 kind: Deployment metadata: name: enterprise-operator namespace: production # Example truncated ...
Customize the Kubernetes Operator YAML before upgrading it.
To avoid breaking changes, you should ensure that you select the same settings as those in your existing deployment. To learn about optional Kubernetes Operator installation settings, see Operator Helm Installation Settings.
You must add your <openshift-pull-secret>
to the
ServiceAccount
definitions:
# Source: mongodb-enterprise-operator/templates/serviceaccount.yaml apiVersion: v1 kind: ServiceAccount metadata: name: enterprise-operator namespace: mongodb imagePullSecrets: - name: <openshift-pull-secret> apiVersion: v1 kind: ServiceAccount metadata: name: mongodb-enterprise-appdb namespace: mongodb imagePullSecrets: - name: <openshift-pull-secret> apiVersion: v1 kind: ServiceAccount metadata: name: mongodb-enterprise-database-pods namespace: mongodb imagePullSecrets: - name: <openshift-pull-secret>
Upgrade to the new version of the Kubernetes Operator.
Populate the <version>
placeholder and run the following oc:
oc apply -f https://raw.githubusercontent.com/mongodb/mongodb-enterprise-kubernetes/<version>/mongodb-enterprise-openshift.yaml
Upgrade the CustomResourceDefinitions for MongoDB deployments.
Run the following oc command:
Populate the <version>
placeholder and run the following oc
command to deploy your chosen version of the CRDs to your Kubernetes cluster:
oc apply -f https://raw.githubusercontent.com/mongodb/mongodb-enterprise-kubernetes/<version>/crds.yaml
Update to the latest version of the MongoDB Helm Charts for Kubernetes.
Run the following command to check the version of your current Helm template:
helm search repo mongodb/enterprise-operator
If your currently installed version is not the latest release, run the following commmand to update your Helm repo:
helm repo update mongodb
If you don't have the Helm repo installed locally, you can install it by running:
helm repo add mongodb https://mongodb.github.io/helm-charts
Customize your Helm Chart before upgrading it.
To avoid breaking changes, you should ensure that you select the same settings as those in your existing deployment. To learn about optional Kubernetes Operator installation settings, see Operator Helm Installation Settings.
Upgrade the Kubernetes Operator.
Run the following helm
command to deploy the Kubernetes Operator to the
default namespace in your Kubernetes cluster:
helm install enterprise-operator mongodb/enterprise-operator
You can pass the --namespace
and --namespace-create
flags to deploy
the Kubernetes Operator to a non-default namespace, like so:
helm install enterprise-operator mongodb/enterprise-operator \ --namespace mongodb \ --create-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.
Verify the Installation
To verify that the Kubernetes Operator installed correctly, run the following command and verify the output:
kubectl describe deployments mongodb-enterprise-operator -n <metadata.namespace>
oc describe deployments mongodb-enterprise-operator -n <metadata.namespace>
By default, deployments exist in the mongodb
namespace. If the
following error message appears, ensure you use the correct
namespace:
Error from server (NotFound): deployments.apps "mongodb-enterprise-operator" not found
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.
Next Steps
After upgrading the MongoDB Enterprise Kubernetes Operator, you can: