Let's assume the scenarios where we are given Project:
- Create a customized Docker container from the current version of Python that deploys a Python ML application.
- Push the image to DockerHub, Amazon ECR, Google Container Registry, or some other Cloud Container Registry.
- Pull the image down and run it on a cloud platform cloud shell: Google Cloud Shell or AWS Cloud9.
- Deploy an application to a cloud-managed Kubernetes cluster, like GKE (Google Kubernetes Engine), or EKS (Elastic Kubernetes Service), etc
This project is inspired by the portfolio guidance in:
Gift, N., & Deza, A. (2021). Practical MLOps: Operationalizing Machine Learning Models. O'Reilly Media.
Specifically adapted from Appendix E: "Building a Technical Portfolio for MLOps".
Minimal portfolio project:
- Classic ML artifact (sklearn pipeline) saved as
artifacts/model.joblib - FastAPI inference service
- Docker image build/push
- Kubernetes deploy (Deployment + LoadBalancer Service)
- GitHub Actions CI/CD: build → push → rollout
This repo expects artifacts/model.joblib.
Option A (recommended): create it via the included training script:
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
python scripts/train.pyuvicorn app:app --host 0.0.0.0 --port 8000
curl http://localhost:8000/healthzPredict:
curl -X POST http://localhost:8000/predict \
-H "Content-Type: application/json" \
-d '{
"Pregnancies": 2,
"Glucose": 120,
"BloodPressure": 70,
"SkinThickness": 20,
"Insulin": 85,
"BMI": 30.5,
"DiabetesPedigreeFunction": 0.35,
"Age": 33
}'docker build -t diabetes-ml:local .
docker run --rm -p 8000:8000 diabetes-ml:localdocker login
docker tag diabetes-ml:local <DOCKERHUB_USERNAME>/diabetes-ml:1.0.0
docker push <DOCKERHUB_USERNAME>/diabetes-ml:1.0.0Edit k8s/deployment.yaml image field:
image: <DOCKERHUB_USERNAME>/diabetes-ml:1.0.0
Apply:
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml
kubectl get svc diabetes-ml-svcAdd GitHub repo secrets:
DOCKERHUB_USERNAMEDOCKERHUB_TOKEN(DockerHub access token)KUBE_CONFIG(base64 kubeconfig)
Create kubeconfig secret:
cat ~/.kube/config | base64Workflow file: .github/workflows/ci-cd.yml
On each push to main, it:
- Builds image tagged with commit SHA
- Pushes to DockerHub
- Applies manifests
- Updates deployment image (rolling update)