Docs Menu
Docs Home
/
MongoDB Controllers for Kubernetes Operator
/ /

Upgrade the MongoDB Controllers for Kubernetes Operator

The following procedure outlines how to upgrade the Kubernetes Operator to its latest version. This upgrade process parallels the Kubernetes Operator installation process.

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-kubernetes.yaml:

---
apiVersion: v1
kind: ServiceAccount
metadata:
name: mongodb-kubernetes-operator
namespace: production
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongodb-kubernetes-operator
namespace: production
---
# Example truncated
---
...
1

Run the following kubectl command to deploy your chosen version of the CRDs to your Kubernetes cluster:

kubectl apply -f https://raw.githubusercontent.com/mongodb/mongodb-kubernetes/1.4.0/public/crds.yaml
2

Run the following command to get the configuration details of your currently deployed Kubernetes Operator:

kubectl get deployment <operator-deployment-name> -n <namespace> -o yaml
3

If needed, find the appropriate example deployment YAML file for your chosen version of the Kubernetes Operator in the GitHub repository. Then, to avoid breaking changes, customize the example YAML file to match the configuration details of your currently deployed Kubernetes Operator.

4

Deploy your customized Kubernetes Operator by running the following:

kubectl apply -f <customized-operator-yaml-file>.yaml

If you do not need to modify the provided deployment YAML, you can apply it directly as follows:

kubectl apply -f https://raw.githubusercontent.com/mongodb/mongodb-enterprise-kubernetes/1.4.0/mongodb-enterprise-multi-cluster.yaml
kubectl apply -f https://raw.githubusercontent.com/mongodb/mongodb-enterprise-kubernetes/1.4.0/public/mongodb-kubernetes.yaml

Use the MongoDB Helm Charts for Kubernetes.

1

Run the following command to check the version of your current Helm template:

helm search repo mongodb/mongodb-kubernetes

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
2

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.

3

Run the following kubectl command to deploy the CRDs to your Kubernetes cluster:

kubectl apply -f https://raw.githubusercontent.com/mongodb/mongodb-kubernetes/1.4.0/public/crds.yaml
4

Run the following helm command to deploy the Kubernetes Operator to the default namespace in your Kubernetes cluster:

helm upgrade --install mongodb-kubernetes-operator mongodb/mongodb-kubernetes

You can pass the --namespace and --namespace-create flags to deploy the Kubernetes Operator to a non-default namespace, like so:

helm upgrade --install mongodb-kubernetes-operator mongodb/mongodb-kubernetes \
--namespace mongodb \
--create-namespace

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-kubernetes-openshift.yaml:

---
apiVersion: v1
kind: ServiceAccount
metadata:
name: mongodb-kubernetes-operator
namespace: production
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongodb-kubernetes-operator
namespace: production
---
# Example truncated
---
...
1

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:

---
apiVersion: v1
kind: ServiceAccount
metadata:
name: enterprise-operator
namespace: mongodb
imagePullSecrets:
- name: <openshift-pull-secret>
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: mongodb-kubernetes-appdb
namespace: mongodb
imagePullSecrets:
- name: <openshift-pull-secret>
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: mongodb-kubernetes-database-pods
namespace: mongodb
imagePullSecrets:
- name: <openshift-pull-secret>
2

Run the following oc command:

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-kubernetes/1.4.0/public/crds.yaml
3

Run the following oc command to deploy your chosen version of the Kubernetes Operator to your Kubernetes cluster:

oc apply -f https://raw.githubusercontent.com/mongodb/mongodb-kubernetes/1.4.0/public/mongodb-kubernetes-openshift.yaml
1

Run the following command to check the version of your current Helm template:

helm search repo mongodb/mongodb-kubernetes

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
2

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.

3

Run the following kubectl command to deploy the CRDs to your Kubernetes cluster:

kubectl apply -f https://raw.githubusercontent.com/mongodb/mongodb-kubernetes/1.4.0/public/crds.yaml
4

Run the following helm command to deploy the Kubernetes Operator to the default namespace in your Kubernetes cluster:

helm upgrade --install mongodb-kubernetes-operator mongodb/mongodb-kubernetes

You can pass the --namespace and --namespace-create flags to deploy the Kubernetes Operator to a non-default namespace, like so:

helm upgrade --install mongodb-kubernetes-operator mongodb/mongodb-kubernetes \
--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.

To verify that the Kubernetes Operator installed correctly, run the following command and verify the output:

kubectl describe deployments mongodb-kubernetes-operator -n <metadata.namespace>
oc describe deployments mongodb-kubernetes-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-kubernetes-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.

After upgrading the MongoDB Controllers for Kubernetes Operator, you can:

On this page