Skip to content

Deployment on GCP of a ML model as several Microservices with a simple Flask interface. CI/CD pipeline was implemented as well

License

Notifications You must be signed in to change notification settings

victorrgez/cloudProjectIris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microservices with CI/CD

CI/CD pipeline

v1.0.0 → Project on Google Cloud Platform (GCP) focused on learning how to use Docker and Kubernetes, how to expose Flask Applications and how to separate different tasks when deploying a simple ML model as a structure of microservices.

v2.0.0 → Implemented a complete CI/CD pipeline consisting of Unit Testing, Integration Tests, Automatic building and pushing images to DockerHub, End-to-End tests and Automatic Deployment to a GKE cluster in GCP. Unit Tests are run on every commit whereas the rest of the steps are only triggered for commits to Main branch with [SRC] at the start of the commit message

  • Frontend → The only service with Public IP with which the user can interact.
  • Backend → Handles the connections with the database and the Machine Learning model.
  • Mysql → Serves as a Database that stores the predictions of the Machine Learning model.
  • Model → Pretrained ML model on the Iris dataset

How to run on Docker:

  1. docker network create cloudprojectiris
  2. docker run -d --name mysql --net cloudprojectiris victorrgez/cloudprojectirismysql
  3. docker run -d --name model --net cloudprojectiris victorrgez/cloudprojectirismodel
  4. docker run -d -p=0.0.0.0:5000:5000 --name frontend --net cloudprojectiris victorrgez/cloudprojectirisfrontend
  5. docker run -d --name backend --net cloudprojectiris victorrgez/cloudprojectirisbackend
  6. Visit http://localhost:5000 or copy the external IP of your machine instead of localhost

How to stop on Docker:

  1. docker stop backend frontend model mysql
  2. docker rm backend frontend model mysql
  3. Remove the images individually with docker rmi (you can list them with docker image ls)
  4. docker network rm cloudprojectiris

How to run on Docker-Compose:

  1. git clone https://github.com/victorrgez/cloudprojectiris.git
  2. cd cloudprojectiris
  3. docker-compose up -d

How to stop on Docker-Compose:

a/ If you want to remove the database:
  1. docker-compose down -v
b/ If you want to keep the database:
  1. docker-compose down

How to run on Kubernetes:

  1. git clone https://github.com/victorrgez/cloudprojectiris.git
  2. Install kompose.io following the instructions for your OS https://kompose.io/installation/
  3. cd cloudprojectiris
  4. kompose convert -f docker-compose.yml
  5. Add type: LoadBalancer inside the spec block in the file frontend-service.yaml like in here
  6. kubectl apply -f . (ignore warnings about docker-compose.yml)
  7. Wait a couple of minutes for mysql service to start-up so that backend can eventually become healthy
  8. kubectl get service frontend
  9. Copy the EXTERNAL-IP in your browser and put :5000 at the end

Alternatively you can run kubectl apply -f . inside the kubernetesYAMLFiles folder instead of using kompose.io

How to stop on Kubernetes:

  1. kubectl delete services frontend backend mysql model
  2. kubectl delete deployments frontend backend mysql model
  3. kubectl delete pvc statefuldatabase

About

Deployment on GCP of a ML model as several Microservices with a simple Flask interface. CI/CD pipeline was implemented as well

Resources

License

Stars

Watchers

Forks