Skip to content
Vector database engineering on Kubernetes · Chapter 18 of 20 Appendix A: Cheat sheet

Appendix A: Cheat sheet

What this appendix is for: you know what you want to do and are looking for the command. Every command ran in this course; the number in the last column leads to the day with the explanation, parameters and real output. Placeholders are in angle brackets. Read the addresses of your lab with kubectl get svc,pod -o wide.

From Day 10 on, Qdrant speaks only TLS and requires a key. Every curl to Qdrant then gets --cacert ~/labor/tag10/ca.crt -H "api-key: $(cat ~/labor/tag10/lese-key)" (for administration admin-key). In the tables this is abbreviated as ….

Site and storage

Command Purpose Day
ssh-keygen -t ed25519 -f ~/.ssh/vdb -C vdb-labor create the lab key 0
ssh-copy-id -i ~/.ssh/vdb.pub ubuntu@<ip> copy the key to a VM 0
INSTALL_K3S_VERSION=v1.37.3+k3s1 sh install-k3s.sh install the k3s server 0
longhornctl check preflight check nodes for Longhorn prerequisites 0
helm install longhorn longhorn/longhorn -n longhorn-system --version 1.13.0 install Longhorn 0
kubectl -n longhorn-system get replicas.longhorn.io prove the copies of a volume 0
kubectl -n ollama exec deploy/ollama -- ollama pull nomic-embed-text load the embedding model 0
kubectl -n qdrant exec qdrant-0 -c qdrant -- df -h /qdrant/storage volume usage inside the pod 3
kubectl -n qdrant patch pvc <pvc> -p '{"spec":{"resources":{"requests":{"storage":"4Gi"}}}}' grow a PVC 3
kubectl -n longhorn-system get volumes.longhorn.io <pv> -o jsonpath='{.spec.size} {.status.actualSize}' size and real space used 3
sudo fstrim -v <globalmount> report free blocks to Longhorn 3
kubectl -n longhorn-system get snapshots.longhorn.io snapshots, including automatic ones 3

Installing and running Qdrant

Command Purpose Day
helm repo add qdrant https://qdrant.github.io/qdrant-helm add the chart repository 2
helm install qdrant qdrant/qdrant --version 1.20.3 -n qdrant --create-namespace --values qdrant-werte.yaml install Qdrant 2
helm get values qdrant -n qdrant / helm history qdrant -n qdrant applied values, revisions 2, 3
kubectl -n qdrant rollout status statefulset/qdrant --timeout=300s wait until all pods are new and ready 5
curl -s http://<ip>:6333/readyz check readiness 2
kubectl -n qdrant logs qdrant-0 -c qdrant --since=15m log of the last 15 minutes 3
kubectl -n qdrant logs <pod> -c qdrant --previous --tail=8 log of the crashed run 9
helm upgrade … --force-conflicts take over fields owned by another manager 9

Collections, points, search

Command Purpose Day
curl -s -X PUT …/collections/doku -H 'Content-Type: application/json' -d '{…}' create a collection 2
curl -s -X POST …/collections/doku/points/count -H 'Content-Type: application/json' -d '{"exact": true}' count points 2
curl -s …/collections/<name> -o <datei> and jq -c '.result \| {status, optimizer_status, …}' <datei> read status and optimizer 3
curl -s -X PATCH …/collections/<name> -H 'Content-Type: application/json' -d '{"optimizers_config": {}}' kick the optimizer (also after a restart) 3, 9
curl -s -X PATCH …/collections/doku -H 'Content-Type: application/json' -d '{"optimizers_config": {"indexing_threshold": 1000}}' trigger the HNSW index 4
curl -s -X PUT …/collections/doku/index -H 'Content-Type: application/json' -d '{"field_name": "bereich", "field_schema": "keyword"}' create a payload index 4
curl -s -X POST …/collections/doku/facet -H 'Content-Type: application/json' -d '{"key": "bereich"}' count the values of a field 4
curl -s -X POST …/collections/doku/points/query -H 'Content-Type: application/json' -d '{"query": 1702, "limit": 10}' neighbours of a point 4
curl -s -X POST '…/points/query?consistency=all' -d '{"query": 1702, "limit": 3}' read with strict consistency 5
curl -s -X PATCH <url>/collections/glove -H 'Content-Type: application/json' -d '{"quantization_config":{"scalar":{"type":"int8","quantile":0.99,"always_ram":true}}}' enable scalar quantization 8
curl -s -X POST '<url>/collections/<name>/points/delete?wait=true' -d '{"filter":…}' delete points by filter 7

Cluster, shards, failures

Command Purpose Day
curl -s http://<pod-ip>:6333/cluster -o k.json Raft view of one peer 5, 7
jq -c '.result.raft_info \| {role, leader, term, commit}' k.json role, leader, term, commit 7
curl -s http://<pod-ip>:6333/collections/<name>/cluster shards and copy states of one peer 5
curl -s -X POST …/collections/doku/cluster -d '{"replicate_shard": {…}}' copy a shard to another peer 5
curl -s -X POST <url>/collections/<name>/cluster -H 'Content-Type: application/json' -d '{"move_shard":{"shard_id":…,"from_peer_id":…,"to_peer_id":…}}' move a shard 9
curl -s -X DELETE <url>/cluster/peer/<peer_id> remove an empty peer from the Raft cluster 9
kubectl -n qdrant get pdb allowed disruptions 6
kubectl drain <knoten> --ignore-daemonsets --delete-emptydir-data --timeout=120s / kubectl uncordon <knoten> drain a node / lift the cordon 6
sudo /usr/local/bin/k3s-killall.sh simulate a hard node failure 6
kubectl taint nodes <knoten> node.kubernetes.io/out-of-service=nodeshutdown:NoExecute confirm that a node is down 6
sudo iptables -I INPUT -s <ip> -j DROP / sudo iptables -D INPUT -s <ip> -j DROP set a partition / remove exactly this rule 7

Performance and capacity

Command Purpose Day
~/werkbank/bin/python last-prozesse.py <url> <collection> <fragen.npy> <parallel> <anzahl> [ef] load generator with processes 8, 11
~/werkbank/bin/python glove-recall.py <url> glove <ef\|-> [ohne-rescore] recall@10 against the glove ground truth 8
kubectl -n qdrant top pods CPU and working set of the pods 8, 9
kubectl -n qdrant exec <pod> -c qdrant -- cat /sys/fs/cgroup/memory.current /sys/fs/cgroup/memory.max memory used and limit 9
kubectl -n qdrant exec <pod> -c qdrant -- grep -E '^(anon\|file\|active_file\|inactive_file) ' /sys/fs/cgroup/memory.stat anon and file pages 9
vmstat 5 2 waiting processes and reads on the node 9
sudo journalctl -k --since '-10 min' --grep 'Memory cgroup out of memory' --no-pager OOM messages from the kernel 9

Security

Command Purpose Day
openssl rand -hex -out <datei> 32 create a 256-bit key 10
kubectl -n qdrant create secret generic <name> --from-file=<key>=<datei> secret from files 10
curl -H "api-key: $(cat <datei>)" … call with a key without showing it 10
python3 jwt-erzeugen.py <schlüssel> <collection> r\|rw <minuten> > <token> issue a JWT 10
openssl x509 -in <crt> -noout -subject -issuer -enddate -ext subjectAltName inspect a certificate 10
wc -c <datei> count characters – reveals a newline 11
kubectl label --dry-run=server --overwrite ns <ns> pod-security.kubernetes.io/enforce=restricted check PSS violations in advance 10
ip route get <pod-ip> source address of a node towards a pod 10

Observability

Command Purpose Day
helm install monitoring oci://ghcr.io/prometheus-community/charts/kube-prometheus-stack --version 94.5.0 -n monitoring -f <werte> install monitoring 11
curl http://<prometheus>:9090/api/v1/targets -o ziele.json targets with state and lastError 11
curl …/api/v1/query --data-urlencode 'query=<promql>' PromQL at the current time 11
histogram_quantile(0.99, sum by (le) (rate(<histogramm>_bucket[1m]))) p99 from a histogram 11
(sum(rate(…{status=~"5.."}[5m])) or vector(0)) / sum(rate(…[5m])) error ratio, a number even without errors 11
curl …/api/v1/alerts / curl http://<alertmanager>:9093/api/v2/alerts alerts in Prometheus / in Alertmanager 11
rate(container_cpu_cfs_throttled_periods_total[1m]) / rate(container_cpu_cfs_periods_total[1m]) share of throttled periods 16

Backup and restore

Command Purpose Day
curl … -X POST …/collections/<c>/shards/<id>/snapshots snapshot of a shard on the peer that holds it 12
curl …/collections/<c>/snapshots list snapshots (with S3: all in the bucket) 12
aws --profile <p> s3 presign s3://<bucket>/<key> --expires-in 900 pickup slip for 15 minutes 12
curl … -X PUT …/collections/<c>/snapshots/recover -d '{"location":"<url>"}' create a collection from a snapshot 12, 16
curl … -X PUT …/collections/<c>/shards/<id>/snapshots/recover -d '{"location":"<url>"}' restore a shard into an existing collection 12
aws --profile <p> s3 ls --recursive --human-readable --summarize s3://<bucket>/ content with sizes and total 12
aws --no-sign-request --endpoint-url <url> s3 ls s3://<bucket>/ check anonymous access 12
ss -ltnp listening ports with process 12

pgvector and Milvus

Command Purpose Day
kubectl -n <ns> exec <pod> -c postgres -- psql <db> -c "<sql>" SQL in the PostgreSQL pod 13
CREATE INDEX … USING hnsw (embedding vector_cosine_ops) WITH (m = …, ef_construction = …) HNSW index for cosine 13
SET hnsw.ef_search = … / SET hnsw.iterative_scan = relaxed_order search width / keep searching with filters 13
EXPLAIN (ANALYZE, COSTS OFF) <abfrage> query plan with real timings 13
helm template … --set cluster.enabled=true > <datei> render manifests without installing 14
load_collection, get_load_state (pymilvus) load a collection, load state 14
query(…, output_fields=["count(*)"], consistency_level="Strong") count live rows 14

GitOps

Command Purpose Day
argocd login --core --kube-context argocd CLI in core mode 15
argocd app get <app> --refresh fetch state and new commit immediately 15
argocd app diff <app> difference Git ↔︎ cluster 15
argocd app sync <app> [--resource g:k:n] [--replace] apply, single resource, replace 15
argocd app wait <app> --sync --health --timeout <s> wait until applied and healthy 15
argocd app history <app> which commit was applied when 16
git revert --no-edit <commit> take back a plan change 15, 16
kubectl get <obj> --show-managed-fields -o jsonpath=… who set which fields 15

Contents

More