Migrating DevOps Velocity from Docker Compose to Kubernetes or OpenShift

You can find information about migrating HCL DevOps Velocity (Velocity) from a Docker Compose environment to a Kubernetes or OpenShift platform.

About this task

To migrate Velocity from a Docker Compose environment to a Kubernetes or OpenShift cluster, you must first export the MongoDB database and restore it to a new instance either on a standalone virtual machine (VM) or on the Kubernetes or OpenShift cluster. In addition to migrating the data, you must copy specific encryption keys from the .env file located in the installation folder on the Docker environment and update the accelerate-tokens templates in the Helm chart and then install Velocity. These keys are required to decrypt passwords and other sensitive values stored in MongoDB.

Procedure

  1. Determine your MongoDB deployment environment from the following options.
    • Install MongoDB on a standalone virtual machine (VM), and provide the MongoDB connection URL during the installation of Velocity.
      Note: You should consider this method as it offers simplicity, stability, and dedicated resources, making it easier to manage and maintain the database for Velocity. Also, ensure that the VM is accessible from the Kubernetes or OpenShift cluster and that the MongoDB port is open. The default port is 27017.
    • Install MongoDB within the Kubernetes or OpenShift cluster by using Helm or Operator.
      Note: If you want to install MongoDB within the Kubernetes or OpenShift cluster, you should deploy MongoDB as a StatefulSet to ensure persistent storage and stable network identities.
  2. Perform the following steps to export the existing MongoDB database from the Docker Compose container:
    1. Run the following command to open a shell to the MongoDB database container:
      docker exec -it <mongo_db_service> bash
    2. Run the following command to export the database by using mongodump:
      mongodump --uri=mongodb://localhost:27017 --gzip --archive=dump.tgz
    3. Run the following command to exit from the MongoDB container shell:
      exit
    4. Run the following command to copy the database dump file from the MongoDB container to your host:
      docker cp <mongo_db_service>:/dump.tgz <destination>
      Note: Make a note of the destination path as it is required during the restore process.
  3. Perform the following steps to install MongoDB in a standalone VM and create a non-root MongoDB user:
    1. Install MongoDB in a standalone VM. For more information, refer to MongoDB Documentation.
    2. Connect to the VM by using the ssh connection.
    3. Run the following command winthin the VM to start the MongoDB shell as the root user.
      mongo admin -u root -p <root_password>
    4. Run the following command to switch to the admin database:
      use admin
    5. Run the following command to create a non-root user with the required roles:
      
                    db.createUser({
                    user: "<new_username>",
                    pwd: "<new_password>",
                    roles: [
                    { role: "readWriteAnyDatabase", db: "admin" },
                    { role: "dbAdminAnyDatabase", db: "admin" },
                    { role: "clusterAdmin", db: "admin" }
                    ]
                    })
                  
    6. Run the following command to exit from the MongoDB container shell:
      exit
  4. Perform the following steps to install MongoDB within Kubernetes or OpenShift and create a non-root MongoDB user:
    Note: If you use OpenShift, then apply the necessary SecurityContextConstraints (SCC) to allow the Container to run.
    1. Install MongoDB on the Kubernetes or OpenShift cluster. For more information, refer to Bitnami documentation for MongoDB.
    2. Run the following command to open a shell to the MongoDB database pod:
      kubectl exec -it --namespace default <mongodb_pod_name> -- /bin/bash
    3. Run the following command to start the MongoDB shell as the root user:
      mongosh admin -u root -p <root_password>
    4. Run the following command to create a non-root user with the required roles:
      
                    db.createUser({
                    user: "<new_username>",
                    pwd: "<new_password>",
                    roles: [
                    { role: "readWriteAnyDatabase", db: "admin" },
                    { role: "dbAdminAnyDatabase", db: "admin" },
                    { role: "clusterAdmin", db: "admin" }
                    ]
                    })
                  
    5. Run the following command to exit from the MongoDB container shell:
      exit
  5. Perform the following steps to restore the MongoDB database dump to a new MongoDB instance:
    1. Connect to the VM using ssh connection, if MongoDB is running in a standalone VM or connect to the pod if MongoDB is running on Kubernetes or OpenShift cluster.
    2. Copy the dump file to a directory.
    3. Run the following command to restore the MongoDB database, excluding the admin database from the directory where you copied the dump file:
      mongorestore --uri="mongodb://<non_root_username>:<non_root_password>@localhost:27017/?authSource=admin" --gzip --archive=dump.tgz
    4. Run the following command to delete the imported dump file from the pod or VM:
      rm /tmp/dump.tgz
      Note: You must delete the dump file to conserve space and reduce security risk.
    5. Run the following command to exit from the shell:
      exit
  6. Copy the following encryption keys from the .env file located in the installation folder on the Docker environment and update the accelerate-tokens template in the Helm chart with these values before you install Velocity:
    • CIPHER_KEY
    • API_TOKEN
    • HMAC_KEY

  7. Install Velocity on the Kubernetes or OpenShift platform. See the Related links section.
    Note: You complete the migration only after you reinstall Velocity in Kubernetes or OpenShift.

Results

You have migrated Velocity from Docker Compose to Kubernetes or OpenShift.

What to do next

You can access the web UI and log in to Velocity. See Logging in to DevOps Velocity.