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 -ysudo apt install python3-pip -ypython -m venv venvsource venv/bin/activatepip3 install apache-airflow flask_appbuilder apache-airflow-providers-fab streamlit scikit-learn pandas joblib airflow versionexport AIRFLOW_HOME=~/airflowecho $AIRFLOW_HOMEls -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.cfgCreate Airflow DAGS Directory
mkdir -p ~/airflow/dagsMake 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 standaloneOn your browser:
localhost:8080Get Admin User Password:
cat ~/airflow/simple_auth_manager_passwords.json.generatedpython ~/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.pklsample_data = [[5.1, 3.5, 1.4, 0.2], [6.7, 3.0, 5.2, 2.3]] # Sample inputscat /tmp/iris_predictions.csvstreamlit run app.pycp /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 iquantcdocker build -t ml-airflow-streamlit-app .docker run -p 8501:8501 ml-airflow-streamlit-apphttp://172.17.0.2:8501http://localhost:8501docker tag ml-airflow-streamlit-app:latest iquantc/ml-airflow-streamlit-app:latestdocker push iquantc/ml-airflow-streamlit-app:latestReview manifest files
minikube start --driver=dockerReview the deployment manifest
kubectl apply -f deployment.yamlkubectl get podskubectl get svcminikube iphttp://<minikube-ip>:<NodePort>minikube stopminikube delete --all