my-homelab-configs/apps/mlops-platform/README.md

44 lines
1.7 KiB
Markdown

# MLOps Platform Demo
Production-shaped inference demo for the portfolio site. The model is
intentionally small: logistic regression coefficients trained with scikit-learn
and exported to JSON so the runtime stays light enough for the homelab.
This directory contains the FastAPI service and model artifacts. It is not yet
registered as a Kubernetes application in `bootstrap/apps`; the public website
currently links to the reserved static placeholder under
`apps/demos-static/public/mlops-platform/`.
## Endpoints
- `GET /healthz` reports service, track, and active model metadata.
- `POST /predict` scores service health risk from latency, error rate, CPU, memory, and queue depth.
- `GET /metrics` exposes Prometheus metrics for request count, latency, errors, model version, confidence, and drift score.
## Model Rollout
- `MODEL_VERSION=v1`, `MODEL_TRACK=blue` is the stable route.
- `MODEL_VERSION=v2`, `MODEL_TRACK=green` is the canary route.
- Kubernetes service selectors choose the active track, so rollback is a service selector change instead of an image rebuild.
## Local Smoke Test
```bash
docker build -t mlops-platform:local apps/mlops-platform
docker run --rm -p 8080:8080 mlops-platform:local
```
In another shell:
```bash
curl -fsS http://127.0.0.1:8080/healthz
curl -fsS http://127.0.0.1:8080/predict \
-H 'Content-Type: application/json' \
-d '{"latency_ms":120,"error_rate":0.01,"cpu_utilization":0.55,"memory_utilization":0.62,"queue_depth":8}'
curl -fsS http://127.0.0.1:8080/metrics
```
The next deployment step is to add Kubernetes manifests or a Kustomize app with
blue and green Deployments, a Service selector for the active track, resource
requests and limits, and Prometheus scraping.