Skip to content

A project to operationalize a Machine Learning Microservice API: Deploying a containerized, machine learning application using Kubernetes

License

Notifications You must be signed in to change notification settings

dapsibaba/DevOps-MLOps-microservice-kubernetes

Repository files navigation

CircleCI

Project Overview

This is a project that operationalizes a Python flask app-in a provided file, app.py that serves out predictions (inference) about housing prices through API calls. The model is a sklearn model that has been trained to predict housing prices in Boston according to several features, such as average rooms in a home and data about highway access, teacher-to-pupil ratios, and so on. You can read more about the data, which was initially taken from Kaggle, on the data source site. This project could be extended to any pre-trained machine learning model, such as those for image recognition and data labeling.In this project, you will apply the skills you have acquired in this course to operationalize a Machine Learning Microservice API.


A. Dependencies

A.1. Python

Download and install the python.

A.2. Docker Desktop

You would require you to install Docker Desktop to create containers for individual microservices. Refer the following links for instructions

A.3. Kubernetes

You would need to install any one tool for creating a Kubernetes cluster - KubeOne / Minikube / kubectl on top of Docker Desktop:

  1. Install and Set Up kubectl directly on top of Docker desktop - For Windows/macOS
  2. Install Minikube - For Linux/macOS

A.4. An account with Circle CI

You may sign up on CircleCI.com with your GitHub credentials.


B. Setup the Environment

To run the project code, you'll have to set up a virtual environment with the project dependencies. All of the following instructions are to be completed via a terminal/command line prompt.

B.1. Git and version control

These instructions also assume you have git installed for working with Github from a terminal window, but if you do not, you can download that first from this Github installation page.

Now, you're ready to create your local environment!

  1. clone this project repository, and navigate to the main project folder.

  2. Create (and activate) a new environment, named .devops with Python 3. If prompted to proceed with the install (Proceed [y]/n) type y.

# Use a command similar to this one:
python3 -m virtualenv --python=<path-to-Python3.7> .devops  
source ~/.devops/bin/activate

OR

python3 -m venv ~/.devops
source ~/.devops/bin/activate

At this point your command line should look something like: (.devops) <User>:<your main project folder><user>$. The (.devops) indicates that your environment has been activated, and you can proceed with further package installations.

  1. Installing dependencies via project Makefile. Many of the project dependencies are listed in the file requirements.txt; these can be installed using pip commands in the provided Makefile. While in your project directory, type the following command to install these dependencies.
make install

B.2. Other libraries that are needed

While you still have your .devops environment activated, you will still need to install:

  • Docker
  • Hadolint
  • Kubernetes (Minikube if you want to run Kubernetes locally)

B.3. Docker

You will need to use Docker to build and upload a containerized application. If you already have this installed and created a docker account, you may skip this step.

  1. You’ll need to create a free docker account, where you’ll choose a unique username and link your email to a docker account. Your username is your unique docker ID.

  2. To install the latest version of docker, choose the Community Edition (CE) for your operating system, on docker’s installation site. It is also recommended that you install the latest, stable release:

  3. After installation, you can verify that you’ve successfully installed docker by printing its version in your terminal: docker --version

B.4. Run Lint Checks

This project also must pass two lint checks; hadolint checks the Dockerfile for errors and pylint checks the app.py source code for errors.

  1. Install hadolint following the instructions, on hadolint's page:

For Mac:

brew install hadolint

For Windows:

scoop install hadolint

For Linux

wget -O /bin/hadolint https://github.com/hadolint/hadolint/releases/download/v1.16.3/hadolint-Linux-x86_64 &&\
chmod +x /bin/hadolint
  1. In your terminal, type: make lint to run lint checks on the project code. If you haven’t changed any code, all requirements should be satisfied, and you should see a printed statement that rates your code (and prints out any additional comments):
------------------------------------
Your code has been rated at 10.00/10

Running app.py

  1. Standalone: python app.py
  2. Run in Docker: ./run_docker.sh
  3. Run in Kubernetes: ./run_kubernetes.sh

About

A project to operationalize a Machine Learning Microservice API: Deploying a containerized, machine learning application using Kubernetes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published