Migrating Docker Compose to Kubernetes#

Migrating Docker Compose to Kubernetes

To migrate docker compose to kubernetes complete the following steps:

  1. Delete mongo database from docker.

    1. Navigate to mongo database container shell.

      docker exec -it velocity_database_1 bash

    2. Delete all data from the mongo database.

      mongodump

    3. Exit the mongo database container shell.

      exit

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

      docker cp velocity_database_1:/dump <DESTINATION>

      Note: Dump folder need to be restored in mongodb pod.

  2. Setting up mongo database in Kubernetes.

    1. Install the MongoDB Helm chart with a root password of your choice.

      helm install --set mongodbRootPassword=<ROOT_PASSWORD> --name velocity-mongo stable/mongodb

    2. Open a shell inside the MongoDB pod.

      kubectl exec -it --namespace default svc/velocity-mongo-mongodb /bin/bash

    3. Open a Mongo Shell session with username root and define password.

      mongo admin -u root -p <ROOT_PASSWORD>

    4. Create a non-root username to access HCL™ Accelerate.

      db.createUser ({ user: "<NEW_USERNAME>", pwd: "<NEW_PASSWORD>", roles: [{role: "readWriteAnyDatabase", db: "admin"}, {role: "dbAdminAnyDatabase", db: "admin"}, {role: "clusterAdmin", db: "admin" }]})

    5. Exit the Mongo Shell.

      exit

  3. Restore the Database Dump to MongoDB pod.

    1. Use kubectl get pods to get all pods. Identify the MongoDB pod.

    2. Copy database dump folder into MongoDB pod.

      kubectl cp <DUMP_LOCATION> <FULL_POD_NAME>:/tmp/dump

    3. Navigate to MongoDB pod shell.

      kubectl exec -it --namespace default svc/velocity-mongo-mongodb /bin/bash

    4. Change directory to dump directory.

      cd /tmp/dump

    5. List all MongoDB folder.

      ls

      Note: Each folder is database in MongoDB.

    6. Restore all database except ADMIN

      mongorestore --uri="mongodb://<NEW_USERNAME>:<NEW_PASSWORD>@localhost:27017/?authSource=admin" <DB_NAME> -d <DB_NAME>

    7. Exit MongoDB pod shell.

      exit

  4. Configure SSL certificate.

    1. Create a velocity-secret.yml filewith the following contents.

      apiVersion: v1 data: tls.crt: <BASE64_CERT> tls.key: <BASE64_KEY> kind: Secret metadata: name: velocitytls namespace: default type: Opaque

    2. Encode the certificate and key files.

      cat <FILE>.pem | base64

      Save certificate and key files to the required folders.

    3. Apply the velocity-secret.yml file.

      kubectl apply -f velocity-secret.yml

  5. Configure Kubernetes Ingress.

    Apply mandatory and cloud-generic Ingress-Nginx.yml files.

    kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml

    kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/cloud-generic.yaml

  6. Install HCL Accelerate.

    Before you begin, ensure settings.json file is available in ~/.ucv directory.

    1. Run the velocity installer. All fields taken information from settings.json.

      Select kubernetes platform to generate Helm chart tgz.

    2. Use Helm chart tgz to install velocity.

    3. Install HCL Accelerate.

      helm install --set license=accept --set url.domain=<HOSTNAME> --set mongo.url=mongodb://<NEW_USERNAME>:<NEW_PASSWORD>@velocity-mongo-mongodb:27017/?authSource=admin --name velocity <VELOCITY_HELM_CHART>

Parent topic: Migrating