Skip to content

About

Demo: deploy ModelKits from Jozu Hub with Helm or on an edge host, then roll back to a good version.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

ModelKit Rollback with Helm and KitOps: Roll back a served model by changing one ModelKit tag in Helm or on an edge host

ModelKit Rollback with Helm and KitOps

Roll back a served model by changing one ModelKit tag in Helm or on an edge host

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.


Built by Studio1 Built with Jozu

Jozu docs  ·  Jozu  ·  KitOps  ·  More examples  ·  studio1hq.com


Overview

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.

Features

  • Helm chart: helm-chart/ deploys the service with separate ModelKit references for the model and the code.
  • Init containers: ghcr.io/kitops-ml/kitops-init unpacks the model (filter model) to /model and the code (filter code) to /app.
  • Two rollback methods: helm upgrade --set modelkitRef=... or kubectl set env deployment/modelkit-demo MODELKIT_REF=....
  • Prepared values: values-prod.yaml holds the bad version and values-rollback.yaml holds 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.conf limits which tags edge devices may deploy.
  • Version endpoint: The API exposes /health, /version, /chat and /model/info, so you can see which model is running.

Tech stack

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

Getting started

Prerequisites

  • A Kubernetes cluster, kubectl and 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)

Installation

git clone https://github.com/Studio1HQ/KitOps-Modelkit-Rollback-Helm.git
cd KitOps-Modelkit-Rollback-Helm

Environment variables

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.

Run

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:v0

The 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/version

How it works

Kitfile             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.

Resources



Studio1

Built by Studio1, the technical content and DevRel partner for devtool teams. Made with Jozu.
Browse more open-source examples at github.com/Studio1HQ.

Website Book a call X LinkedIn

studio1hq.com · Technical content, docs, video and DevRel for devtools

About

Demo: deploy ModelKits from Jozu Hub with Helm or on an edge host, then roll back to a good version.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages