Migrating Docker Compose to Kubernetes#
Migrating Docker Compose to Kubernetes
To migrate docker compose to kubernetes complete the following steps:
-
Delete mongo database from docker.
-
Navigate to mongo database container shell.
docker exec -it velocity_database_1 bash
-
Delete all data from the mongo database.
mongodump
-
Exit the mongo database container shell.
exit
-
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.
-
-
Setting up mongo database in Kubernetes.
-
Install the MongoDB Helm chart with a root password of your choice.
helm install --set mongodbRootPassword=<ROOT_PASSWORD> --name velocity-mongo stable/mongodb
-
Open a shell inside the MongoDB pod.
kubectl exec -it --namespace default svc/velocity-mongo-mongodb /bin/bash
-
Open a Mongo Shell session with username root and define password.
mongo admin -u root -p <ROOT_PASSWORD>
-
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" }]})
-
Exit the Mongo Shell.
exit
-
-
Restore the Database Dump to MongoDB pod.
-
Use
kubectl get pods
to get all pods. Identify the MongoDB pod. -
Copy database dump folder into MongoDB pod.
kubectl cp <DUMP_LOCATION> <FULL_POD_NAME>:/tmp/dump
-
Navigate to MongoDB pod shell.
kubectl exec -it --namespace default svc/velocity-mongo-mongodb /bin/bash
-
Change directory to dump directory.
cd /tmp/dump
-
List all MongoDB folder.
ls
Note: Each folder is database in MongoDB.
-
Restore all database except
ADMIN
mongorestore --uri="mongodb://<NEW_USERNAME>:<NEW_PASSWORD>@localhost:27017/?authSource=admin" <DB_NAME> -d <DB_NAME>
-
Exit MongoDB pod shell.
exit
-
-
Configure SSL certificate.
-
Create a
velocity-secret.yml file
with the following contents.apiVersion: v1 data: tls.crt: <BASE64_CERT> tls.key: <BASE64_KEY> kind: Secret metadata: name: velocitytls namespace: default type: Opaque
-
Encode the certificate and key files.
cat <FILE>.pem | base64
Save certificate and key files to the required folders.
-
Apply the
velocity-secret.yml
file.kubectl apply -f velocity-secret.yml
-
-
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
-
Install HCL Accelerate.
Before you begin, ensure
settings.json
file is available in ~/.ucv directory.-
Run
the velocity installer. All fields taken information fromsettings.json
.Select
kubernetes
platform to generateHelm chart tgz
. -
Use
Helm chart tgz
to install velocity. -
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