This project demonstrates a local Kubernetes setup using KIND to deploy two ML model APIs simultaneously:
- A decision tree regression model API (Axum + ONNX), running across 3 pods, each limited to 0.1 CPU core.
- A decision tree binary classification model API (Axum + ONNX), running on 1 pod with 0.1 CPU core.
Both APIs are exposed using NodePort services, making them accessible via localhost for testing. A concurrent inference test script sends alternating requests (regression → classification → regression...) to simulate real-world multi-model inference behavior.
- Docker Desktop
- KIND (Kubernetes in Docker)
- Python 3.8+
- Rust 1.70+
- kubectl
- just (task runner)
# Install just
winget install Casey.Just
# 1. Train the models
just train-models
# 2. Build Docker images
just build-images
# 3. Setup KIND cluster and deploy
just setup-cluster
just deploy
# 4. Test the deployment
just test
# 5. Cleanup
just cleanup
# All-in-one demo setup
just demo
# Then test
just test
cd models
pip install -r requirements.txt
python train_models.py
./scripts/build-images.sh
./scripts/setup.sh
./scripts/deploy.sh
# Test concurrent inference
./tests/test_apis.sh
# Or test individually
curl -X POST http://localhost:30001/predict \
-H "Content-Type: application/json" \
-d '{"features": [1.0, 2.0, 3.0]}'
curl -X POST http://localhost:30002/predict \
-H "Content-Type: application/json" \
-d '{"features": [1.0, 2.0, 3.0, 4.0]}'
- Regression API: 3 replicas, 0.1 CPU each (Port 30001)
- Classification API: 1 replica, 0.1 CPU (Port 30002)
- Resource Management: CPU limits enforced by Kubernetes
- Load Balancing: Kubernetes service handles distribution across pods
- Update
models/train_models.py
to train your model - Export to ONNX format
- Create new Rust API service
- Add Kubernetes manifests
- Update build and deploy scripts
# Run regression API locally
just dev-regression
# Run classification API locally
just dev-classification
kubectl get pods -n ml-apis
kubectl logs -n ml-apis <pod-name>
# Or use just commands
just logs-regression
just logs-classification
just status
kubectl get services -n ml-apis
kubectl cluster-info --context kind-ml-cluster
models/
: Python model training coderegression-api/
,classification-api/
: Rust API servicesk8s/
: Kubernetes manifestsscripts/
: Automation scriptstests/
: Test suites