Migrating Docker Compose to Kubernetes

All production instances of HCL Accelerate must be installed on a Kubernetes platform. As a part of this migration, the instance of MongoDB need to be re-installed in a Kubernetes-accessible location. To migrate your MongoDB database, follow the steps below. After completion of these steps, follow the Kubernetes installation procedure to complete the installation of HCL Accelerate.

About this task

To migrate a Docker Compose MongoDB database to Kubernetes complete the following steps:


  1. Export the existing Docker Compose MongoDB database.
    1. Navigate to MongoDB database container shell.

      docker exec -it <mongo_db_service> bash

    2. Export all data from the MongoDB database.

      mongodump dump.tar

    3. Exit the MongoDB database container shell.


    4. Copy the dump folder out of the MongoDB database container.

      docker cp <mongo_db_service>:/dump.tar <destination>

      Save the destination location of the MongoDB export to use in the final step.

  2. Install MongoDB database in Kubernetes.
    1. Install the MongoDB Helm chart with a root password of your choice.
      helm install accelerate_mongo --set mongodbRootPassword=<root_password> bitnami/mongodb
  3. Create a non-root MongoDB user.
    1. Navigate to MongoDB database's Kubernetes pod.

      kubectl exec -it --namespace default accelerate_mongo /bin/bash

    2. Open a MongoDB Shell session as the root user.

      mongo admin -u root -p <root_password>

    3. Create a non-root MongoDB user with the following roles and permissions.
      user: "<new_username>", 
      pwd: "<new_password>", 
      roles: [{role: "readWriteAnyDatabase", 
      db: "admin"}, {role: "dbAdminAnyDatabase", 
      db: "admin"}, {role: "clusterAdmin", 
      db: "admin"
    4. Exit the MongoDB Shell.


  4. Restore the Docker Compose database dump to the new MongoDB pod.
    1. Use kubectl get pods to get all pods. Identify the MongoDB pod.
    2. Copy database dump folder from the Docker Compose installation location into the MongoDB pod.

      kubectl cp <dump.tar file directory of docker compose_mongodb>accelerate_mongo:/tmp/

    3. Navigate to MongoDB pod shell.

      kubectl exec -it --namespace default accelerate_mongo/bin/bash

    4. Change directory to dump directory.

      cd /tmp/dump.tar

    5. List all MongoDB folder to verify the contents.


      Note: Each folder is a database in MongoDB.
    6. Restore all database except ADMIN

      mongorestore --uri="mongodb://<non_root_username>:<non_root_password>@localhost:27017/?authSource=admin" <db_name> -d <db_name>

      Note: Delete the Docker Compose MongoDB export that was copied into the Kubermetes MongoDB pod at your earliest convenience.
    7. Exit MongoDB pod shell.


      The new MongoDB server is ready for use. For Kubernetes installation directions, see this page.