Migrating Docker Compose to Kubernetes
About this task
To migrate docker compose to kubernetes complete the following steps:
Procedure
-
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.
-
Exit the mongo database container shell.
-
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.
-
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.
-
List all MongoDB folder.
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.
-
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.
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 from
settings.json
.
Select kubernetes
platform to generate Helm 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>