Reference
kvbctl command reference
kvbctl is the command-line tool for the KVStash daemon: store and fetch blocks, probe prefixes and read stats on the data plane, and manage tenants on the admin plane.
Last updated
Basics
kvbctl exists [flags] KEY... probe the prefix chain
kvbctl get [flags] [-o FILE] KEY fetch one block (stdout by default)
kvbctl put [flags] KEY <FILE|-> store one block (stdin with -)
kvbctl delete [flags] [-force] KEY... remove blocks
kvbctl stats [flags] server stats JSON
kvbctl namespace add|list [flags] tenant admin (loopback admin socket)
kvbctl quota set [flags] per-tier tenant quota (admin socket)
kvbctl version print version - Flags go before the arguments.
kvbctl get -o out.bin KEYworks;kvbctl get KEY -o out.binfails with "need exactly one KEY", andexistsordeletewould treat-oas one more key. - Token sources, highest first:
-token, then-token-file, then theKVBCTL_TOKENenvironment variable. - Engines do not need kvbctl. It is for operators: smoke tests, checks, and tenant changes without a restart.
Data commands
exists KEY...Prints consecutive=N, the number of keys present from the first one on, then one line per key with its status. Exit 1 if any key is missing.
get [-o FILE] KEYFetches one block to stdout or FILE. The checksum is verified before any byte is written out. Exit 1 if not found.
put KEY FILEStores FILE, or stdin with -, as one block. Blocks are write-once: putting a key that already exists succeeds and keeps the first block (kvbctl still prints stored N bytes).
delete [-force] KEY...Deletes blocks and prints one status per key. Without -force, leased or hard-pinned blocks are kept.
statsPrints the daemon's stats document as JSON: arena, blocks, bytes, evictions and per-tier detail.
versionPrints the kvbctl version.
export KVBCTL_TOKEN=$(cat /run/kvb/demo.token)
S="-addr 10.0.0.5:9440 -ns demo"
# store a file and read it back to another file
kvbctl put $S model-card ./card.json
# stored 1834 bytes
kvbctl get $S -o /tmp/card.json model-card
# how many keys, from the first, are present?
kvbctl exists $S a b c
# consecutive=2
# a OK
# b OK
# c NOT_FOUND
# delete, even if leased or pinned
kvbctl delete $S -force a b
# a OK
# b OK Admin commands
These talk to the admin listener (-admin, default 127.0.0.1:9441), which accepts loopback connections only, so run them on the store machine. The listener is off until you set admin_addr and admin_token_file; without them every admin command fails with connection refused, and without the admin token it fails with admin authentication required. Changes last until the daemon restarts; add them to the namespaces file too.
# config.yaml: the admin plane is off until both lines are set
admin_addr: "127.0.0.1:9441"
admin_token_file: "/etc/kvblockd/admin.token"
# make the admin token (at least 32 bytes), readable by the user that runs the daemon
openssl rand -hex 32 | sudo tee /etc/kvblockd/admin.token >/dev/null
sudo chown kvblockd:kvblockd /etc/kvblockd/admin.token # the systemd unit's User; yours if you run it by hand
sudo chmod 600 /etc/kvblockd/admin.token
# then restart the daemon namespace add-name, -id (nonzero, permanent), -token-file, and optional -quota-dram, -quota-nvme, -quota-s3, -pin-quota in bytes (0 = unlimited). The token is hashed before it is sent.
namespace listJSON list of namespaces with their quotas and current usage per tier.
quota set-name, -tier (dram, nvme or s3) and -bytes (0 = unlimited).
# runs on the store machine: the admin plane is loopback only.
# kvbctl must read the admin token too: run these with sudo -E, or as the daemon's user
export KVB_ADMIN_TOKEN_FILE=/etc/kvblockd/admin.token # or pass -admin-token-file
openssl rand -hex 24 > team-a.token # the tenant's own token
kvbctl namespace add -name team-a -id 2 -token-file ./team-a.token \
-quota-dram 8589934592 -pin-quota 1073741824
kvbctl namespace list
kvbctl quota set -name team-a -tier nvme -bytes 68719476736 Keys
Blocks are addressed by 32-byte keys. For convenience, kvbctl hashes a plain argument with SHA-256, so kvbctl put greeting - works. Engines derive keys their own way, so to look at a block an engine wrote, pass its key as 64 hex characters with -hex.
Exit codes
0Success.
1Not found, or a per-key or status failure.
2Usage error, connection failure, or a local I/O error.
Something missing or wrong on this page? Email rudray@kvstash.com and it gets fixed.