👩‍💻Kubernetes Microservices Project: Deployment of MongoDB+Flask Application on K8S Cluster

In this blog, we will learn how to deploy a Flask app that communicates with a MongoDB database, containerize the app using Docker, and manage it through a Kubernetes cluster. Although it may seem complicated at first, I will break down each step of the process to make it easy to follow and understand.

🔹Set up Kubernetes Cluster using Kubeadm

To begin, spin up two EC2 instances with the instance type of t2.medium.

To learn how to install Kubernetes, follow the instructions provided at the following link:https://hashnode.com/post/cllv698t7000309l659i2eu31

Check the nodes:

kubectl get nodes

The Master and Worker nodes have been set up and are now ready to create pods and run containers.

To get started, fork the repository and clone it onto the Master Node by executing the following command: git clone Project Code

git clone https://github.com/lovely7027/microservices-k8s.git

Follow the steps below to navigate to the files:

🔹Deploying the Taskmaster Micro-service

kubectl apply -f taskmaster.yml

  • Execute the following command to scale up the Taskmaster:

      kubectl scale --replicas=3 deployment/taskmaster
    

    • To provide users with access to our taskmaster, we need to deploy a taskmaster service.

        kubectl apply -f taskmaster-svc.yml
      

      we can access it from outside the cluster using the IP address of the worker node and the NodePort we specified in the taskmaster-svc.yml file.

      You can access the API at http://<ip-of-worker-node>:30007

      🔹Integrate Persistent Volume and PV Claim

        kubectl apply -f mongo-pv.yml
      

Create a persistent volume and claim it by executing the following command:

kubectl apply -f mongo-pvc.yml

🔹Deploy Mongo DB

kubectl apply -f mongo.yml

Congratulations! MongoDB has been deployed successfully.

To check the status of all pods

kubectl get pods

View the running containers by using

docker ps

Our MongoDB container is up and running! 🎉

Stay tuned to check the integration of these micro-services and troubleshooting. I will upload another blog on this topic soon.