Welcome to this beginner-friendly tutorial where we dive into the world of MLOps by building a complete Machine Learning pipeline! In this video, we walk you through creating an Apache Airflow pipeline to load, train, and evaluate a ML model, save it, and make predictions. Then, we deploy the model with a sleek Streamlit UI, containerize it with Docker, and scale it with Kubernetes. Perfect for anyone starting their MLOps journey! π
YouTube Link: https://youtu.be/SrvhSMeMsio?si=WJcLwpapJsCMQSNJ
- Apache Airflow
- Python
- Streamlit
- Docker
- DockerHub
- Kubernetes
- Kubectl
sudo apt update && sudo apt upgrade -y
sudo apt install python3-pip -y
python -m venv venv
source venv/bin/activate
pip3 install apache-airflow flask_appbuilder apache-airflow-providers-fab streamlit scikit-learn pandas joblib
airflow version
export AIRFLOW_HOME=~/airflow
echo $AIRFLOW_HOME
ls -l ~/airflow
- Replace "auth_manager = airflow.api_fastapi.auth.managers.simple.simple_auth_manager.SimpleAuthManager" in airflow.cfg file with "auth_manager=airflow.providers.fab.auth_manager.fab_auth_manager.FabAuthManager".
- Or you can comment the earlier variable.
vim ~/airflow/airflow.cfg
Create Airflow DAGS Directory
mkdir -p ~/airflow/dags
Make sure the DAG is in the Airflow DAGS Directory
cp iris_model_pipeline_dag.py ~/airflow/dags/
ls ~/airflow/dags/
Start the Airflow Scheduler, Api-Server, DB, Create Admin User - Starts all Components or Services of Airflow (For Dev Environment)
airflow standalone
On your browser:
localhost:8080
Get Admin User Password:
cat ~/airflow/simple_auth_manager_passwords.json.generated
python ~/airflow/dags/iris_model_pipeline_dag.py
- Look for the DAG Pipeline named: iris_model_pipeline
- Toggle the switch to "ON".
- Click the "Trigger DAG" button (the play icon) to start run.
- Monitor the run (in the "Graph" or "Grid" view).
Once DAG Pipeline run is successful, the model artifact (.pkl file) is saved to location: /tmp
ls -ld /tmp/
ls /tmp/iris_logistic_model.pkl
sample_data = [[5.1, 3.5, 1.4, 0.2], [6.7, 3.0, 5.2, 2.3]] # Sample inputs
cat /tmp/iris_predictions.csv
streamlit run app.py
cp /tmp/iris_logistic_model.pkl .
docker build -t ml-airflow-streamlit-app .
If it fails, go to your DockerHub account and create a Personal Access Token (PAT) - This will be your login password
docker login -u iquantc
docker build -t ml-airflow-streamlit-app .
docker run -p 8501:8501 ml-airflow-streamlit-app
http://172.17.0.2:8501
http://localhost:8501
docker tag ml-airflow-streamlit-app:latest iquantc/ml-airflow-streamlit-app:latest
docker push iquantc/ml-airflow-streamlit-app:latest
Review manifest files
minikube start --driver=docker
Review the deployment manifest
kubectl apply -f deployment.yaml
kubectl get pods
kubectl get svc
minikube ip
http://<minikube-ip>:<NodePort>
minikube stop
minikube delete --all