Udacity Cloud Devops Engineer
Project: Operationalize Machine Learning Microservice API.
Deploying an elastic and fault-tolerant Machine Learning inference API using Kubernetes. Configure this microservice to be highly available by using Kubernetes best practices. Validate the design by load testing the service and verifying the application architecture performs as designed.
Project Overview
You are given 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.
Project Tasks
Project goal is to operationalize working machine learning microservice using kubernetes, which is an open-source system for automating the management of containerized applications.
Project Steps
- Test the project code using linting
- Complete a Dockerfile to containerize the 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 (minikube)
- Deploy a container using Kubernetes and make a prediction
- Upload a complete Github repo with CircleCI to indicate that the code has been tested
Setup the Environment
- Create a virtualenv and activate it
python3 -m venv ~/.devops
source ~/.devops/bin/activate
- Run
make install
to install the necessary dependencies
Running app.py
- Standalone:
python app.py
- Run in Docker:
./run_docker.sh
- Run in Kubernetes:
./run_kubernetes.sh
- Make predictions:
./make_prediction.sh
Docker
- Publish docker image:
./upload_docker.sh
Kubernetes Steps
- Setup and Configure Docker locally
- Setup and Configure Kubernetes locally
- Create Flask app in Container
- Run via kubectl
Files included:
.circleci
- circleci config scriptsmodel_data
- ML model related data (model, csv data)output_txt_files
- project output files (docker, kubernetes)docker_out.txt
- run_docker.sh outputdocker_prediction_out.txt
- make_prediction.sh output while running dockerkubernetes_container_logs.txt
- kubectl logs output for the podkubernetes_out.txt
- run_kubernetes.sh outputkubernetes_prediction_out.txt
- make_prediction.sh output while running k8s pod
app.py
- python web application entry point fileDickerfile
- docker image configmake_prediction.sh
- make prediction HTTP call scriptMakefile
- make file (install, test, lint steps)requirements.txt
- web application dependencies (python, libraries)run_docker.sh
- run docker container scriptrun_kubernetes.sh
- run kubernetes pod for the web app scriptupload_docker.sh
- upload docker image to dicker hub script