Upgrade MongoDB
MongoDB is a database service used by CircleCI Server. This page describes how to upgrade MongoDB from version 3.6.22 to 7.0.15.
MongoDB 3.6.22 is shipped with CircleCI Server 4.9.
Upgrade MongoDB to 4.4
Prerequisites
-
Ensure backups have been taken. You need a backup of MongoDB to restore in case anything goes wrong during the upgrade progress.
-
You are able to modify your
values.yamlfile. -
helm upgradeworks from your system to upgrade the cluster. -
Your MongoDB root password is available.
Scripted upgrade
We have created a shell script that you can use to upgrade your cluster’s MongoDB instance here.
Alternatively, you can use the following instructions to manually upgrade your cluster’s MongoDB:
Manual upgrade
1. Upgrade from MongoDB 3.6 to 4.0
-
Your
values.yamlshould contain the following snippet:mongodb: image: tag: 3.6.22-debian-9-r38To begin the upgrade process, change the tag to
4.0.27-debian-9-r118:mongodb: image: tag: 4.0.27-debian-9-r118 -
Run
helm upgradeto update your installation. -
Once the
helm upgradehas completed and MongoDB has rolled, you will need toexecinto the pod (with the root password handy) to modify the compatibility version. (Be sure to replace<password>with your MongoDB root password.)$ kubectl exec -it mongodb-0 -- mongo -u root -p <password> db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } ) -
You should get a
{ "ok" : 1 }response from Mongo. Exit out of the MongoDB shell and pod.
2. Upgrade from MongoDB 4.0 to 4.2
-
Change the tag to
4.2.21-debian-10-r8:mongodb: image: tag: 4.2.21-debian-10-r8 -
Run
helm upgradeto update your installation. -
Once the
helm upgradehas completed and MongoDB has rolled, you will need toexecinto the pod (with the root password handy) to modify the compatibility version. (Be sure to replace<password>with your MongoDB root password.)$ kubectl exec -it mongodb-0 -- mongo -u root -p <password> db.adminCommand( { setFeatureCompatibilityVersion: "4.2" } ) -
You should get
{ "ok" : 1 }again. Exit out of the shell and pod.
3. Upgrade from MongoDB 4.2 to 4.4
-
Change the tag one more time to
4.4.15-debian-10-r8:mongodb: image: tag: 4.4.15-debian-10-r8 -
Run
helm upgradeto update your installation. -
Once the
helm upgradehas completed and MongoDB has rolled, you will need toexecinto the pod (with the root password handy) to modify the compatibility version. (Be sure to replace<password>with your MongoDB root password.)$ kubectl exec -it mongodb-0 -- mongo -u root -p <password> db.adminCommand( { setFeatureCompatibilityVersion: "4.4" } ) -
Once you receive
{ "ok" : 1 }, you have successfully upgraded your MongoDB to 4.4.15.
Upgrade MongoDB to 7.0
Prerequisites
-
You have completed the
4.4.15upgrade above. -
Ensure backups have been taken. You need a backup of MongoDB to restore in case anything goes wrong during the upgrade progress.
-
You are able to modify your
values.yamlfile. -
helm upgradeworks from your system to upgrade the cluster. -
Your MongoDB root password is available.
Scripted upgrade
We have created a shell script that you can use to upgrade your cluster’s MongoDB instance here.
Alternatively, you can use the following instructions to manually upgrade your cluster’s MongoDB:
Manual upgrade
1. Upgrade from MongoDB 4.4 to 5.0
-
Your
values.yamlshould contain the following snippet:mongodb: image: tag: 4.4.15-debian-10-r8To begin the upgrade process, change the tag to
5.0.24-debian-11-r20and update the probes to usemongosh:mongodb: image: tag: 5.0.24-debian-11-r20 livenessProbe: enabled: false readinessProbe: enabled: false customLivenessProbe: exec: command: - mongosh - --eval - "db.adminCommand('ping')" initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 5 successThreshold: 1 failureThreshold: 6 customReadinessProbe: exec: command: - bash - -ec - | mongosh --eval 'db.hello().isWritablePrimary || db.hello().secondary' | grep -q 'true' initialDelaySeconds: 5 periodSeconds: 10 timeoutSeconds: 5 successThreshold: 1 failureThreshold: 6 -
Run
helm upgradeto update your installation. -
Once the
helm upgradehas completed and MongoDB has rolled, you will need toexecinto the pod (with the root password handy) to modify the compatibility version. Note that MongoDB 5.0+ usesmongoshinstead ofmongo. (Be sure to replace<password>with your MongoDB root password.)$ kubectl exec -it mongodb-0 -- mongosh -u root -p <password> db.adminCommand( { setFeatureCompatibilityVersion: "5.0" } ) -
You should get an
{ "ok" : 1 }response from MongoDB. Exit out of the MongoDB shell and pod.
2. Upgrade from MongoDB 5.0 to 6.0
-
Change the tag to
6.0.13-debian-11-r21while being sure to keep the newcustomLivenessProbeandcustomReadinessProbeparameters.:mongodb: image: tag: 6.0.13-debian-11-r21 -
Run
helm upgradeto update your installation. -
Once the
helm upgradehas completed and MongoDB has rolled, you will need toexecinto the pod (with the root password handy) to modify the compatibility version. (Be sure to replace<password>with your MongoDB root password.)$ kubectl exec -it mongodb-0 -- mongosh -u root -p <password> db.adminCommand( { setFeatureCompatibilityVersion: "6.0" } ) -
You should get
{ "ok" : 1 }`again. Exit out of the shell and pod.
3. Upgrade from MongoDB 6.0 to 7.0
-
Change the tag to
7.0.15-debian-12-r2:mongodb: image: tag: 7.0.15-debian-12-r2 -
Run
helm upgradeto update your installation. -
Once the
helm upgradehas completed and MongoDB has rolled, you will need toexecinto the pod (with the root password handy) to modify the compatibility version (be sure to replace<password>with your MongoDB root password.)MongoDB 7.0+ upgrade is one-way and cannot be downgraded. MongoDB 7.0+ requires the confirm: trueparameter.$ kubectl exec -it mongodb-0 -- mongosh -u root -p <password> db.adminCommand( { setFeatureCompatibilityVersion: "7.0", confirm: true } ) -
Once you receive
{ "ok" : 1 }`, you have successfully upgraded your MongoDB to 7.0.15.