<p>Small question regarding MongoDB please.</p>
<p>I am currently using the version <strong>4.4.18</strong> of MongoDB</p>
<p>I am deploying it using this manifest in Kubernetes, and no problem at all, everything is working fine, very happy.</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: mongo-config
data:
  mongo.conf: |
    storage:
      dbPath: /data/db
  ensure-users.js: |
    const targetDbStr = 'test';
    const rootUser = cat('/etc/k8-test/admin/MONGO_ROOT_USERNAME');
    const rootPass = cat('/etc/k8-test/admin/MONGO_ROOT_PASSWORD');
    const usersStr = cat('/etc/k8-test/MONGO_USERS_LIST');
    const adminDb = db.getSiblingDB('admin');
    adminDb.auth(rootUser, rootPass);
    print('Successfully authenticated admin user');
    const targetDb = db.getSiblingDB(targetDbStr);
    const customRoles = adminDb
      .getRoles({rolesInfo: 1, showBuiltinRoles: false})
      .map(role =&amp;gt; role.role)
      .filter(Boolean);
    usersStr
      .trim()
      .split(';')
      .map(s =&amp;gt; s.split(':'))
      .forEach(user =&amp;gt; {
        const username = user[0];
        const rolesStr = user[1];
        const password = user[2];
        if (!rolesStr || !password) {
          return;
        }
        const roles = rolesStr.split(',');
        const userDoc = {
          user: username,
          pwd: password,
        };
        userDoc.roles = roles.map(role =&amp;gt; {
          if (!~customRoles.indexOf(role)) {
            return role;
          }
          return {role: role, db: 'admin'};
        });
        try {
          targetDb.createUser(userDoc);
        } catch (err) {
          if (!~err.message.toLowerCase().indexOf('duplicate')) {
            throw err;
          }
        }
      });
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mongo
spec:
  serviceName: mongo
  replicas: 1
  selector:
    matchLabels:
      app: mongo
  template:
    metadata:
      labels:
        app: mongo
    spec:
      terminationGracePeriodSeconds: 30
      containers:
        - name: mongo
          image: docker.io/mongo:4.4.18
#          image: docker.io/mongo:6.0
          command: [&quot;/bin/sh&quot;]
          args: [&quot;-c&quot;, &quot;mongod --replSet=rs0 --bind_ip_all&quot;]
          resources:
            limits:
              cpu: 1000m
              memory: 1G
            requests:
              cpu: 100m
              memory: 1G
          ports:
            - containerPort: 27017
              name: mongo
              protocol: TCP
          volumeMounts:
            - name: data
              mountPath: /data/db
  volumeClaimTemplates:
    - metadata:
        name: data
      spec:
        accessModes: [ &quot;ReadWriteOnce&quot; ]
        storageClassName: nfs-1
        resources:
          requests:
            storage: 50Mi
---
apiVersion: v1
kind: Service
metadata:
  name: mongo
  labels:
    app: mongo
spec:
  selector:
    app: mongo
  ports:
    - port: 27017
      targetPort: 27017
      name: mongo
  clusterIP: None

</code></pre>
<p>Now, I just want to bump the version up to <strong>6.0</strong>, literally just replacing this one line (the one commented out), leaving everything else exactly the same.</p>
<p>I then deploy this new version, and unfortunately, this happens.</p>
<pre><code>NAME          READY   STATUS             RESTARTS      AGE
pod/mongo-0   0/1     CrashLoopBackOff   1 (10s ago)   24s
</code></pre>
<p>When tailing the log, I do see:</p>
<pre><code>{&quot;t&quot;:{&quot;$date&quot;:&quot;2022-12-07T06:50:10.048+00:00&quot;},&quot;s&quot;:&quot;F&quot;,  &quot;c&quot;:&quot;CONTROL&quot;,  &quot;id&quot;:20573,   &quot;ctx&quot;:&quot;initandlisten&quot;,&quot;msg&quot;:&quot;Wrong mongod version&quot;,&quot;attr&quot;:{&quot;error&quot;:&quot;UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: Location4926900: Invalid featureCompatibilityVersion document in admin.system.version: { _id: \&quot;featureCompatibilityVersion\&quot;, version: \&quot;4.2\&quot; }. See https://docs.mongodb.com/master/release-notes/5.0-compatibility/#feature-compatibility. :: caused by :: Invalid feature compatibility version value, expected '5.0' or '5.3' or '6.0. See https://docs.mongodb.com/master/release-notes/5.0-compatibility/#feature-compatibility.). If the current featureCompatibilityVersion is below 5.0, see the documentation on upgrading at https://docs.mongodb.com/master/release-notes/5.0/#upgrade-procedures.&quot;}}
</code></pre>
<p>I went to read the docs, but it is mainly about migrating to 5.0. May I ask what am I missing for 6.0 please?</p>
<p>Thank you</p>

PatPanda
<p>The error is due to mongodb version is not compatible with data files mounted to <code>/data/db</code>.</p>
<p>The gap between version is too large. As @WernfriedDomscheit commented you will need to upgrade it by steps:</p>
<ul>
<li>4.4 to 5.0 <a href="https://www.mongodb.com/docs/v6.0/release-notes/5.0-upgrade-replica-set/" rel="nofollow noreferrer">https://www.mongodb.com/docs/v6.0/release-notes/5.0-upgrade-replica-set/</a></li>
<li>5.0 to 6.0 <a href="https://www.mongodb.com/docs/v6.0/release-notes/6.0-upgrade-replica-set/" rel="nofollow noreferrer">https://www.mongodb.com/docs/v6.0/release-notes/6.0-upgrade-replica-set/</a></li>
</ul>
<p>If the dataset size allows, you can shortcut it by <a href="https://www.mongodb.com/docs/database-tools/mongodump/" rel="nofollow noreferrer">backing up your data</a> from v4.4, starting v6 with new empty volume mounted to /data/db, and <a href="https://www.mongodb.com/docs/database-tools/mongorestore/" rel="nofollow noreferrer">restoring</a> the database from the backup.</p>
