|
| 1 | +# PrisKV KVCache Cluster × AIBrix Integration Example |
| 2 | + |
| 3 | +This README describes how to deploy: |
| 4 | + |
| 5 | +- **KVCache Controller** (Kubernetes control plane for KVCache clusters) |
| 6 | +- A **PrisKV-based KVCache cluster** (HPKV data nodes + Redis-compatible metadata + Watcher) |
| 7 | +- An **AIBrix-enabled vLLM inference service** that uses PrisKV as a remote KV cache backend |
| 8 | + |
| 9 | +This example is intended as a step-by-step tutorial you can run on any compatible Kubernetes cluster (e.g., Volcengine VKE) with GPU nodes. |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## 1. Architecture Overview |
| 14 | + |
| 15 | +This example sets up the following components: |
| 16 | + |
| 17 | +1. **KVCache Controller** |
| 18 | + - Watches `KVCache` custom resources |
| 19 | + - Creates and manages: |
| 20 | + - Redis-compatible metadata service |
| 21 | + - Watcher Pod (for node discovery and registration) |
| 22 | + - PrisKV data nodes |
| 23 | + |
| 24 | +2. **PrisKV KVCache Cluster** |
| 25 | + - Distributed KV cache backend |
| 26 | + - Uses Redis-compatible metadata and PrisKV data nodes for KV storage |
| 27 | + |
| 28 | +3. **AIBrix-enabled vLLM Service** |
| 29 | + - vLLM image extended with: |
| 30 | + - AIBrix KVCache Offloading connector |
| 31 | + - PrisKV client SDK |
| 32 | + - Uses `AIBrixOffloadingConnectorV1Type3` to offload KV tensors to PrisKV |
| 33 | + - Treats PrisKV as an L2 cache backend (L1 DRAM cache is optional) |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## 2. Prerequisites |
| 38 | + |
| 39 | +### 2.1 Kubernetes Cluster with GPUs |
| 40 | + |
| 41 | +You need a Kubernetes cluster with GPU nodes. For example, on Volcengine VKE: |
| 42 | + |
| 43 | +- Create a VKE cluster with GPU instances such as **H20** / **A800** that support RDMA. |
| 44 | +- Official docs (examples): |
| 45 | + - Cluster creation: `https://www.volcengine.com/docs/6460/100936?LibVersion=2.27.0` |
| 46 | + - `kubectl` configuration: `https://www.volcengine.com/docs/6460/1374028-` |
| 47 | + |
| 48 | +Other Kubernetes providers are also fine as long as: |
| 49 | + |
| 50 | +- GPU nodes are available |
| 51 | +- Networking is sufficient for PrisKV and inference pods (RDMA recommended but not strictly required for functional validation) |
| 52 | + |
| 53 | +### 2.2 kubectl Access |
| 54 | + |
| 55 | +Make sure `kubectl` can talk to the cluster: |
| 56 | + |
| 57 | +```bash |
| 58 | +kubectl get nodes |
| 59 | +``` |
| 60 | + |
| 61 | +You should see your GPU nodes listed. |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +## 3. Install AIBrix |
| 66 | + |
| 67 | +The KVCache Controller is part of AIBrix and it runs in its own namespace and reconciles `KVCache` CRs. |
| 68 | + |
| 69 | +```bash |
| 70 | +# Install envoy-gateway, this is not aibrix component. you can also use helm package to install it. |
| 71 | +helm install eg oci://docker.io/envoyproxy/gateway-helm --version v1.2.8 -n envoy-gateway-system --create-namespace |
| 72 | + |
| 73 | +# patch the configuration to enable EnvoyPatchPolicy, this is super important! |
| 74 | +kubectl apply -f - <<EOF |
| 75 | +apiVersion: v1 |
| 76 | +kind: ConfigMap |
| 77 | +metadata: |
| 78 | + name: envoy-gateway-config |
| 79 | + namespace: envoy-gateway-system |
| 80 | +data: |
| 81 | + envoy-gateway.yaml: | |
| 82 | + apiVersion: gateway.envoyproxy.io/v1alpha1 |
| 83 | + kind: EnvoyGateway |
| 84 | + provider: |
| 85 | + type: Kubernetes |
| 86 | + gateway: |
| 87 | + controllerName: gateway.envoyproxy.io/gatewayclass-controller |
| 88 | + extensionApis: |
| 89 | + enableEnvoyPatchPolicy: true |
| 90 | +EOF |
| 91 | +``` |
| 92 | + |
| 93 | +```bash |
| 94 | +# Install AIBrix CRDs. `--install-crds` is not available in local chart installation. |
| 95 | +kubectl apply -f dist/chart/crds/ |
| 96 | + |
| 97 | +# Install AIBrix with the pinned release version: |
| 98 | +helm install aibrix dist/chart -f dist/chart/stable.yaml -n aibrix-system --create-namespace |
| 99 | +``` |
| 100 | + |
| 101 | +> At the moment, the controller is assumed to run in `aibrix-system`. Future versions may support custom namespaces. |
| 102 | +
|
| 103 | +Verify the controller is running: |
| 104 | + |
| 105 | +```bash |
| 106 | +kubectl get pods -n aibrix-system |
| 107 | +kubectl get deployments -n aibrix-system |
| 108 | +``` |
| 109 | + |
| 110 | +You should see controller-related Pods in `Running` state. |
| 111 | + |
| 112 | +--- |
| 113 | + |
| 114 | +## 4. Deploy a PrisKV KVCache Cluster |
| 115 | + |
| 116 | +With the controller up, define a `KVCache` custom resource and let the controller create the cluster. |
| 117 | + |
| 118 | +### 4.1 Apply KVCache CR |
| 119 | + |
| 120 | +```bash |
| 121 | +kubectl apply -f kvcache.yaml |
| 122 | +``` |
| 123 | + |
| 124 | +After the controller reconciles the resource, you should see pods similar to: |
| 125 | + |
| 126 | +```bash |
| 127 | +kubectl get pods |
| 128 | +NAME READY STATUS RESTARTS AGE |
| 129 | +debug 1/1 Running 0 23h |
| 130 | +kvcache-cluster-0 1/1 Running 0 8h |
| 131 | +kvcache-cluster-1 1/1 Running 0 8h |
| 132 | +kvcache-cluster-2 1/1 Running 0 8h |
| 133 | +kvcache-cluster-kvcache-watcher-pod 1/1 Running 0 8h |
| 134 | +kvcache-cluster-redis 1/1 Running 0 8h |
| 135 | +``` |
| 136 | + |
| 137 | +Roles: |
| 138 | + |
| 139 | +- `kvcache-cluster-0/1/2` – PrisKV data nodes |
| 140 | +- `kvcache-cluster-redis` – Redis-compatible metadata service |
| 141 | +- `kvcache-cluster-kvcache-watcher-pod` – Watcher that discovers and registers data nodes into metadata |
| 142 | + |
| 143 | +### 4.2 Verify Redis Metadata |
| 144 | + |
| 145 | +To confirm the cluster is writing metadata correctly: |
| 146 | + |
| 147 | +```bash |
| 148 | +kubectl exec -it kvcache-cluster-redis -- bash |
| 149 | +``` |
| 150 | + |
| 151 | +Inside the container: |
| 152 | + |
| 153 | +```bash |
| 154 | +redis-cli -a kvcache_nodes |
| 155 | +KEYS * |
| 156 | +# Inspect keys according to your schema |
| 157 | +``` |
| 158 | + |
| 159 | +If you can see keys representing nodes, shards or sessions, the KVCache cluster is healthy. |
| 160 | + |
| 161 | +--- |
| 162 | + |
| 163 | +## 5. Deploy an AIBrix-Enabled vLLM Service Using PrisKV |
| 164 | + |
| 165 | +Next, we deploy a vLLM service that: |
| 166 | + |
| 167 | +- Uses the **AIBrix KV Offloading connector** (`AIBrixOffloadingConnectorV1Type3`) |
| 168 | +- Configures **PrisKV** as the L2 KV cache backend (through Redis metadata) |
| 169 | + |
| 170 | + |
| 171 | +```yaml |
| 172 | +kubectl apply -f vllm.yaml |
| 173 | +``` |
| 174 | + |
| 175 | + |
| 176 | +--- |
| 177 | + |
| 178 | +## 6. End-to-End Validation |
| 179 | + |
| 180 | +### 6.1 Check All Pods |
| 181 | + |
| 182 | +```bash |
| 183 | +kubectl get pods |
| 184 | +``` |
| 185 | + |
| 186 | +You should see: |
| 187 | + |
| 188 | +- `kvcache-cluster-*` pods from the PrisKV cluster |
| 189 | +- `deepseek-r1-distill-llama-8b-*` inference pod |
| 190 | + |
| 191 | +All should be `Running`. |
| 192 | + |
| 193 | +### 6.2 Send Test Requests |
| 194 | + |
| 195 | +Port-forward the service: |
| 196 | + |
| 197 | +```bash |
| 198 | +kubectl port-forward svc/deepseek-r1-distill-llama-8b 8000:8000 |
| 199 | +``` |
| 200 | + |
| 201 | +Then call the OpenAI-compatible endpoint: |
| 202 | + |
| 203 | +```bash |
| 204 | +curl http://127.0.0.1:8000/v1/chat/completions -H "Content-Type: application/json" -d '{ |
| 205 | + "model": "deepseek-r1-distill-llama-8b", |
| 206 | + "messages": [ |
| 207 | + {"role": "user", "content": "Hello, PrisKV and AIBrix!"} |
| 208 | + ] |
| 209 | + }' |
| 210 | +``` |
| 211 | + |
| 212 | +These requests will generate KVCache traffic. |
| 213 | + |
| 214 | +### 6.3 Check Redis Metadata |
| 215 | + |
| 216 | +Inspect Redis again: |
| 217 | + |
| 218 | +```bash |
| 219 | +kubectl exec -it kvcache-cluster-redis -- bash |
| 220 | +redis-cli -a kvcache_nodes |
| 221 | + |
| 222 | +KEYS * |
| 223 | +# Inspect keys to confirm entries related to sessions / nodes / chunks have been created |
| 224 | +``` |
| 225 | + |
| 226 | +If new keys appear after you send requests, it means: |
| 227 | + |
| 228 | +> The AIBrix-enabled vLLM instance is successfully using the PrisKV cluster as its remote KV cache backend. |
| 229 | +
|
| 230 | + |
| 231 | +## 7. Next Steps |
| 232 | + |
| 233 | +From here, you can extend this example to: |
| 234 | + |
| 235 | +- Share a single PrisKV cluster across multiple engines (vLLM, SGLang, etc.). |
| 236 | +- Combine L1 DRAM cache with L2 PrisKV (multi-tier KV caching). |
| 237 | +- Run benchmarks to evaluate performance and cost efficiency under real workloads. |
| 238 | +- Integrate with your existing autoscaling and routing stack for production use. |
| 239 | + |
| 240 | +If you have feedback or want to contribute improvements to the controller, cluster layout, or AIBrix integration, feel free to open an issue or pull request in this repository. |
0 commit comments