A demo that deploys a llama.cpp FastAPI service from Jozu Hub ModelKits on Kubernetes with Helm and on an edge host, and rolls back from a bad model version to a good one.
Jozu docs · Jozu · KitOps · More examples · studio1hq.com
This repo demonstrates rolling back an AI model by changing a KitOps ModelKit tag. A small FastAPI service answers chat requests with a quantized Qwen2 0.5B model through llama-cpp-python. The model and the code come from ModelKits stored on Jozu Hub and are unpacked into the pod by kitops-init init containers.
There are two deployment playbooks: a Helm chart for Kubernetes, where a rollback is a helm upgrade or kubectl set env, and an edge deployment for a single host with Docker and systemd, where a rollback is stop, swap, start.
- Helm chart:
helm-chart/deploys the service with separate ModelKit references for the model and the code. - Init containers:
ghcr.io/kitops-ml/kitops-initunpacks the model (filtermodel) to/modeland the code (filtercode) to/app. - Two rollback methods:
helm upgrade --set modelkitRef=...orkubectl set env deployment/modelkit-demo MODELKIT_REF=.... - Prepared values:
values-prod.yamlholds the bad version andvalues-rollback.yamlholds the good one (two replicas). - Edge deployment: Scripts for deploy, start, stop and rollback, a Dockerfile, Compose file and systemd unit.
- Tag allowlist:
edge-deployment/governance.conflimits which tags edge devices may deploy. - Version endpoint: The API exposes
/health,/version,/chatand/model/info, so you can see which model is running.
| Layer | Tool |
|---|---|
| Packaging | KitOps |
| Registry | Jozu Hub |
| Kubernetes deploy | Helm and kubectl |
| Service | FastAPI, llama-cpp-python |
| Model | Qwen2 0.5B Instruct (Q4_K_M GGUF) |
| Edge | Docker, Docker Compose, systemd |
- A Kubernetes cluster,
kubectland Helm for the Helm demo - Docker and the KitOps CLI for the edge demo
- Access to the ModelKits on Jozu Hub (or your own copies; see below)
git clone https://github.com/Studio1HQ/KitOps-Modelkit-Rollback-Helm.git
cd KitOps-Modelkit-Rollback-Helm| Variable | Description |
|---|---|
MODEL_PATH |
Where the service looks for the model. Defaults to /model. |
MODELKIT_REF |
ModelKit reference used by the init containers and the edge scripts, for example jozu.ml/arnabchat2001/modelkit-demo:v3. |
The chart and scripts reference ModelKits under jozu.ml/arnabchat2001/modelkit-demo. Push your own ModelKit and update modelkitRef in the values files and edge-deployment/ scripts to use it.
Helm, deploy the bad version, check it, then roll back:
helm upgrade --install modelkit-demo ./helm-chart -f helm-chart/values-prod.yaml --namespace default
kubectl get pods -l app.kubernetes.io/name=modelkit-demo
kubectl exec <pod-name> -- curl -s localhost:8000/version
# Method A: Helm upgrade
helm upgrade modelkit-demo ./helm-chart --set modelkitRef=jozu.ml/arnabchat2001/modelkit-demo:v0
# Method B: kubectl set env
kubectl set env deployment/modelkit-demo MODELKIT_REF=jozu.ml/arnabchat2001/modelkit-demo:v0The guided version is ./demo-script.sh.
Edge host:
cd edge-deployment
./deploy.sh v7
curl http://localhost:8000/health
curl http://localhost:8000/version
./rollback.sh v3
curl http://localhost:8000/versionKitfile Packages ./model (GGUF + version.txt) and ./src (FastAPI app)
src/app.py FastAPI + llama-cpp-python service
helm-chart/ Chart, values.yaml, values-prod.yaml, values-rollback.yaml, templates
k8s/deployment.yaml Plain Kubernetes manifest with kitops-init containers
edge-deployment/ deploy.sh, rollback.sh, start/stop scripts, governance.conf, systemd unit
MODEL_VERSIONS.md Describes the demo versions: good (rollback target), bad (current), experimental
The default values.yaml has modelkitRef.model and modelkitRef.code as separate references, so the model and the code can be pinned independently. A rollback moves them to a known good tag, and /version reports which model is loaded.
- KitOps documentation: ModelKit and Kitfile reference.
- Jozu documentation: Jozu Hub guides.
- Jozu: Product site.
- Helm documentation: Chart and rollback reference.
Built by Studio1, the technical content and DevRel partner for devtool teams. Made with Jozu.
Browse more open-source examples at github.com/Studio1HQ.
studio1hq.com · Technical content, docs, video and DevRel for devtools