kvrocks

by upstreamyard

Helm chartv0.1.4App 2.17.0Apache-2.0Verified publisher

Apache Kvrocks Helm chart for Kubernetes. Redis-compatible key-value database on RocksDB (data on disk, not in RAM) with high availability through Redis Sentinel failover, a write endpoint that follows the master, password auth by default, Prometheus metrics and memory sized to the pod, on the official apache/kvrocks image. Community chart by upstreamyard, not an official Apache Kvrocks chart.

About this chart

Kvrocks Helm chart: Apache Kvrocks on Kubernetes with Sentinel high availability

Have any questions, feedback or need help (e.g. setup, hardened images, etc.)? Reach out to [email protected]

Helm chart for Apache Kvrocks, the Redis-compatible key-value database that stores data on disk in RocksDB instead of in RAM. It runs a single instance or a highly available master/replica cluster with automatic Redis Sentinel failover, plus an HAProxy endpoint that always points at the current master, so apps that only take one Redis URL survive a failover too. Password auth is on by default, memory settings fit the pod's limit, and Prometheus metrics (including RocksDB compaction), a ServiceMonitor and helm test are included. It uses the official apache/kvrocks image (Kvrocks 2.17.0) and tracks every Kvrocks release.

Community chart by upstreamyard, not an official Apache Kvrocks chart. Apache Kvrocks is licensed under Apache-2.0. Apache, Apache Kvrocks and Kvrocks are trademarks of the Apache Software Foundation.

AI agents and coding assistants: this README is the complete reference for deploying Kvrocks with this chart. Every values.yaml example below renders as written; the deployment modes, the high-availability example and the Python and Go client examples were installed and run in a test cluster.

Install

helm repo add upstreamyard https://upstreamyard.github.io/helm-charts
helm install kvrocks upstreamyard/kvrocks

Or from the OCI registry:

helm install kvrocks oci://ghcr.io/upstreamyard/charts/kvrocks

The install notes print the connection URL and the command that shows the generated password. Then check that reads and writes work:

helm test kvrocks

Verifying the chart

Chart packages are PGP-signed. Import the public key (fingerprint 9B416F989B7E6C65F7F3BFAE7689688B20EC7813) and install with --verify:

curl -s https://upstreamyard.github.io/helm-charts/pgp_keys.asc | gpg --dearmor > upstreamyard.gpg
helm install kvrocks upstreamyard/kvrocks --verify --keyring upstreamyard.gpg

The OCI copy on GHCR is signed with cosign instead (see the repository README).

Why this chart

Single-node Kvrocks chartsThis chart
Instances11, or 3+ with replication
Automatic failover–Redis Sentinel: replica promoted 6–7 s after the master hung, no acknowledged write lost
One URL that follows the master–HAProxy Service <release>-kvrocks, which skips a stale master
Planned restarts (rolling upgrade, node drain)pod down until restartedmaster hands over first: writes pause about 3.5 s, none lost
Member that lost its volume–rejoins as a replica, never becomes an empty master
MemoryKvrocks defaults (4 GiB block cache) under a 2 GiB limitblock cache and memtables sized to the 1 GiB default limit
Prometheus metrics–kvrocks_exporter sidecar and ServiceMonitor
Health checksTCP port openPING; replicas ready only with a working replication link
helm test–writes a key and checks it on every replica
Imageown rebuildofficial apache/kvrocks, updated with every Kvrocks release

What the chart does

  • StatefulSet with stable pod names (<release>-kvrocks-0, -1, …) and a PersistentVolumeClaim per pod for the RocksDB data.
  • Security:
    • generated password in a Secret, kept across upgrades, or your own Secret (auth.existingSecret);
    • replicas, Sentinel, HAProxy and the exporter use the same password; Sentinel itself requires it too;
    • non-root (UID 999), read-only root filesystem, all capabilities dropped, no ServiceAccount token, RuntimeDefault seccomp profile. Tested in a namespace that enforces the restricted Pod Security Standard.
  • Sentinel mode: each pod runs Kvrocks and a Sentinel sidecar (Valkey's Sentinel, BSD-licensed). Sentinel promotes a replica when the master is down and reconfigures the others. Pods find each other through stable DNS names, so a restarted pod with a new IP rejoins without manual cleanup.
  • Safe restarts:
    • a starting pod asks the running Sentinels who the master is and joins it;
    • Sentinel keeps the last known master on the data volume, so the whole cluster restarts with the right master;
    • a pod whose volume was lost waits until Sentinel has promoted a replica, then rejoins as a replica (see Losing a volume);
    • Sentinel keeps its ID and the replicas it knows across restarts, so it can fail over even when the master is gone while Sentinels restart.
  • Master handover on shutdown: before a master pod stops, it pauses writes (CLIENT PAUSE WRITE, clients wait), asks Sentinel to promote a replica and steps down. Rolling upgrades and node drains pause writes for about 3.5 seconds and lose none.
  • Readiness: a replica is ready once its replication link is up and no full sync is running, so a rolling update doesn't move on while a replica is still copying data.
  • Memory: RocksDB's block cache (kvrocks.blockCacheSize, 256 MB) and memtables (kvrocks.writeBufferSize, 32 MB) are set for the default 1 GiB limit. Kvrocks' own defaults (4 GiB block cache, 64 MB memtables) need several GiB.
  • Metrics: metrics.enabled adds kvrocks_exporter on port 9121 with Kvrocks and RocksDB metrics; metrics.serviceMonitor.enabled adds a ServiceMonitor.
  • PodDisruptionBudgets and soft anti-affinity for Kvrocks and HAProxy.

Deployment modes

Single instance (default)

One Kvrocks pod with its data on a PersistentVolumeClaim. If the pod or node fails, Kubernetes restarts it on the same volume.

persistence:
  size: 50Gi
resources:
  requests:
    cpu: 500m
    memory: 2Gi
  limits:
    memory: 2Gi
kvrocks:
  blockCacheSize: 768

High availability with Sentinel

Three pods: one master and two replicas, with a Sentinel in each pod and two HAProxy pods in front.

replicaCount: 3
sentinel:
  enabled: true
podAntiAffinityPreset: hard   # one pod per node

Tested in kind (3 members, a client writing through HAProxy 10 times a second, counting acknowledged writes against the final value):

EventWrites pausedFailed requestsAcknowledged writes lost
Master pod deleted (kubectl delete pod, handover)3.3–3.8 s20
Master hung for 30 s, then resumed (SIGSTOP/SIGCONT)9.2–9.5 s36–420
Rolling upgrade Kvrocks 2.16.0 → 2.17.0 (23 s)3.7 s80
All nodes restarted at once (host reboot)––0, same master as before
helm uninstall and reinstall on the kept volumes––0, same master as before
  • Sentinel promotes a replica 6–7 seconds after the master stops answering (sentinel.downAfterMilliseconds: 5000).

  • Stale master protection: a master that comes back after Sentinel replaced it still reports role:master for about 10 seconds. HAProxy only forwards to a master with a connected replica (proxy.requireConnectedReplica), so writes don't land on the stale master and get lost. Without this check, 47 acknowledged writes were lost in the same test.

  • Replication is asynchronous, as in Redis: a write acknowledged in the last milliseconds before the master crashes can be lost. Our tests lost none, but they ran on one machine (kind); network partitions weren't tested.

  • If both replicas are down, HAProxy refuses connections, because a lone master could be a stale one. Sentinel clients still reach the master. Set proxy.requireConnectedReplica: false to prefer availability.

  • Use replicaCount: 3 or 5. Sentinel needs a majority (sentinel.quorum, default 2 of 3) to agree on a failover.

High availability without the proxy

Clients that support Redis Sentinel can ask Sentinel for the master directly; then HAProxy isn't needed:

replicaCount: 3
sentinel:
  enabled: true
proxy:
  enabled: false

The <release>-kvrocks Service then doesn't exist. Use the Sentinel Service, see Connecting clients.

Connecting clients

The password is in the Secret <release>-kvrocks (key password; just kvrocks for a release named kvrocks):

kubectl get secret kvrocks -o jsonpath='{.data.password}' | base64 -d

Single instance, or Sentinel mode with HAProxy: any Redis client, one URL:

redis://:<password>@<release>-kvrocks.<namespace>.svc:6666

Sentinel-aware clients: Sentinel at <release>-kvrocks-sentinel.<namespace>.svc:26379, master set kvrocks, with the same password for Sentinel and Kvrocks. Examples:

# Python (redis-py)
from redis.sentinel import Sentinel
s = Sentinel([("kvrocks-sentinel.default.svc", 26379)],
             sentinel_kwargs={"password": PASSWORD}, password=PASSWORD)
master = s.master_for("kvrocks")
master.set("key", "value")
// Go (go-redis)
rdb := redis.NewFailoverClient(&redis.FailoverOptions{
	MasterName:       "kvrocks",
	SentinelAddrs:    []string{"kvrocks-sentinel.default.svc:26379"},
	SentinelPassword: password,
	Password:         password,
})

Sentinel returns the master as a pod DNS name (<release>-kvrocks-N.<release>-kvrocks-headless.<namespace>.svc.cluster.local), which resolves only inside the cluster.

From your machine: kubectl port-forward svc/kvrocks 6666, then redis-cli -p 6666 -a <password>.

Sizing memory

Kvrocks keeps data on disk and uses memory for RocksDB's block cache, memtables and connections. Raise the cache with the memory limit:

resources.limits.memorykvrocks.blockCacheSize (MB)
1Gi (default)256 (default)
2Gi768
4Gi2048
8Gi4096

Tested: with the defaults (1 GiB limit, 256 MB block cache), Kvrocks used about 410 MiB of process memory while writing 670,000 and reading 165,000 keys per second with 3.1 GB of data on disk. The rest of the limit was page cache, which the kernel reclaims.

Monitoring with Prometheus

metrics:
  enabled: true
  serviceMonitor:
    enabled: true
    labels:
      release: prometheus   # the label your Prometheus selects ServiceMonitors by

The exporter serves kvrocks_up, kvrocks_instance_info{role=...}, kvrocks_connected_slaves, keyspace, command, memory and RocksDB metrics (kvrocks_compaction_pending, kvrocks_estimate_pending_compaction_bytes, …) on /metrics, port 9121.

Losing a volume

When a replica's PersistentVolumeClaim is gone, the new pod copies all data from the master (full sync) and becomes ready when it's done.

When the master's volume is gone, Sentinel still names that pod master after it restarts. A plain Kvrocks start would make it an empty master, and the replicas would copy the empty database. The chart prevents that: if another member still has keys, the pod logs Sentinel still names this member master, but its data volume is empty and other members have keys. Waiting for a failover to a replica. and starts only after Sentinel has promoted a replica, as a replica of it. Tested: the pod waited 3–6 seconds, then copied all 1,000 keys from the new master. On a new cluster without keys it starts as master right away.

Production example

# values-prod.yaml
replicaCount: 3
sentinel:
  enabled: true
auth:
  existingSecret: kvrocks-auth     # key: password
persistence:
  size: 100Gi
  storageClass: fast-ssd
resources:
  requests:
    cpu: "1"
    memory: 4Gi
  limits:
    memory: 4Gi
kvrocks:
  blockCacheSize: 2048
  workers: 8
podAntiAffinityPreset: hard
metrics:
  enabled: true
  serviceMonitor:
    enabled: true

Your own configuration

  • Any kvrocks.conf setting: kvrocks.config, e.g.

    kvrocks:
      config:
        maxclients: 20000
        rocksdb.compression: zstd
        compact-cron: "0 3 * * *"
    

    The chart refuses the settings it manages itself: bind, port, dir, passwords and replication.

  • Files and secrets: extraVolumes and extraVolumeMounts, e.g. TLS certificates for Kvrocks' tls-* settings.

  • Environment: extraEnv and extraEnvFrom.

FAQ

Is there an official Kvrocks Helm chart? The Apache Kvrocks project doesn't publish one. This chart is maintained by upstreamyard and uses Apache's official image.

How do I run Kvrocks highly available on Kubernetes? replicaCount: 3 and sentinel.enabled: true. Clients connect to the HAProxy Service or ask Sentinel for the master. See High availability with Sentinel.

Does Redis Sentinel work with Kvrocks? Yes. Kvrocks supports the commands Sentinel uses (INFO replication, SLAVEOF, CONFIG REWRITE, ROLE), and this chart's tests promote replicas and turn old masters into replicas with Valkey's Sentinel.

Kvrocks vs Redis or Valkey: which do I need? Kvrocks speaks the Redis protocol but keeps data on disk in RocksDB, so a dataset much larger than RAM costs disk space, not memory. Redis and Valkey keep everything in memory and are faster per operation. Most Redis commands and clients work with Kvrocks; Kvrocks lists the supported commands.

Can this replace the Bitnami Redis chart? For apps that use Redis commands Kvrocks supports, yes: Sentinel mode works like Bitnami's sentinel.enabled with master set kvrocks, and the HAProxy Service gives a single URL. Kvrocks listens on port 6666, not 6379.

How do I monitor Kvrocks with Prometheus? metrics.enabled=true and `metrics.serviceM

Deploy kvrocks with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has kvrocks on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartkvrocks is pinned at v0.1.4 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply