Project · Advanced · about 24 hours
Serve a model on Kubernetes with autoscaling and a safe rollout
Package an intent classifier as a container, run it on a local Kubernetes cluster with health checks, autoscaling and metrics, and roll out a new version without errors.
Skills:CI/CD, MLOps, Monitoring and observability, Docker and containers, Kubernetes
Part of: AI/ML Engineer
Data and licences
- PolyAI Banking77 ↗CC BY 4.0
Brief
A classifier in a notebook is not a product. Take the Banking77 intent model (TF-IDF or embeddings) and run it the way a platform team would: in containers, on Kubernetes, observable and safe to update.
Use a local cluster such as kind or minikube. Nothing here needs a cloud account.
What to build
Train the model and save it with its version and training data hash.
Serve it with FastAPI:
/predict,/healthzand/readyz(ready only after the model is loaded), plus Prometheus metrics.Build a multi-stage image that runs as a non-root user. Record its size.
Deploy with resource requests and limits set from a quick load test, liveness and readiness probes, and an HPA on CPU.
Load test with a tool such as k6 or Locust. Show pods scaling out and latency staying within a target you set.
Ship version 2 with a rolling update while the load test runs. Show zero failed requests, then roll back.
Validate manifests in CI (for example with kubeconform) and build the image on every push.
Deliverables
Repository with
service/,Dockerfile,k8s/,load/,.github/workflows/,RUNBOOK.md
How it is graded
Reviewers create the cluster from your README, run your load test and trigger a rollout. They check the dashboard and whether anything failed.
Stretch
Add a canary with two Deployments behind one Service and compare the new version's error rate before shifting all traffic.
Deliverables
- A slim, non-root container image for the model service with a pinned model artifact
- Kubernetes manifests (Deployment, Service, probes, resources, HorizontalPodAutoscaler)
- Metrics for request rate, latency and errors, and a dashboard
- A load test report and a rolling update with zero failed requests
How a reviewer grades it
| Criterion | Weight | What good looks like |
|---|---|---|
| Image is small, reproducible and runs as non-root; model version is visible at runtime | 20% | |
| Probes, requests and limits are set from measurements, not guesses | 25% | |
| Autoscaling demonstrated under load with a clear graph | 25% | |
| Rollout and rollback tested with no failed requests, documented in a runbook | 30% |