Run in production

Tenants, tokens and network security

Every connection belongs to one namespace, proven once with a token when it opens. Quotas, metrics and keys are per namespace. Plain TCP means the network boundary does the rest.

Last updated

The identity model

  • Authenticate once per connection. The client sends a namespace name and token when it connects; the daemon compares the token in constant time and the connection then lives inside that namespace. There is no per-request check to get wrong.
  • Keys cannot cross tenants. The namespace is part of every key lookup, so two tenants with identical prompts never read each other's blocks.
  • Closed by default. A daemon with no namespaces file, or an empty one, refuses every connection.
  • Failures are counted. kvb_auth_failures_total rises on every rejected token, without recording the token or the address.

The namespaces file

Point namespaces_path (or KVBLOCKD_NAMESPACES, or --namespaces) at a YAML file like this. Store token hashes, so the file holds no secret.

namespaces.yaml
namespaces:
  - name: team-a
    id: 2                          # nonzero, permanent, never reused for another tenant
    token_sha256: "64-hex-chars"   # echo -n SECRET | shasum -a 256
    quota_dram: 8589934592         # 8 GiB, enforced when blocks are written
    quota_nvme: 68719476736        # 64 GiB of flash, reserved in whole 256 MiB segments
    quota_s3: 549755813888         # 512 GiB in S3, the same way
    pin_quota: 1073741824          # 1 GiB of pinned blocks, at most dram_arena_bytes
  - name: team-b
    id: 3
    token_sha256: "64-hex-chars"
  • namerequired

    What clients send when they connect, and the label on per-tenant metrics.

  • idrequired, nonzero

    Keys on-disk ownership, so it must stay the same across restarts and must not be reused for another tenant. The daemon refuses duplicate ids. Data-plane metrics carry it as the ns label.

  • token_sha256or token

    The SHA-256 of the token as 64 hex characters (preferred), or the token in clear for local testing.

  • quota_dram0 = unlimited

    Bytes this tenant may hold in DRAM. Enforced: a write that would exceed it is refused with ERR_QUOTA_BYTES.

  • quota_nvme, quota_s30 = unlimited

    Enforced on the physical tier: flash and S3 usage are reserved in whole 256 MiB segments. kvb_tenant_physical_bytes shows usage.

  • pin_quotadaemon default 128 MiB

    Bytes of hard-pinned blocks. Must not exceed dram_arena_bytes; the daemon refuses a larger value at startup.

Quotas

The DRAM quota is the one that protects tenants from each other today. When the arena is under pressure, tenants over their quota are evicted from first. Watch each tenant against its limits with kvb_tenant_bytes and kvb_tenant_quota_bytes, both labelled by namespace name and tier.

Per-tenant rate or bandwidth limits are not part of the daemon.

Add tenants at runtime

The admin plane adds namespaces and changes quotas without a restart. kvbctl hashes the token on the client side; only the hash reaches the daemon.

Shell
# on the store machine: the admin plane listens on loopback only (see kvbctl docs to turn it on)
export KVB_ADMIN_TOKEN_FILE=/etc/kvblockd/admin.token     # or pass -admin-token-file to each command
printf '%s' 'team-c-secret' > /run/kvb/team-c.token      # no trailing newline
kvbctl namespace add -name team-c -id 4 -token-file /run/kvb/team-c.token -quota-dram 4294967296
# {"note":"runtime only ... add the entry to the namespaces file to survive a restart","ok":true}

kvbctl namespace list
# [{"name":"team-c","id":4,"quota_bytes":{"dram":4294967296,"nvme":0,"s3":0},
#   "usage_bytes":{"dram":0,"nvme":0,"s3":0},"physical_usage_bytes":{"nvme":0,"s3":0},"pin_quota":0}, ...]

kvbctl quota set -name team-c -tier dram -bytes 8589934592
Runtime changes are not saved

Changes made through the admin plane last until the daemon restarts. Add the same entry to the namespaces file as well, as the command's reply reminds you.

Ports and exposure

PortSettingWhat it servesReachable from
9440listen_addrData plane: engines and kvbctl. Default binds all interfaces (":9440"); the daemon warns on a non-loopback bind.Private network or VPC only
9441admin_addrAdmin plane: add tenants, set quotas. Off unless admin_addr is set, with an admin_token_file of at least 32 bytes. Loopback only; any other address is refused at startup.Never
9442metrics_addr/metrics and /healthz. Loopback by default.Your Prometheus only
9443pprof_addrGo profiler. Off by default, loopback only when on; tunnel in to use it.Never
9500s3compat_addrS3-compatible endpoint for NIXL object clients. Off by default.Private network only
  • The wire is not encrypted. Tokens and blocks cross port 9440 in clear text. Keep it on a private segment, restrict it to engine hosts with a firewall or NetworkPolicy, or put a TCP proxy that terminates TLS in front of it.
  • Never expose 9440 to the internet.
  • Connection cap: max_conns (1,024 by default) bounds open connections as a cheap floor against floods.

Handling tokens

  • Generate long random tokens, for example openssl rand -hex 32, one per tenant.
  • kvbctl: use -token-file or KVBCTL_TOKEN. The -token flag shows the secret in ps and shell history; keep it for local tests.
  • Engines: the token goes in the connector settings; for LMCache and vllm-kvblockd it can come from KVBLOCKD_TOKEN in the environment instead. Treat the engine's launch config as a secret.
  • Kubernetes: the Helm chart puts tenants in a Secret; use namespaces.existingSecret to manage it yourself.
  • Rotating a token: a namespace has one token at a time. Change its token_sha256 in the file, restart the daemon, then restart the engines with the new token. Until an engine is updated it cannot connect and serves by recomputing, so rotate in a quiet window.

Report a vulnerability through the security page.

Something missing or wrong on this page? Email rudray@kvstash.com and it gets fixed.