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.
To migrate a Docker Compose MongoDB database to Kubernetes complete the following steps:
-
Export the existing Docker Compose MongoDB database.
-
Navigate to MongoDB database container shell.
docker exec -it <MONGO_DB_SERVICE> bash
-
Export all data from the MongoDB database.
mongodump dump.tar
-
Exit the MongoDB database container shell.
exit
-
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.
-
-
Install MongoDB database in Kubernetes.
-
Install the MongoDB Helm chart with a root password of your choice.
helm install accelerate_mongo --set mongodbRootPassword=<ROOT_PASSWORD> bitnami/mongodb
-
-
Create a non-root MongoDB user
-
Navigate to MongoDB database's Kubernetes pod..
kubectl exec -it --namespace default accelerate_mongo /bin/bash
-
Open a MongoDB Shell session as the root user.
mongo admin -u root -p <ROOT_PASSWORD>
-
Create a non-root MongoDB user with the following roles and permissions.
db.createUser ({ user: "<NEW_USERNAME>", pwd: "<NEW_PASSWORD>", roles: [{role: "readWriteAnyDatabase", db: "admin"}, {role: "dbAdminAnyDatabase", db: "admin"}, {role: "clusterAdmin", db: "admin" }]})
-
Exit the MongoDB Shell.
exit
-
-
Restore the Docker Compose database dump to the new MongoDB pod.
-
Use
kubectl get pods
to get all pods. Identify the MongoDB pod. -
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/
-
Navigate to MongoDB pod shell.
kubectl exec -it --namespace default accelerate_mongo/bin/bash
-
Change directory to dump directory.
cd /tmp/dump.tar
-
List all MongoDB folder to verify the contents.
ls
Note: Each folder is a database in MongoDB.
-
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.
-
Exit MongoDB pod shell.
exit
The new MongoDB server is ready for use. For Kubernetes installation directions, see this page.
-
Parent topic: Migrating