LLMKube with Vulkan
Chris Cowley
- 14 minutes read - 2830 wordsBack in April I wrote about running Hugging Face models on Ollama, and Ollama has been the local-AI backbone of the lab ever since. However, it has a couple of problems:
- I have never managed to get Vulkan running with it
- it has fallen out of favour with the community, which has really coalesced around llama.cpp
- a couple of my colleagues got all snobby with me about still running it
So I went looking for a “kubernetes-native” way to run llama.cpp on my cluster. Pretty quickly I came across LLMKube, which is an LLM Operator.
Info
As a quick reminder, an operator adds Custom Resource Definitions to my Kubernetes cluster, thus allowing me to manage anything as if it is just another kubernetes resource.
There are a few main consumers:
- karakeep (my bookmark manager) wants a chat model for auto-tagging, a vision-capable one for link previews, and an embedding model for semantic search.
- paperless-ngx wants document understanding for its AI features, plus embeddings for cross-corpus search.
- Hermes, my personal assistant
- Open WebUI is the basic chat interface
- n8n (which I covered previously) is an automation system that could be doing “who knows what”
If you listen to r/LocalLLaMA, everyone doing this stuff has a pile of DGX Sparks and a workstation packed to the gills with RTX4090s in the cupboard. Unfortunately, back in the real world of being a dad, with 2 sons at uni and a mortgage to pay, I have some constraints: I only have one GPU (an AMD RX 580, a Polaris-era card with 8 GB of VRAM) plus a handful of CPU-only nodes with ordinary amounts of RAM - nothing has more than 16GB. No NVIDIA, no ROCm support (Polaris fell off the official list years ago). Of course I like to do things “properly” so everything has to be declarative: the cluster is Flux-managed from git, and anything that isn’t in git effectively doesn’t exist.
The RX 580 needs a word of explanation, because it looks odd sitting in a lab that is otherwise a pile of mini-PCs: it is a hand-me-down from my younger son. Where everyone on r/LocalLLaMA has a workstation packed with 4090s, my GPU acquisition strategy is “buy your kids a graphics card and wait for it to come back around”. I paid for the thing once, my son got his use out of it, and now it is back for a second tour of duty. Nobody ever built a homelab out of sensible purchasing decisions.
What I wanted:
- One OpenAI-compatible endpoint every app talks to.
- Multiple models, each deployed because a specific app needs it.
- The GPU shared properly: one model resident at a time, swapped on demand.
- Latency-tolerant models on CPU nodes so the GPU is reserved for models that need it.
What LLMKube gives you
The vocabulary first, because the rest of this builds on it. The operator installs CRDs in the inference.llmkube.dev group:
- Model — a model artefact pulled from Hugging Face, usually GGUF, e.g.
hf://unsloth/gemma-4-E4B-it-GGUF. - InferenceService — runs a Model as a serving pod (llama.cpp under the hood) with an OpenAI-compatible API.
- ModelPool — a set of InferenceServices that share one GPU, swapping members in and out on demand.
- ModelRouter — a proxy presenting a single endpoint, routing by requested model name.
The lab now looks like this:
karakeep ─┐
paperless ─┤ base_url = http://llmkube.llmkube.svc...:8080/v1
hermes ────┼─► router-proxy (CPU node) llmkube.lab.cowley.tech (external)
webui ────┘ │
│ routes by model name
┌───────────┴──────────────────────┐
▼ ▼
ModelPool "gpu-pool" resident CPU services
one RX 580, swapPolicy: reclaim no GPU, never swapped
───────────────────────── ──────────────────────
gemma4-e4b ← resident bge-m3 (CPU node)
ornith15-9b qwen3-embedding-0-6b (CPU node)
mellum21-instruct gemma4-26b-a4b (CPU node)
mellum21-thinking
▲
└── pinned to the GPU node (amd.com/gpu: 1)
In fairness to Ollama, it never needed a pool: it loads and unloads models on demand all by itself. The thing it never had was Vulkan support that actually worked, at least on my RX 580 (that is the story of the next section). Four chat models fit on the card one at a time (not four at once, never), so the pool keeps the default resident and swaps the others in when the router sees them requested. Nobody has to coordinate that, because nobody has to care.
Installing it
The operator is a plain Helm chart, so it joined the other operators in operators/ (my config): a HelmRepository pointing at https://defilantech.github.io/LLMKube and a HelmRelease that puts the controller in llmkube-system, while my Model/Pool/Router resources live in the llmkube namespace (manifests here).
Getting the GPU to work at all: the Vulkan path
The RX 580 is Polaris (gfx803), an architecture for which ROCm dropped official support long ago. This means the usual Kubernetes GPU story (NVIDIA operator, DCGM exporter, nvidia.com/gpu) does not apply. The alternative is llama.cpp’s Vulkan backend driving the card through RADV, Mesa’s open Vulkan driver: no compute stack required, just the kernel driver and the DRM render nodes. For me that is great, because I do not have to shoehorn NVIDIA’s driver into my Fedora CoreOS machines.
In llmkube, the logic is this:
- the
Modelspec declares the hardware - the
InferenceServiceschedules accordingly (my model.yaml):
# apps/llmkube/model.yaml (excerpt, live-verified)
apiVersion: inference.llmkube.dev/v1alpha1
kind: Model
metadata:
name: gemma4-e4b
namespace: llmkube
spec:
files: [gemma-4-E4B-it-UD-Q4_K_XL.gguf]
format: gguf
hardware:
accelerator: vulkan
gpu:
enabled: true
count: 1
vendor: amd
resourceName: amd.com/gpu
amd.com/gpu comes from AMD’s device plugin on my nodes that have an AMD GPU (hint: I only have one). The pods requesting it need access to the DRM render nodes (which is why the controller values carry one very specific number):
controllerManager:
driRenderGID: 105
That is the render-node group the inference containers must belong to to touch /dev/dri/renderD*. Get it wrong and the pod starts, passes readiness, and serves tokens (on the CPU).
The image that wasn’t using the GPU
Which brings me to the one bug that cost me the most time, precisely because nothing broke.
llmkube runs llama.cpp from a default image (ghcr.io/ggml-org/llama.cpp:server-b11854). That is the stock build, with no GPU backend compiled in at all. The pod came up healthy, the API answered, the dashboard stayed green. It was also doing inference on CPU, at CPU speeds, and only the token rate knew.
The fix is a one-line image pin in my isvc.yaml: the same llama.cpp build version, compiled with GGML_VULKAN=ON:
# apps/llmkube/isvc.yaml (excerpt)
apiVersion: inference.llmkube.dev/v1alpha1
kind: InferenceService
metadata:
name: gemma4-e4b
spec:
image: ghcr.io/ggml-org/llama.cpp:server-vulkan-b11854
modelRef: gemma4-e4b
nodeSelector:
kubernetes.io/hostname: agent4
contextSize: 65536
resources:
gpu: 1
cpu: "1"
memory: 6Gi
The commit message in my repo is the whole lesson: “pin llama.cpp server-vulkan-b11854 image (stock build has no GPU backend)”. If you go down this path, do not assume the default image is the Vulkan image — check the build flags before you start tuning anything, because a wrong-backend deployment is indistinguishable from a correct one until you look at tokens-per-second. A sanity check I now run after every model deploy: the Grafana AMD-GPU dashboard should be showing the card actually busy.
The memory arithmetic: VRAM versus RAM
However, with Vulkan working, the interesting problem becomes placement, and it is decided by memory. There are two currencies in this cluster, and they are not interchangeable:
- 8 GB of VRAM on the RX 580 — fast, and the binding constraint for GPU models. Weights plus KV cache at the configured
contextSizemust fit, so the GPU models are chosen by what loads inside that envelope.gemma4-e4b(Q4 quantised, roughly 4 GB of weights, declaredmemory: 6Gi) fits with room for its context; so doornith15-9band the two Mellum 2.1 variants at ~6.5 GiB each. A 10 GB model simply is not a candidate, however much you want it to be. - System RAM on the CPU nodes — slower, but there is far more of it, and for the right kind of model that is a good trade to make deliberately.
This is the balance I ended up settling on: the GPU runs the models that have to be fast; the CPU runs the models that are allowed to be slow. Which side a model lands on is a decision about its shape and about how its apps use it:
| model | size | where | why there |
|---|---|---|---|
| gemma4-e4b | ~4 GB Q4 | GPU (pool default) | the interactive default; ~26 tok/s |
| ornith15-9b | ~5 GB | GPU (pool member) | fits VRAM; used when its voice is wanted |
| mellum21-instruct / -thinking | 6.5 GiB each | GPU (pool members) | fit individually (only one member is resident at a time) |
| gemma4-26b-a4b | 10.5 GiB | CPU, resident | 26B-total MoE with only ~4B active per token: cannot fit 8 GB VRAM, but decode work is small enough that DDR5 bandwidth is usable |
| bge-m3, qwen3-embedding-0-6b | ~0.6 GiB each | CPU, resident | embeddings must answer instantly, so they stay loaded outside the pool (GPU swap latency is unacceptable for them) |
There are two things worth noticing in that table.
The first is that pool members only have to fit the VRAM individually, never together. That is precisely what a ModelPool buys you: four models that each fit in 8 GB get to behave like four models you own, even though only one of them is ever true at a time.
The second is why the 10.5 GiB model is a CPU model by nature, not by exile. Mixture-of-experts means ~4B parameters active per token: the weights need lots of RAM (they all must be reachable), but the arithmetic per token is small. (I chose to use a 4B active token count based on initial benchmarking, though the actual requirement might be a little hit-or-miss depending on the specific token distribution.) It decodes at roughly DDR5 bandwidth, which is a rate I accept for research and long-document work. The workloads that ask for it (paperless batches, Hermes’s optional deep mode) are asynchronous anyway, and they carry the timeouts to match. What I do not put on CPU is anything sitting on an interactive path. The contextSize on every service is a RAM budget too: qwen3-embedding-0-6b needed its context reduced after it started getting OOMKilled, and llama.cpp threads get throttled into uselessness by CPU limits (the big CPU model’s deployment lost its CPU limit for exactly that reason).
There is also a cautionary postscript about trying to split the difference. One of my nodes is a recent AMD APU with an RDNA3 iGPU, which looked like the perfect middle tier: Vulkan compute with the model’s weights in system RAM, sharing the memory controller (GTT mapped straight into DDR5, no PCIe tax). In theory an APU is a VRAM-free GPU. In practice, current llama.cpp builds have a RADV regression on RDNA iGPUs with small VRAM carves. My node’s heap is a 512 MiB carve plus ~7.6 GiB of GTT, and the model load dies at command submission regardless of buffer sizes. The 26B runs on plain CPU builds instead, which is slower than the theory and far faster than the alternative of it not existing.
Sharing the pool, and the timeouts it implies
A pool swap under swapPolicy: reclaim means: evict the resident member, schedule the incoming one, run its init containers (cache verification), load the GGUF, promote. I measured it at roughly 90 seconds, sometimes more before a cold member serves tokens. The router does the right thing and waits; the clients have to agree to wait too, which means every consumer’s timeout has to be set for the cold path, not the warm one:
- karakeep:
INFERENCE_JOB_TIMEOUT_SEC: 180(a full swap plus inference). - paperless:
PAPERLESS_AI_LLM_REQUEST_TIMEOUT: 900(document batches can span several swaps).
There is a subtler consequence: the default member is the whole experience for normal traffic. Requests for whatever is already resident are instant, requests for a pool member pay ~90 s once and then are instant until something else reclaims the card. So the default (gemma4-e4b) ends up being whichever model gets used most, and the swap cadence is what the pool costs you.
Wiring the consumers in
Every consumer points the same way (this is karakeep’s deployment.yaml):
# apps/karakeep/deployment.yaml (excerpt)
- name: OPENAI_BASE_URL
value: "http://llmkube.llmkube.svc.cluster.local:8080/v1"
- name: OPENAI_API_KEY
value: "llmkube" # not used, but many clients insist the variable exists
- name: INFERENCE_TEXT_MODEL
value: "gemma4-e4b"
- name: INFERENCE_IMAGE_MODEL
value: "gemma4-e4b"
- name: INFERENCE_JOB_TIMEOUT_SEC
value: "180"
- name: EMBEDDING_TEXT_MODEL
value: "qwen3-embedding-0-6b"
| app | chat/vision model | embeddings |
|---|---|---|
| karakeep | gemma4-e4b (text and image) | qwen3-embedding-0-6b |
| paperless-ngx | ornith15-9b | qwen3-embedding-0-6b |
| hermes | gemma4-e4b; 26b-a4b as an optional deep-dive provider | — |
| Open WebUI | anything it asks the router for | for RAG |
The benchmark that decided Hermes’s default is a comment in Hermes’s config, because it is worth putting in writing: gemma4-e4b decodes at roughly 26 tok/s on the RX 580 against ornith15-9b’s 16, and carries 64k of context versus 24k. For a coding agent that works out at about three times less compaction churn. Numbers like that are how the resident member of the pool gets picked.
The router also has an HTTPRoute at llmkube.lab.cowley.tech, so the same OpenAI endpoint serves external clients. It is not accessible outside my LAN, don’t even try and use it.
And Ollama? Still deployed, scaled to zero. Its last real job was proxying Ollama’s hosted cloud models for Hermes, which ended when the router went live. I may scale it back up occasionally with minimal resources in order to use the cloud models.
Alerting and dashboards
llmkube ships Prometheus rules and Grafana dashboards, which is generous, and each needed one correction to function in this cluster:
- The controller’s metrics endpoint returned 401. With
metrics.secure: true(the chart default) it demands a ServiceAccount token, and the chart’s ServiceMonitor has no field to send one, so the operator tier scraped nothing. Plain HTTP on the ClusterIP metrics service (metrics.secure: false) fixes it. Is it perfect? No it isn’t, but the data never leaves my cluster, so I could not care less. - Every scrape object needed
additionalLabels: release: prometheus. My Prometheus CR selects ServiceMonitors/PodMonitors/Rules on that label alone; the chart’s default labels produce objects that exist and that no Prometheus will ever look at. Same story for the dashboards: the Grafana sidecar’s selector is the literal stringgrafana_dashboard: "1", nottrue. - The GPU rules assume NVIDIA data-centre cards. The
gpuHealthgroup (Xid errors, row remapping) is DCGM-only, so it stays off. The utilisation alert fires at 90% by default; on a dedicated inference GPU, saturation is the desired state, so the threshold went to 95% and the temperature threshold 85→90 to survive my GPU doing useful work. The AMD metrics feeding those rules come from the llmkube-amdgpu-exporter DaemonSet (ghcr.io/defilantech/llmkube-amdgpu-exporter). - The shipped
InferenceServiceDownalert pages on normal pool operation. Its expression isup == 0with a hard-codedfor: 1m, and a swap takes a member down for ~90 s by design. Every reclaim-based swap fired critical. Thefor:is not a chart value, so the chart rule is routed to a blackhole receiver in Alertmanager and replaced by a twin in my own monitoring/llmkube withfor: 10m: swaps are silent, a model that is genuinely down still finds me. The chart’s recording rules stay enabled (the inference dashboard’s restart-rate panel depends on them).
Scrape-wise there are three tiers, all healthy now: the controller’s ServiceMonitor, PodMonitors for the llama.cpp pods and for the router proxy, and four dashboards actually loaded (llmkube-inference, llamacpp, model-router, amd-gpu-observability).
A week later
The state of play:
$ kubectl get modelpools -n llmkube
NAME SWAP POLICY READY MEMBER STATUS AGE
agent4-gpu reclaim gemma4-e4b Ready 5d
$ kubectl get inferenceservices -n llmkube
NAME STATUS REPLICAS
bge-m3 Ready 1
gemma4-26b-a4b Ready 1
gemma4-e4b Ready 1
mellum21-instruct Stopped
mellum21-thinking Stopped
ornith15-9b Stopped
qwen3-embedding-0-6b Ready 1
Stopped is not dead: those four are pool members waiting for their turn on the card. Seven models on one shared RX 580. Three CPU-resident services that are never swapped. Every AI consumer in the lab on one URL, and Ollama retired without a single workflow noticing.
The honest caveats:
- RAM is the new GPU. With models on CPU nodes come memory claims: three of my nodes now sit at 89%, 94% and 99% utilisation. VRAM decided what runs where; RAM is what I monitor now.
- Swaps are slow. ~90 s cold is acceptable because the resident default absorbs normal traffic, but the first request for a cold member pays it, and every consumer timeout in this post exists because of swap latency.
- The chart is young. The 401-metrics, label-selector, hard-coded-alert and stock-image problems are all chart-level, not operator-level, and all upstreamable.
Conclusion
The snobby colleagues got their way in the end. However, I did not want to give up on the convenience Ollama gave me. LLMKube turned out to give me all of that, and as a bonus it brought my GPU into play.
The Vulkan image pin and the VRAM-versus-RAM budgeting are the two things I would tell anyone attempting this: check which build is actually running, and decide per model whether the right currency for it is VRAM or RAM.
If your lab has exactly one GPU and it happens to be the wrong brand, LLMKube is worth a look.
Hopefully this is useful for someone else too.
