Skip to content
RAG infrastructure on Kubernetes · Chapter 18 of 20 Appendix A: Cheat sheet

Appendix A: Cheat sheet

What this appendix is for: looking things up when you know what you want to do but have forgotten the syntax. It explains nothing new. Every command appears in the course; the “Day” column leads to the chapters where it appears with all its options and a real output.

Three shorthands apply throughout:

  • …:6333 stands for Qdrant: on Days 4 to 8 mostly http://127.0.0.1:6333 via port-forward, from Day 9 http://qdrant.rag:6333 from the helper pod curl.
  • From Day 14 every call to Qdrant needs -K /schluessel/lesen.conf (read) or -K /schluessel/voll.conf (write) – and the pod needs the label qdrant-zugang=ja.
  • kubectl -n rag exec -i curl -- curl … -d @- < datei.json sends a file from rag1 to a service in the cluster. The tables say curl … -d @datei for short.

The site

Command What for Day
ssh-keygen -t ed25519 -f ~/.ssh/rag -C rag-labor create a key pair for the VMs 0
ssh-copy-id -i ~/.ssh/rag.pub ubuntu@<ip> copy the public key to a VM 0
sudo hostnamectl set-hostname rag1 set the host name 0
getent hosts rag2 resolve a name through the system 0
ARCH=$(dpkg --print-architecture) remember the architecture for downloads 0
sha256sum -c <file> compare the checksum of a download 0
sudo INSTALL_K3S_VERSION=… sh install-k3s.sh install k3s; INSTALL_K3S_EXEC=agent for rag2 0
kubectl get nodes -o wide nodes with IP and version 0
free -m · nproc memory in MB, number of cores 0, 10
sudo systemctl enable --now ollama · disable --now start a service, or stop it and remove autostart 0, 3

Models with Ollama

Command What for Day
ollama pull <model> download a model 0
ollama list · ollama ps available or loaded models with memory and context 0, 2
ollama show <model> size, context, defaults 2, 9
kubectl -n rag exec deploy/embed -- ollama pull <model> load a model into the embedding service 3, 13
kubectl -n rag exec deployment/llm -- ollama pull qwen3:1.7b load the language model into its volume 9
curl -s …:11434/api/embed -d @anfrage.json -o embed.json request embeddings 0, 1, 6
curl -s …:11434/api/generate -d @anfrage.json -o antwort.json generate an answer from a prompt 1
kubectl -n rag logs deployment/llm \| grep "eval time" the model’s reading and writing time 9

JSON with jq

Command What for Day
jq . · jq -c … · jq -r … show everything · one line · text without quotes 1, 16
jq -n --rawfile v datei '{…}' > anfrage.json build a request from text files 1
jq '[.embeddings[] \| length]' embed.json length of each vector 0, 1
jq -n --slurpfile k … --slurpfile f … '…transpose…' similarity question ↔︎ cards by hand 1
jq '.model = "…"' alt.json > neu.json replace a field 2
jq '.input \|= map("präfix " + .)' prepend something to every list element 2
jq -c '.result.points[] \| [.score, .payload.quelle, .payload.abschnitt]' one line per hit 8

Everyday Kubernetes

Command What for Day
kubectl apply -f <file> apply a manifest 3
kubectl diff -f <file> what an apply would change; exit code 1 = differences 16
kubectl -n rag rollout status deployment/<name> wait for a rollout 3
kubectl -n rag rollout restart deployment/<name> restart pods, e.g. after a changed ConfigMap 3, 9, 13
kubectl -n rag scale deployment <name> --replicas=<n> set replicas, including 0 9, 10
kubectl -n rag set env deployment/<name> --list show environment variables 13
kubectl -n rag get pods -o wide --field-selector=status.phase=Running running pods with their node 11, 15
kubectl -n rag get pods -l <label> -L <key> filter by label, label as a column 14
kubectl label pod <name> <key>=<value> · <key>- set or remove a label 14
kubectl -n rag describe pod <name> events, Last State, volumes 10, 12
kubectl describe node <node> committed requests, taints, conditions 9, 11
kubectl -n rag get events --field-selector reason=… filter events 11
kubectl -n rag logs <pod> --since=60s log of the last minute 15
kubectl -n rag logs -l <label> --prefix --tail=-1 logs of all matching pods with pod names 15, 16
kubectl -n rag exec <pod> -- <command> run a command in a pod 3
kubectl cp rag/curl:/tmp/e.json kalt.json fetch a file from a pod 3
kubectl run -n rag curl --image=… --overrides='…' --command -- sleep infinity helper pod on a specific node 3, 7
kubectl top pod -n rag · kubectl top node CPU and memory 3, 10
kubectl -n rag delete pod <name> --force --grace-period=0 remove a pod object immediately (careful) 11
kubectl -n rag get endpointslices -l kubernetes.io/service-name=<svc> which pods are behind a service 10
kubectl -n rag get hpa <name> target and current value of the HPA 10

ConfigMaps, jobs and secrets

Command What for Day
kubectl -n rag create configmap <name> --from-file=<file or folder/> files as a ConfigMap 6, 15
kubectl -n rag delete configmap <name> remove a ConfigMap to recreate it 6
kubectl -n rag wait --for=condition=Complete job/<name> --timeout=300s wait for a job to finish 6
kubectl -n rag wait --for=condition=Failed job/<name> wait for a job to fail 8, 14
kubectl -n rag logs job/<name> report of a job (ingest, test bench, load) 6, 7, 10
kubectl -n rag delete job <name> --ignore-not-found remove a job to start it again 6, 13
openssl rand -hex <n> random value for a key 14
kubectl create secret generic <name> --from-env-file=<file> secret from name=value lines 14
kubectl exec <pod> -- env environment of a pod – secrets included, in plain text 14

Qdrant

Command What for Day
helm install qdrant qdrant/qdrant --version 1.20.3 -n rag -f qdrant-werte.yaml install Qdrant 4
helm upgrade qdrant qdrant/qdrant --version 1.20.3 -n rag -f <values> roll out new values, e.g. two peers 11
helm upgrade … --reuse-values -f schluessel-werte.yaml add keys, keep the previous values 14
curl -X PUT …:6333/collections/<name> -d '{"vectors":{…}}' create a collection (shard_number, replication_factor, metadata) 4, 13
curl …:6333/collections · …/collections/<name> list collections · state of one collection 4, 7
curl -X PUT '…/points?wait=true' -d @punkte.json store points 4
curl -X POST …/points/query -d @suche.json search (query, limit, filter, using, prefetch) 4, 8
curl -X POST …/points/scroll -d '{"filter":…}' page through points with a filter 6, 13
curl -X POST …/collections/<name>/facet -d '{"key":…}' count points per payload value 13
curl -X PUT …/collections/<name>/index -d '{"field_name":…}' create a payload or full-text index 6, 8, 14
curl -X POST '…/points/payload?wait=true' set payload fields 11, 14
curl -X POST …/points/delete -d '{"filter":…}' delete cards by filter (full key) 14
curl -X PATCH …/collections/<name> -d '{"params":…}' · '{"metadata":…}' change settings or metadata 11, 13
curl …:6333/cluster · …/collections/<name>/cluster peers, leader, shards 11
curl -X POST …/collections/<name>/cluster -d '{"replicate_shard":{…}}' copy a shard to another peer 11
curl -X POST '…/collections/<name>/snapshots?wait=true' create a snapshot 12
curl …/collections/<name>/snapshots/<file> > <file> download a snapshot 12
curl -X POST '…/snapshots/upload?priority=snapshot&wait=true' -F 'snapshot=@-;filename=…' upload a snapshot and restore the collection 12
curl -X POST …:6333/collections/aliases -d @umhaengen.json create, delete, move a sign – atomically 13, 16
curl …:6333/aliases which collection each sign points to 13, 16

PostgreSQL with pgvector

Command What for Day
helm install cnpg cnpg/cloudnative-pg -n cnpg-system --create-namespace --version 0.29.2 install the operator 5
kubectl -n rag wait --for=condition=Ready cluster/pg wait for the cluster 5, 12
kubectl -n rag exec pg-1 -c postgres -- psql -d rag -c "<sql>" run SQL in the pod 5
kubectl -n rag exec -i pg-1 -c postgres -- psql -d rag < datei.sql run an SQL file 5
CREATE EXTENSION vector; turn on pgvector 5
… ORDER BY embedding <=> v LIMIT 3 nearest neighbours by cosine distance 5
CREATE INDEX … USING hnsw (embedding vector_cosine_ops) HNSW index 5
EXPLAIN (ANALYZE, COSTS OFF) … query plan with real times 5
pg_dump -Fc -d rag · pg_restore --list back up · contents of a backup 12
pg_restore -d rag -t <table> · --section=post-data table with rows · keys and indexes 12
GRANT SELECT ON karten TO leser; · psql -c '\dp karten' grant and check read access 14
pg_isready -h <host> does the server accept connections? 14

Answer service and measuring

Command What for Day
curl -s -X POST http://antwort.rag/frage -H 'Content-Type: application/json' -d @frage.json ask the answer service 9
curl -sN … streamed answer line by line 9
curl -s -o /dev/null -w '%{http_code} %{time_total}\n' -m <s> <url> measure status and duration 3, 9, 10
time kubectl -n rag delete pod <name> measure how long shutting down takes 9
kubectl -n rag exec deployment/antwort -- grep -E '^(SigIgn\|SigCgt)' /proc/1/status which signals process 1 catches 9
kubectl -n rag exec deploy/embed -- cat /sys/fs/cgroup/cpu.stat CPU throttling of a pod 3
kubectl -n rag logs besucher \| grep -c ' 200$' · grep -v ' 200$' count answers with 200 · show all others 15, 16
date -u +%T note the time for RPO, RTO and reports 12, 16

Prometheus and PromQL

Command What for Day
curl -K /schluessel/lesen.conf …:6333/metrics Qdrant’s metrics 15
curl …:9090/api/v1/targets targets with state and error 15
curl …:9090/api/v1/query --data-urlencode query@- < datei.promql PromQL query from a file 15, 16
curl …:9090/api/v1/rules · …/api/v1/alerts rules and alerts with state 15, 16
curl -X POST …:9090/-/reload reload the configuration 15, 16
rate(x_total[5m]) · increase(x_total[10m]) increase per second · in the window 15
sum by (label) (…) add up over pods, split by label 15
histogram_quantile(0.95, sum by (le) (rate(x_bucket[5m]))) 95th percentile 15
max_over_time(<expression>[2h:1m]) evaluate a rule expression retroactively for every minute 16

Nodes, failure and network

Command What for Day
sudo systemctl stop k3s-agent · sudo /usr/local/bin/k3s-killall.sh let node rag2 fail 11
kubectl wait --for=condition=Ready=Unknown node/<node> wait until a node counts as failed 11
kubectl describe pv <name> which node a volume lives on 11
systemctl cat <unit> show a unit file 11
kubectl get networkpolicy -A all fences 14
sudo iptables -t filter -L <chain> -v -n rules of a chain with counters 10
helm uninstall <release> -n <ns> · kubectl delete namespace <ns> remove a test environment 12

Contents

More