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>