A
u
Belaid Youba Hadj Arab, Etienne Deneuve
Aug 27, 2023 · 3 min read

How upgrade MonogDB Community on AKS

Side view worker wearing gloves

Comment upgrade Mongodb Community sur son AKS

Here we’ll look at how to upgrade Mongodb Community from 4.4.10 to 7.0.0 . No matter how hard I searched, I couldn’t find anything to help me, so I might as well help those who will have to deal with it!

Mongodb Community

  1. Let’s start with a simple deployment, with one user and one database :
apiVersion: mongodbcommunity.mongodb.com/v1
kind: MongoDBCommunity
metadata:
name: my-mongo
namespace: mongo
spec:
additionalMongodConfig:
storage.wiredTiger.engineConfig.journalCompressor: zlib
members: 3
security:
authentication:
ignoreUnknownUsers: true
modes:
- SCRAM
tls:
enabled: false
statefulSet:
spec:
template:
spec:
containers:
- name: mongod
resources:
limits:
cpu: '3'
memory: 4Gi
requests:
cpu: '2'
memory: 2Gi
- name: mongodb-agent
resources:
limits:
cpu: '0.5'
memory: 512M
requests:
cpu: '0.2'
memory: 200M
type: ReplicaSet
users:
- name: admin
db: admin
scramCredentialsSecretName: my-scram-admin
passwordSecretRef:
name: admin-password
roles:
- name: clusterAdmin
db: admin
- name: userAdminAnyDatabase
db: admin
- name: dev-db
db: dev-db
scramCredentialsSecretName: my-scram-dev
passwordSecretRef:
name: dev-db-password
roles:
- name: readWrite
db: dev-db
version: 4.4.10
featureCompatibilityVersion: '4.4'
  1. Here there are 2 scenarios: in the first, you have this featureCompatibilityVersion in your yaml and in this case bravo, if not you must add it as in the example above.

  2. Access the primary pod, then connect to the database :

Terminal window
mongo -u admin -p PASSWORD --authenticationDatabase admin
  1. Once in the database, place these commands :
Terminal window
# passer en admin
use admin
# Verifier le eatureCompatibilityVersion
db.adminCommand({getParameter: 1,featureCompatibilityVersion: 1})
  1. If all goes well, you should get a result that says :

    Terminal window
    {
    "featureCompatibilityVersion" : {
    "version" : "4.4" # we're on the right version
    },
    "ok" : 1,
    "$clusterTime" : {
    "clusterTime" : Timestamp(1692709763, 3),
    "signature" : {
    "hash" : BinData(0,"G2h/IOKY+TIMtryV9dDkEt2rlkw="),
    "keyId" : NumberLong("7263035781982191620")
    }
    },
    "operationTime" : Timestamp(1692709763, 3)
    }
  2. If you get the wrong result, just place this command and test again:

    Terminal window
    db.adminCommand( { setFeatureCompatibilityVersion: "4.4" } )
  3. Now that the featureCompatibilityVersion corresponds to the mongodb version, you can perform the upgrade. Just change the versions :

    version: 5.0.0
    featureCompatibilityVersion: '5.0'

IMPORTANT NOTE: to upgrade from version 4.4.10 to 7.0.0, for example, you must go through the intermediate major releases, i.e. 4.4.10->5.0.0->6.0.9->7.0.0.

  1. Wait for all pods to redeploy, then repeat step 4 to check that the mongo version corresponds to the featureCompatibilityVersion version, otherwise repeat step 6.

IMPORTANT NOTE: for the featureCompatibilityVersion, here are the versions to use: 4.4, 5.0, 6.0 and 7.0.

Conclusion

Now you can upgrade your mongodb without any featureCompatibilityVersion problems.

Tutorial Mongo

Related articles