This Microservice Project is part of the Udacity Cloud DevOps Engineer Nanodegree
There is a pre-trained, 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 tests your ability to operationalize a Python flask app—in a provided file, app.py
—that serves out predictions (inference) about housing prices through API calls. This project could be extended to any pre-trained machine learning model, such as those for image recognition and data labeling.
Goal is to operationalize this working, machine learning microservice using kubernetes, which is an open-source system for automating the management of containerized applications. Tasks in this project:
- Build a Frontend to accept user input data and produce a prediction
- Test project code using linting
- Complete a Dockerfile to containerize this application
- Deploy containerized application using Docker and make a prediction
- Improve the log statements in the source code for this application
- Configure Kubernetes and create a Kubernetes cluster
- Deploy a container using Kubernetes and make a prediction
- Integrate with CircleCI to indicate that your code has been tested
Dockerfile
- Contains commands used to create a docker image
Makefile
- Contains useful set of commands to setup environment, run tests and run lints
app.py
- Python flask app that returns predictions about housing prices when requested using API calls
make_prediction.sh
- Send API request to Flash app running and receives response
run_docker.sh
- Script to build and run docker image locally
upload_docker.sh
- Script to tag and upload docker image to docker hub
run_kubernetes.sh
- Script to setup and run app on kubernetes
.circleci/config.yml
: CircleCI configuration file for running the tests
templates/index.html
: Frontend of this project where you can send input and receive a prediction
static/
: Frontend assets
- Docker (Requirements: WSL2 / Windows 10 Pro, Enterprise, or Education)
- Virtual Machine (VirtualBox / HyperV / etc.)
- Create a virtualenv and activate it
python3 -m venv <name_of_venv>
source <name_of_venv>/bin/activate
- Run
make install
using bash to install the necessary dependencies
- Standalone:
python app.py
- Run in Docker:
./run_docker.sh
- Run in Kubernetes:
./run_kubernetes.sh
- Setup and Configure Docker locally
- Setup and Configure Kubernetes locally
- Create Flask app in Container
- Run via kubectl
-
To start a local cluster:
minikube start
-
To deploy this application in kubernetes:
./run_kubernetes.sh
-
When the pod is up and running, make predictions using:
./make_prediction.sh
-
Delete the cluster after your done:
minikube delete