Migrating Docker Compose to Kubernetes

Migrating Docker Compose to Kubernetes.

About this task

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 accelerate_database_1 bash

    2. Delete all data from the mongo database.


    3. Exit the mongo database container shell.


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

      docker cp accelerate_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/accelerate-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.
      user: "<new_username>", 
      pwd: "<new_password>", 
      roles: [{role: "readWriteAnyDatabase", 
      db: "admin"}, {role: "dbAdminAnyDatabase", 
      db: "admin"}, {role: "clusterAdmin", 
      db: "admin"
    5. Exit the Mongo Shell.


  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/accelerate-mongo-mongodb /bin/bash

    4. Change directory to dump directory.

      cd /tmp/dump

    5. List all MongoDB folder.


      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.


  4. Configure SSL certificate.
    1. Create a accelerate-secret.yml filewith the following contents:
      apiVersion: v1
        tls.crt: <base64_cert>
        tls.key: <base64_key>
      kind: Secret
        name: acceleratetls
        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 accelerate-secret.yml file.

      kubectl apply -f accelerate-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 accelerate installer. All fields taken information from settings.json.

      Select kubernetes platform to generate Helm chart tgz.

    2. Use Helm chart tgz to install accelerate.
    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 accelerate <accelerate_helm_chart>