Day 2: Qdrant with Helm – the first branch
Goal: install Qdrant with the official Helm chart as a StatefulSet on a data node, set values deliberately (version, node, resources, storage, probes, telemetry), load the corpus from Day 1 as a collection, compare hits with exact search and prove that the data survives a pod restart · Duration: about 120 min · Prerequisite: Day 0 and Day 1
State before this chapter
From Day 1, the corpus and vectors are in
~/labor/tag01.
# on vdb1
ls -lh ~/labor/tag01/korpus.jsonl ~/labor/tag01/vektoren.npyExpected (date and time will differ):
-rw-rw-r-- 1 ubuntu ubuntu 11M Dec 4 17:22 /home/ubuntu/labor/tag01/korpus.jsonl
-rw-rw-r-- 1 ubuntu ubuntu 39M Dec 4 17:18 /home/ubuntu/labor/tag01/vektoren.npy
So far, Helm only knows the Longhorn repository:
# on vdb1
helm repo listExpected:
NAME URL
longhorn https://charts.longhorn.io
Introduction
Yesterday you rebuilt in numpy what a vector database computes. Today the library gets its first branch: Qdrant runs as a pod on one of the data nodes, stores its data on a Longhorn volume and answers search requests over HTTP.
Qdrant is a vector database written in Rust under the Apache license. For every vector it stores a payload (the index card), searches with an HNSW index and can distribute itself across several nodes. There is an official Helm chart for Kubernetes. A chart is convenient, but also dangerous: its default values are intended for a quick demo, not for operations. You therefore first read the default values and then set every value that matters for operations yourself.
Today you will learn:
- to install a Helm chart with a fixed version and read its default values,
- to mark data nodes with a label and place Qdrant there,
- to choose requests, limits, volume size and StorageClass for a database deliberately,
- to distinguish the three probes of a database pod,
- to create a collection, load 13,220 points with payload and search in it,
- to recognize when Qdrant is not (yet) using an index at all,
- to prove that data survives a pod restart – by the data, not by the pod.
Background
The picture of the day: the first branch opens
A branch needs a building, shelves and an accession register. In Kubernetes:
- The building is the pod on a data node. It has a
fixed name,
qdrant-0, and keeps it even after a restart. The StatefulSet takes care of that – unlike a Deployment, whose pods get random names. - The shelves stand in the closed stacks: a Longhorn volume that belongs to the pod and outlives it.
- In Qdrant, the holdings are called a collection. Every book in it is a point: an ID, a vector and an index card (payload).
- The books don’t stand on a single shelf but on several book trolleys – the segments. New books go onto a trolley; at night the optimizer rearranges and builds signposts (the HNSW index) for large trolleys.
- The probes are the supervision: is the building unlocked at all (startup)? Is anyone still alive inside (liveness)? May readers be let in (readiness)?
The terms
| Term | Meaning | In the picture |
|---|---|---|
| Helm chart | package of Kubernetes templates with configurable values | building plan for a branch |
| Values | settings with which Helm fills the templates | equipment list |
| StatefulSet | controller for pods with a fixed name and their own volume | branch with a fixed house number |
| headless Service | Service without a cluster IP, returns the addresses of individual pods | address book of the branches |
| Collection | named holdings with a fixed dimension and a fixed distance measure | holdings of a department |
| Point | ID + vector + payload | book with an index card |
| Payload | JSON data for a point, filterable | index card |
| Segment | part of a collection with its own files and possibly its own index | book trolley |
| Optimizer | background process that merges and indexes segments | rearranging at night |
indexing_threshold |
size in KB above which a segment gets an HNSW index | when signposts become worthwhile |
| Startup, liveness, readiness probe | kubelet checks for startup, signs of life and readiness | supervision at the door |
Remember: A database in a pod is only as durable as its volume. The StatefulSet gives the pod a fixed name and a fixed volume – that turns a container into a branch.
Why the default values are not enough
Without your own values, the Qdrant chart installs a pod without requests and limits, on any node, with a 10 GiB volume from the default StorageClass, without liveness and startup probes, and with telemetry to the vendor switched on. Each of these points is harmless for a demo and a risk in operations: without requests, the scheduler places the database on a full node. Without a limit, it can eat up the node. Without node selection, it ends up next to the embedding model in the headquarters.
Drill 1: The chart and its default values
Where you are: on vdb1.
What you have afterwards: the Qdrant repository in Helm and the chart’s default values as a file to read.
Step 1 – add the repository.
# on vdb1
helm repo add qdrant https://qdrant.github.io/qdrant-helmhelm repo add <name> <url> remembers a chart
repository under a short name.
Expected:
"qdrant" has been added to your repositories
Step 2 – check the version.
# on vdb1
helm search repo qdrant/qdrantExpected:
NAME CHART VERSION APP VERSION DESCRIPTION
qdrant/qdrant 1.20.3 v1.20.3 Qdrant - Vector Database for the next generatio...
What you see: CHART VERSION is the
version of the building plan, APP VERSION the version of
Qdrant in it. For this chart, both match. The course pins both –
helm search may already show a newer version for you.
Step 3 – save the default values.
# on vdb1
mkdir -p ~/labor/tag02# on vdb1
cd ~/labor/tag02# on vdb1
helm show values qdrant/qdrant --version 1.20.3 > qdrant-standard.yamlhelm show valuesprints the default values of a chart without installing anything.--version 1.20.3takes exactly this chart version.>writes the output to a file that you can read at your leisure.
Step 4 – look at the structure.
# on vdb1
grep -n -E '^[a-zA-Z]+:' qdrant-standard.yaml-nshows the line number so that you can jump straight there innano(withStrg+_).-E '^[a-zA-Z]+:'finds lines that begin with a key at the very left – the top level of the values.
Expected (excerpt – the keys you set or read today):
1:replicaCount: 1
3:image:
61:livenessProbe:
69:readinessProbe:
77:startupProbe:
91:resources: {}
99:containerSecurityContext:
124:nodeSelector: {}
145:persistence:
181:config:
259:podManagementPolicy: Parallel
261:podDisruptionBudget:
What you see: resources: {} and
nodeSelector: {} are empty – no requests, no fixed node.
podManagementPolicy: Parallel starts all pods at the same
time. That becomes important from Day 5 on, when several Qdrant nodes
must find each other at startup. Open the file with
nano qdrant-standard.yaml and read the sections
livenessProbe to startupProbe and
persistence; the comments in them explain a lot.
Remember: Read the default values first, then install. Whatever you don’t set yourself is decided by the chart author – for their use case, not yours.
Save your progress? Sign up for free
Drill 2: Marking data nodes
Where you are: on vdb1.
What you have afterwards: vdb2, vdb3 and vdb4 carry the label
vdb-rolle=daten.
Qdrant should run only in the branches, never in the headquarters. Instead of hard-coding a single node name, you give all data nodes a common label. That way the scheduler can choose between them, and from Day 5 on it distributes three Qdrant pods across them.
Step 1 – mark the three nodes.
# on vdb1
kubectl label node vdb2 vdb-rolle=daten# on vdb1
kubectl label node vdb3 vdb-rolle=daten# on vdb1
kubectl label node vdb4 vdb-rolle=datenkubectl label node <knoten> <schlüssel>=<wert>
attaches a label to the Node object.
Expected (one line per command):
node/vdb2 labeled
node/vdb3 labeled
node/vdb4 labeled
Step 2 – check.
# on vdb1
kubectl get nodes -L vdb-rolle-L <schlüssel> shows the value of this label as a
separate column.
Expected:
NAME STATUS ROLES AGE VERSION VDB-ROLLE
vdb1 Ready control-plane 100m v1.37.3+k3s1
vdb2 Ready <none> 99m v1.37.3+k3s1 daten
vdb3 Ready <none> 99m v1.37.3+k3s1 daten
vdb4 Ready <none> 98m v1.37.3+k3s1 daten
Remember: Roles belong on the node as labels, not in the application as node names. Then you can replace a node without reconfiguring the database.
Save your progress? Sign up for free
Drill 3: Installing Qdrant
Where you are: on vdb1, in
~/labor/tag02.What you have afterwards: Qdrant 1.20.3 as a StatefulSet with one pod on a data node and a 2 GiB volume from Longhorn.
Step 1 – write your own values.
# on vdb1
nano qdrant-werte.yamlimage:
tag: v1.20.3
replicaCount: 1
nodeSelector:
vdb-rolle: daten
resources:
requests:
cpu: 500m
memory: 1Gi
limits:
memory: 2Gi
persistence:
size: 2Gi
storageClassName: longhorn
startupProbe:
enabled: true
livenessProbe:
enabled: true| Value | Setting | Why |
|---|---|---|
image.tag |
v1.20.3 |
fixed version instead of “whatever the chart currently ships” – a
helm repo update must not silently update the database |
replicaCount |
1 |
one branch today; three from Day 5 on |
nodeSelector |
vdb-rolle: daten |
only on vdb2–vdb4 |
requests.cpu |
500m |
half a CPU firmly reserved; the scheduler plans with it |
requests.memory |
1Gi |
the node must have this much memory free |
limits.memory |
2Gi |
above this, the kernel terminates the process (OOM). No CPU limit: throttled CPU makes searches slow without anything visibly going wrong |
persistence.size |
2Gi |
deliberately small – on Day 3 it fills up, and you expand it |
persistence.storageClassName |
longhorn |
explicitly, instead of relying on the default class |
startupProbe.enabled |
true |
gives Qdrant up to 30 × 5 s to load the data before the liveness probe takes effect |
livenessProbe.enabled |
true |
restarts a hanging process |
The readiness probe is already switched on in the chart.
config.cluster.enabled is set to true in the
chart by default: even a single Qdrant pod thus runs in distributed
mode, as a cluster with only one member. That is intentional – on Day 5
further members join without you having to switch modes.
Step 2 – install.
# on vdb1
helm install qdrant qdrant/qdrant --version 1.20.3 --namespace qdrant --create-namespace --values qdrant-werte.yaml| Setting | Value | Meaning |
|---|---|---|
| first argument | qdrant |
name of the release; also the prefix of the generated objects |
| second argument | qdrant/qdrant |
repository/chart |
--version |
1.20.3 |
chart version |
--namespace |
qdrant |
target namespace |
--create-namespace |
create the namespace if it is missing | |
--values |
qdrant-werte.yaml |
your values; they override the default values |
Expected (excerpt – you don’t need the
port-forward notes that follow):
NAME: qdrant
LAST DEPLOYED: Fri Dec 4 17:27:13 2026
NAMESPACE: qdrant
STATUS: deployed
REVISION: 1
DESCRIPTION: Install complete
NOTES:
Qdrant v1.20.3 has been deployed successfully.
Step 3 – wait until the pod is ready.
# on vdb1
kubectl -n qdrant rollout status statefulset/qdrant --timeout=300srollout status waits until all pods of the StatefulSet
are ready, at most for --timeout.
Expected:
Waiting for 1 pods to be ready...
partitioned roll out complete: 1 new pods have been updated...
Step 4 – look at what has been created.
# on vdb1
kubectl -n qdrant get statefulset,pod,service,pvc -o wideExpected (columns truncated on the right):
NAME READY AGE CONTAINERS IMAGES
statefulset.apps/qdrant 1/1 55s qdrant docker.io/qdrant/qdrant:v1.20.3
NAME READY STATUS RESTARTS AGE IP NODE
pod/qdrant-0 1/1 Running 0 54s 10.42.1.17 vdb2
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)
service/qdrant ClusterIP 10.43.151.237 <none> 6333/TCP,6334/TCP,6335/TCP
service/qdrant-headless ClusterIP None <none> 6333/TCP,6334/TCP,6335/TCP
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS
persistentvolumeclaim/qdrant-storage-qdrant-0 Bound pvc-c6c96e89-073d-4b27-baae-13ed36b72ef8 2Gi RWO longhorn
What you see:
| Object | Value | Meaning |
|---|---|---|
Pod qdrant-0 |
on vdb2 |
name with a number instead of a random suffix; the scheduler has chosen a data node |
Service qdrant |
10.43.151.237 |
one address for requests – yours is different |
Service qdrant-headless |
CLUSTER-IP None |
hands out the addresses of the individual pods; from Day 5 on, the Qdrant nodes find each other through it |
| Ports | 6333, 6334, 6335 | REST, gRPC and the internal connection between Qdrant nodes (p2p) |
PVC qdrant-storage-qdrant-0 |
Bound, 2Gi, longhorn |
volume from the StatefulSet’s template, bound to
qdrant-0 |
Step 5 – look at the volume in the closed stacks.
# on vdb1
kubectl -n longhorn-system get replicas.longhorn.ioExpected (excerpt – only the lines with the volume from step 4, columns truncated on the right):
NAME DATA ENGINE STATE NODE
pvc-c6c96e89-073d-4b27-baae-13ed36b72ef8-r-bad787c4 v1 running vdb2
pvc-c6c96e89-073d-4b27-baae-13ed36b72ef8-r-bbb265c3 v1 running vdb1
pvc-c6c96e89-073d-4b27-baae-13ed36b72ef8-r-e8af35e7 v1 running vdb4
What you see: Longhorn keeps the volume three times, on vdb2, vdb1 and vdb4. That is the first level of fault tolerance: if the disk of one copy fails, the data is still there twice. A second level – second copies in Qdrant itself – comes on Day 5. On Day 3 you calculate what both levels together cost in space.
Remember:
helm installwith--versionand your own values file is repeatable. A name with a number and a PVC with the same name show you the StatefulSet at a glance.
Save your progress? Sign up for free
Drill 4: Checking probes and limits on the running pod
Where you are: on vdb1.
What you have afterwards: certainty that your values have arrived in the pod.
A values file is a wish. What applies is in the pod. You therefore read what Kubernetes has made of it.
Step 1 – the readiness probe.
# on vdb1
kubectl -n qdrant get pod qdrant-0 -o jsonpath='{.spec.containers[0].readinessProbe}'-o jsonpath='{…}' prints only the specified field of the
object; containers[0] is the first container in the
pod.
Expected:
{"failureThreshold":6,"httpGet":{"path":"/readyz","port":6333,"scheme":"HTTP"},"initialDelaySeconds":5,"periodSeconds":5,"successThreshold":1,"timeoutSeconds":1}
Step 2 – startup and liveness probe.
# on vdb1
kubectl -n qdrant get pod qdrant-0 -o jsonpath='{.spec.containers[0].startupProbe}'Expected:
{"failureThreshold":30,"httpGet":{"path":"/","port":6333,"scheme":"HTTP"},"initialDelaySeconds":10,"periodSeconds":5,"successThreshold":1,"timeoutSeconds":1}
# on vdb1
kubectl -n qdrant get pod qdrant-0 -o jsonpath='{.spec.containers[0].livenessProbe}'Expected:
{"failureThreshold":6,"httpGet":{"path":"/","port":6333,"scheme":"HTTP"},"initialDelaySeconds":5,"periodSeconds":5,"successThreshold":1,"timeoutSeconds":1}
What you see:
| Probe | Path | Takes effect after | Consequence on failure |
|---|---|---|---|
| Startup | / |
at most 10 s + 30 × 5 s = 160 s | container is restarted |
| Liveness | / |
6 × 5 s = 30 s without a response | container is restarted |
| Readiness | /readyz |
6 × 5 s = 30 s | pod no longer receives requests via the service |
/ answers as soon as the process speaks HTTP.
/readyz answers only once all shards are loaded. The
startup probe protects against a vicious circle: if Qdrant with a lot of
data needs two minutes to load, the liveness probe alone would restart
the container after 30 seconds – again and again. As long as the startup
probe is running, the liveness probe is suspended.
Step 3 – resources and security context.
# on vdb1
kubectl -n qdrant get pod qdrant-0 -o jsonpath='{.spec.containers[0].resources}'Expected:
{"limits":{"memory":"2Gi"},"requests":{"cpu":"500m","memory":"1Gi"}}
# on vdb1
kubectl -n qdrant get pod qdrant-0 -o jsonpath='{.spec.containers[0].securityContext}'Expected:
{"allowPrivilegeEscalation":false,"privileged":false,"readOnlyRootFilesystem":true,"runAsGroup":2000,"runAsNonRoot":true,"runAsUser":1000}
What you see: The chart runs Qdrant as user 1000 without root privileges and with a read-only file system. The process may only write to the volume. The chart already brings this along; on Day 10 you check it against the Pod Security Standards.
Remember: Liveness checks “is it alive?”, readiness “may it receive requests?”, startup “has it finished starting up yet?”. A database without a startup probe can drive itself into a restart loop with the liveness probe.
Save your progress? Sign up for free
Drill 5: Reading the log and switching off telemetry
Where you are: on vdb1, in
~/labor/tag02.What you have afterwards: a Qdrant that doesn’t send usage data to the vendor, and your first change via
helm upgrade.
Step 1 – read the log at startup.
# on vdb1
kubectl -n qdrant logs qdrant-0 --tail=25--tail=25 shows the last 25 lines. The message
“Defaulted container …” only says that kubectl has chosen
the main container and not the init container that sets the permissions
on the volume beforehand.
Expected (excerpt, timestamps shortened):
Version: 1.20.3, build: 0e7061a7
WARN qdrant::settings: Running in distributed mode without an API key. The internal (p2p) gRPC API is not authenticated, and `service.enforce_internal_auth` has no effect without `service.api_key`. Restrict the internal port to cluster nodes and configure an API key.
INFO storage::content_manager::consensus::persistent: Initializing new raft state at ./storage/raft_state.json
INFO storage::content_manager::consensus_manager: Consensus state machine initialized: peer_id=121400021250061, peers=0, collections=0
INFO qdrant: Telemetry reporting enabled, id: 13e3b35b-833c-4763-90f4-a55d17dce9a6
INFO qdrant::actix: Qdrant HTTP listening on 6333
INFO actix_server::server: starting service: "actix-web-service-0.0.0.0:6333", workers: 7, listening on: 0.0.0.0:6333
INFO qdrant::tonic: Qdrant gRPC listening on 6334
What you see:
| Line | Meaning |
|---|---|
WARN … without an API key |
anyone who can reach the pod on the network may do anything. You fix that on Day 10 with an API key and a NetworkPolicy |
Initializing new raft state |
first start: Qdrant creates its consensus state anew, in the volume |
peer_id=121400021250061 |
the identifier of this Qdrant node in the cluster |
Telemetry reporting enabled |
Qdrant sends anonymous usage data to the vendor |
workers: 7 |
this many HTTP worker threads Qdrant has started, depending on the node’s CPUs |
Telemetry is anonymous, but a database server in a closed network
should not phone home – that is a question of data protection and
firewall rules. Qdrant has the setting telemetry_disabled
for this.
Step 2 – extend the values.
# on vdb1
nano qdrant-werte.yamlimage:
tag: v1.20.3
replicaCount: 1
nodeSelector:
vdb-rolle: daten
resources:
requests:
cpu: 500m
memory: 1Gi
limits:
memory: 2Gi
persistence:
size: 2Gi
storageClassName: longhorn
startupProbe:
enabled: true
livenessProbe:
enabled: true
config:
telemetry_disabled: trueUnder config is everything the chart writes into
Qdrant’s configuration file. Helm merges your values with the default
values: config.cluster from the chart is kept, only
telemetry_disabled is added.
Step 3 – update the release.
# on vdb1
helm upgrade qdrant qdrant/qdrant --version 1.20.3 --namespace qdrant --values qdrant-werte.yamlhelm upgrade takes the same settings as
install and renders everything anew. Because the
configuration changes, the StatefulSet restarts the pod.
Expected (excerpt):
Release "qdrant" has been upgraded. Happy Helming!
NAME: qdrant
LAST DEPLOYED: Fri Dec 4 17:28:27 2026
NAMESPACE: qdrant
STATUS: deployed
REVISION: 2
DESCRIPTION: Upgrade complete
# on vdb1
kubectl -n qdrant rollout status statefulset/qdrant --timeout=300sExpected:
Waiting for partitioned roll out to finish: 0 out of 1 new pods have been updated...
Waiting for 1 pods to be ready...
Waiting for 1 pods to be ready...
Waiting for 1 pods to be ready...
partitioned roll out complete: 1 new pods have been updated...
Step 4 – read the log again.
# on vdb1
kubectl -n qdrant logs qdrant-0Expected (excerpt – look for the lines with
raft and Telemetry):
INFO storage::content_manager::consensus::persistent: Loading raft state from ./storage/raft_state.json
INFO storage::content_manager::consensus_manager: Consensus state machine initialized: peer_id=121400021250061, peers=1, collections=0
INFO qdrant: Telemetry reporting disabled
What you see: Two things. Telemetry is off. And:
Loading raft state instead of Initializing –
with the same peer_id as before. The new pod has received
the old pod’s volume and found its state in it again.
Step 5 – read what Helm has applied.
# on vdb1
helm get values qdrant -n qdrantExpected:
USER-SUPPLIED VALUES:
config:
telemetry_disabled: true
image:
tag: v1.20.3
livenessProbe:
enabled: true
nodeSelector:
vdb-rolle: daten
persistence:
size: 2Gi
storageClassName: longhorn
replicaCount: 1
resources:
limits:
memory: 2Gi
requests:
cpu: 500m
memory: 1Gi
startupProbe:
enabled: true
What you see: Exactly your values, sorted alphabetically. If something different from your file appears here, someone has updated the release with other values – from Day 15 on, GitOps prevents that.
Remember: Every change to the database goes through the values file and
helm upgrade, never throughkubectl edit. Then the file is the truth, andhelm get valuesproves it.
Save your progress? Sign up for free
Drill 6: Talking to Qdrant
Where you are: on vdb1, in
~/labor/tag02.What you have afterwards: responses from Qdrant’s REST API via the cluster IP.
As with Ollama, you reach Qdrant from vdb1 via the cluster IP of the service. Insert your address from Drill 3 in all commands.
Step 1 – query the version.
# on vdb1
curl -s http://10.43.151.237:6333/-s suppresses curl’s progress display.
Expected:
{"title":"qdrant - vector search engine","version":"1.20.3","commit":"0e7061a7ad2e0660ca7507ad154eb2e95e6f51c6"}
Step 2 – query readiness.
# on vdb1
curl -s http://10.43.151.237:6333/readyzExpected:
all shards are ready
What you see: This is the path the readiness probe
queries. You can call it yourself if a pod does not become
Ready.
Step 3 – query the cluster state.
# on vdb1
curl -s http://10.43.151.237:6333/cluster -o cluster.json-o cluster.json saves the response to a file instead of
printing it.
# on vdb1
jq '.result | {status, peer_id, raft_info}' cluster.jsonjq selects only the three named fields from the
result field.
Expected:
{
"status": "enabled",
"peer_id": 121400021250061,
"raft_info": {
"term": 3,
"commit": 10,
"pending_operations": 0,
"leader": 121400021250061,
"role": "Leader",
"is_voter": true
}
}
What you see: The library council has one member,
and it is also the chair (Leader). term counts
how often the council has held a new election – once at every restart.
On Day 5 two members join, on Day 7 the council loses its majority.
Step 4 – query the collections.
# on vdb1
curl -s http://10.43.151.237:6333/collectionsExpected:
{"result":{"collections":[]},"status":"ok","time":0.000022849}
What you see: No holdings yet. time is
the processing time in the server in seconds.
Remember:
/says “the process is running”,/readyz“the data is loaded”,/cluster“this is what the council looks like”. These three queries are your first move when a branch seems odd.
Save your progress? Sign up for free
Drill 7: Creating and filling the collection
Where you are: on vdb1, in
~/labor/tag02.What you have afterwards: the collection
dokuwith 13,220 points, each with a vector and payload.
A collection has two properties that cannot be changed later: the dimension of the vectors and the distance measure. Both must match the model: 768 and cosine, as measured on Day 1.
Step 1 – create the collection.
# on vdb1
curl -s -X PUT http://10.43.151.237:6333/collections/doku -H 'Content-Type: application/json' -d '{"vectors": {"size": 768, "distance": "Cosine"}}'| Setting | Meaning |
|---|---|
-X PUT |
HTTP method PUT: create the resource under this path |
/collections/doku |
name of the collection |
-H 'Content-Type: application/json' |
the body is JSON |
-d '…' |
the body: size = dimension, distance =
distance measure |
Expected:
{"result":true,"status":"ok","time":0.651148937}
Step 2 – create the loading program.
# on vdb1
nano laden.py"""Lädt Bestand und Vektoren aus Tag 1 in eine Qdrant-Collection."""
import json
import sys
import time
import numpy as np
from qdrant_client import QdrantClient, models
QDRANT, COLLECTION = sys.argv[1], sys.argv[2] # z. B. http://10.43.151.237:6333 doku
eintraege = [json.loads(z) for z in open("../tag01/korpus.jsonl", encoding="utf-8")]
vektoren = np.load("../tag01/vektoren.npy")
if len(eintraege) != len(vektoren):
sys.exit(f"Abbruch: {len(eintraege)} Texte, aber {len(vektoren)} Vektoren")
punkte = (
models.PointStruct(
id=e["id"],
vector=v.tolist(),
payload={"bereich": e["bereich"], "pfad": e["pfad"], "titel": e["titel"], "text": e["text"]},
)
for e, v in zip(eintraege, vektoren)
)
client = QdrantClient(url=QDRANT, timeout=60)
beginn = time.time()
client.upload_points(collection_name=COLLECTION, points=punkte, batch_size=256, wait=True)
print(f"{len(eintraege)} Punkte in {time.time() - beginn:.1f} s geladen")| Part | Meaning |
|---|---|
| length check | aborts if texts and vectors don’t match – the lesson from the diagnosis task of Day 1 |
PointStruct(id=…, vector=…, payload=…) |
one point: the id from Day 1, the vector as a list, the
index card |
punkte = ( … for … ) |
a generator: the points are only created during upload, not all at once in memory |
upload_points(…, batch_size=256) |
sends the points in batches of 256 |
wait=True |
waits until Qdrant has confirmed each batch |
The program receives the address and the name of the collection as arguments. That way you can use it in the diagnosis task for a second collection.
Step 3 – load.
# on vdb1
~/werkbank/bin/python laden.py http://10.43.151.237:6333 dokuExpected:
13220 Punkte in 22.2 s geladen
What you see: 22 seconds for loading compared with 64 minutes for embedding. The database is not the bottleneck when filling.
Step 4 – query the state of the collection.
# on vdb1
curl -s http://10.43.151.237:6333/collections/doku -o doku.json# on vdb1
jq '.result | {status, optimizer_status, points_count, indexed_vectors_count, segments_count}' doku.jsonExpected:
{
"status": "green",
"optimizer_status": "ok",
"points_count": 13220,
"indexed_vectors_count": 0,
"segments_count": 4
}
What you see:
| Field | Value | Meaning |
|---|---|---|
status |
green |
everything finished; yellow would mean the optimizer is
still working |
points_count |
13220 | all points have arrived |
segments_count |
4 | Qdrant has distributed the points across four book trolleys |
indexed_vectors_count |
0 | not a single vector is in an HNSW index |
The last line is the most important finding of the day. Why no index? That is in the collection’s configuration.
Step 5 – find the indexing threshold.
# on vdb1
jq '.result.config.optimizer_config.indexing_threshold' doku.jsonExpected:
10000
# on vdb1
jq '.result.config.hnsw_config' doku.jsonExpected:
{
"m": 16,
"ef_construct": 100,
"full_scan_threshold": 10000,
"max_indexing_threads": 0,
"on_disk": false
}
What you see: A segment only gets an HNSW index once
its vectors occupy more than indexing_threshold = 10,000
KB. Do the math: 13,220 points on four segments are a good 3,300 per
segment, times 3 KiB is about 9,900 KB – just below the
threshold. So Qdrant searches every segment completely here, exactly
like your numpy program on Day 1. For a small corpus that is right: an
index would cost memory and hardly save time. m and
ef_construct are the index’s tuning knobs; you work with
them and the threshold on Day 4.
Remember:
points_countsays how many books are there;indexed_vectors_countsays how many of them can be reached via signposts. A small corpus has no signposts – Qdrant then walks along every shelf.
Save your progress? Sign up for free
Drill 8: Searching in Qdrant
Where you are: on vdb1, in
~/labor/tag02.What you have afterwards: the same question as on Day 1, this time answered by Qdrant.
Step 1 – create the search program.
# on vdb1
nano qsuche.py"""Sucht eine Frage in der Qdrant-Collection doku."""
import sys
import time
import requests
from qdrant_client import QdrantClient
QDRANT, OLLAMA, FRAGE = sys.argv[1], sys.argv[2], sys.argv[3]
antwort = requests.post(f"{OLLAMA}/api/embed",
json={"model": "nomic-embed-text", "input": "search_query: " + FRAGE},
timeout=60)
frage = antwort.json()["embeddings"][0]
client = QdrantClient(url=QDRANT, timeout=60)
beginn = time.perf_counter()
treffer = client.query_points(collection_name="doku", query=frage, limit=5,
with_payload=["pfad", "titel"]).points
dauer = (time.perf_counter() - beginn) * 1000
for t in treffer:
print(f"{t.score:.3f} {t.payload['pfad']} [{t.payload['titel']}] id={t.id}")
print(f"Antwort von Qdrant nach {dauer:.1f} ms")query_points(…, query=frage, limit=5)searches for the five nearest points to the question vector.with_payload=["pfad", "titel"]fetches only these two fields of the index card – not the whole text. Less payload means less data over the network.- This time the time covers the whole request: network, HTTP, search and payload.
Step 2 – ask.
# on vdb1
~/werkbank/bin/python qsuche.py http://10.43.151.237:6333 http://10.43.16.22:11434 "How do I make a persistent volume bigger?"Expected:
0.794 concepts/storage/storage-classes.md [Volume expansion] id=1776
0.794 concepts/storage/persistent-volumes.md [Expanding Persistent Volumes Claims] id=1702
0.768 tutorials/configuration/configure-persistent-volume-storage.md [Create a PersistentVolumeClaim] id=12940
0.743 reference/access-authn-authz/admission-controllers.md [PersistentVolumeClaimResize] id=2674
0.742 concepts/storage/persistent-volumes.md [] id=1743
Antwort von Qdrant nach 16.9 ms
What you see: The same five hits in the same order
with the same values as in the exact search on Day 1. That has to be so:
without an index, Qdrant searches exactly. With cosine,
score is the cosine itself – larger is more similar. The 17
ms include the trip over the network to vdb2 and back; the pure
comparison on Day 1 took 5.5 ms.
Remember: Before you trust an index, compare its hits with exact search. Today they match because no index exists yet – from Day 4 on, that can no longer be taken for granted.
Save your progress? Sign up for free
Drill 9: Does the data survive a restart?
Where you are: on vdb1.
What you have afterwards: proof that a new pod finds the holdings complete.
“The pod is running again” proves nothing about the data. The proof is the number of points after the restart.
Step 1 – note the time.
# on vdb1
date +%TExpected (your time):
17:30:33
Step 2 – delete the pod.
# on vdb1
kubectl -n qdrant delete pod qdrant-0Expected:
pod "qdrant-0" deleted from qdrant namespace
Step 3 – wait until the new pod is ready.
# on vdb1
kubectl -n qdrant wait --for=condition=Ready pod/qdrant-0 --timeout=300skubectl wait --for=condition=Ready returns as soon as
the pod reports the Ready condition – that is, it passes
the readiness probe.
Expected:
pod/qdrant-0 condition met
# on vdb1
date +%TExpected:
17:30:58
What you see: 25 seconds from deletion to “ready”. During this time the branch was closed – with one pod there is no fault tolerance.
Step 4 – where does the new pod run?
# on vdb1
kubectl -n qdrant get pod qdrant-0 -o wideExpected (columns truncated on the right):
NAME READY STATUS RESTARTS AGE IP NODE
qdrant-0 1/1 Running 0 20s 10.42.1.19 vdb2
What you see: Same name, new IP, same node. The
StatefulSet has created a new pod with the same name, and the PVC
qdrant-storage-qdrant-0 has bound it to the old volume
again.
Step 5 – count the points.
# on vdb1
curl -s -X POST http://10.43.151.237:6333/collections/doku/points/count -H 'Content-Type: application/json' -d '{"exact": true}'/points/count counts the points.
"exact": true really counts instead of returning an
estimate from the segment statistics.
Expected:
{"result":{"count":13220},"status":"ok","time":0.006677798}
Step 6 – read the new pod’s log.
# on vdb1
kubectl -n qdrant logs qdrant-0Expected (excerpt – look for the lines with
doku, timestamps shortened):
17:30:43.951 INFO storage::content_manager::consensus::persistent: Loading raft state from ./storage/raft_state.json
17:30:44.002 INFO storage::content_manager::toc: Loading collection: doku
17:30:46.351 INFO collection::shards::local_shard: Recovering shard ./storage/collections/doku/0: 0/1 (0%)
17:30:46.523 INFO collection::shards::local_shard: Recovered collection doku: 1/1 (100%)
What you see: Qdrant loads the collection from the volume and replays the accession register (WAL): whatever had been accepted but not yet written to the segments is added. Here this took a good two seconds. With large holdings it takes longer – that is what the startup probe is for.
Remember: Fault tolerance is proven by the data, not by the pod: compare the number of points before and after. A single pod survives a restart without data loss, but not without downtime.
Save your progress? Sign up for free
Diagnosis task: The collection that accepts nothing
For a test, a colleague creates a collection probe and
wants to load the same corpus into it. The loading program aborts:
qdrant_client.http.exceptions.UnexpectedResponse: Unexpected Response: 400 (Bad Request)
Raw response content:
b'{"status":{"error":"Wrong input: Vector dimension error: expected dim: 384, got 768"},"time":0.000590374}'
Find the cause and the way to fix it before you read on.
Solution, step by step. You reproduce the error.
Step 1 – create the collection the way your colleague did.
# on vdb1
curl -s -X PUT http://10.43.151.237:6333/collections/probe -H 'Content-Type: application/json' -d '{"vectors": {"size": 384, "distance": "Cosine"}}'Expected:
{"result":true,"status":"ok","time":0.739504827}
Qdrant accepts the collection – 384 is a valid dimension; many smaller models return exactly that many numbers.
Step 2 – load.
# on vdb1
~/werkbank/bin/python laden.py http://10.43.151.237:6333 probeExpected (the last lines):
raise UnexpectedResponse.for_response(response)
qdrant_client.http.exceptions.UnexpectedResponse: Unexpected Response: 400 (Bad Request)
Raw response content:
b'{"status":{"error":"Wrong input: Vector dimension error: expected dim: 384, got 768"},"time":0.000590374}'
Step 3 – read the collection’s configuration.
# on vdb1
curl -s http://10.43.151.237:6333/collections/probe -o probe.json# on vdb1
jq '.result.config.params.vectors' probe.jsonExpected:
{
"size": 384,
"distance": "Cosine"
}
The cause: The collection was created for 384 dimensions, nomic-embed-text returns 768. The dimension of a collection cannot be changed afterwards.
Step 4 – fix it. Delete the collection and recreate it with the right dimension. Here, in the test, deleting is enough:
# on vdb1
curl -s -X DELETE http://10.43.151.237:6333/collections/probeExpected:
{"result":true,"status":"ok","time":0.098336164}
# on vdb1
curl -s http://10.43.151.237:6333/collectionsExpected:
{"result":{"collections":[{"name":"doku"}]},"status":"ok","time":0.000012255}
What you see: Only doku is left. In
production, this error is usually the result of a model change: a new
model with a different dimension needs a new collection, never a rewrite
of the old one.
Remember: Dimension and distance measure are the contract between model and collection. Whoever swaps the model creates a new collection and re-embeds everything.
Checkpoint
# on vdb1
helm list -n qdrantExpected (column UPDATED
shortened):
NAME NAMESPACE REVISION STATUS CHART APP VERSION
qdrant qdrant 2 deployed qdrant-1.20.3 v1.20.3
# on vdb1
kubectl -n qdrant get pvcExpected: qdrant-storage-qdrant-0 with
Bound, 2Gi, longhorn.
# on vdb1
curl -s -X POST http://10.43.151.237:6333/collections/doku/points/count -H 'Content-Type: application/json' -d '{"exact": true}'Expected: "count":13220.
# on vdb1
kubectl -n longhorn-system get volumes.longhorn.ioExpected (columns shortened):
NAME DATA ENGINE STATE ROBUSTNESS SIZE NODE
pvc-1be489ab-3891-4c08-b4b4-b3d91dac36d9 v1 attached healthy 5368709120 vdb1
pvc-c6c96e89-073d-4b27-baae-13ed36b72ef8 v1 attached healthy 2147483648 vdb2
What you see: Two volumes: Ollama’s model volume (5
GiB, attached to vdb1) and the Qdrant volume (2 GiB, attached to vdb2),
both healthy.
Test yourself
- Why is
qdrant-0stillqdrant-0after deletion and notqdrant-7f9c…? - What happens if you leave out the startup probe and Qdrant needs three minutes to load after a restart?
indexed_vectors_countis 0. Is the search therefore wrong?- Why does the course set a memory limit but no CPU limit?
- A colleague changes
replicaCountwithkubectl scaleinstead of via the values file. What happens at the nexthelm upgrade? - How did you recognize twice today that a new pod got the old volume?
Answers:
- Because it is a StatefulSet: pods get the set’s name with a sequential number, and the replacement for a deleted pod gets the same number – and thus the same PVC.
- The liveness probe would strike after 5 + 6 × 5 = 35 seconds without a response and restart the container – in the middle of loading. This repeats; the pod never comes up (CrashLoopBackOff).
- No. Without an index, Qdrant searches exactly; the hits are the same as in the exact search on Day 1. Only with a large corpus would it become slow.
- An exceeded memory limit terminates the process immediately and visibly (OOMKilled). A CPU limit, on the other hand, throttles silently: searches become slower without an error appearing. The request still reserves CPU for scheduling.
- Helm 4 applies the objects server-side, and after
kubectl scalethe field.spec.replicasbelongs to the managerkubectl. If the values file sets the same value, nothing happens. If it sets a different one,helm upgradeaborts with a conflict (measured on Day 9); only--force-conflictstakes the field back. The values file remains the truth – but Helm doesn’t overwrite silently. - In the log after
helm upgrade:Loading raft statewith the samepeer_id. And after deleting the pod:count13,220 andRecovered collection doku.
Interview note
“Why a StatefulSet and not a Deployment for a database?” – A
StatefulSet gives every pod a fixed name, a fixed DNS address via the
headless service and its own PVC from a template. A replacement pod gets
exactly this PVC back. With a Deployment, all pods share the same PVC
specification, the names are random, and with several replicas an RWO
volume fails. For a distributed Qdrant there is an additional point: the
nodes find each other via the fixed names
qdrant-0.qdrant-headless.
Enterprise note
In production, the chart doesn’t come directly from the internet but
from your own registry, and the image is pinned by digest, not just by
tag. Data nodes additionally get a taint so that nothing other than the
database runs there. The volume size is based on a capacity calculation
(Day 9), with reserve for the optimizer and snapshots. And before the
first customer there is an API key – the WARN shown today
must not exist in production.
Summary
- Qdrant 1.20.3 runs via Helm as a StatefulSet with one pod on a data
node (
vdb-rolle=daten). - Your own values: fixed image version, requests and memory limit, 2 GiB Longhorn volume, startup and liveness probes, telemetry off.
- The collection
dokuhas 13,220 points with 768 dimensions, cosine and payload, loaded in 22 s. - Four segments, each just below the indexing threshold: Qdrant still searches exactly and delivers the same hits as on Day 1.
- After deleting the pod: same name, same volume, 13,220 points, 25 s of downtime.
- The dimension and distance measure of a collection cannot be changed.
Commands at a glance
| Command | Purpose |
|---|---|
helm repo add qdrant https://qdrant.github.io/qdrant-helm |
add the chart repository |
helm show values qdrant/qdrant --version 1.20.3 > qdrant-standard.yaml |
save the default values |
kubectl label node vdb2 vdb-rolle=daten |
mark a data node |
helm install qdrant qdrant/qdrant --version 1.20.3 -n qdrant --create-namespace --values qdrant-werte.yaml |
install Qdrant |
helm upgrade qdrant qdrant/qdrant --version 1.20.3 -n qdrant --values qdrant-werte.yaml |
change values |
helm get values qdrant -n qdrant |
show the applied values |
kubectl -n qdrant get pod qdrant-0 -o jsonpath='{.spec.containers[0].readinessProbe}' |
read the probe in the pod |
curl -s http://<ip>:6333/readyz |
check readiness |
curl -s http://<ip>:6333/cluster -o cluster.json |
query the state of the council |
curl -s -X PUT http://<ip>:6333/collections/doku -H 'Content-Type: application/json' -d '{…}' |
create a collection |
~/werkbank/bin/python laden.py <qdrant-url> doku |
load the corpus |
curl -s -X POST http://<ip>:6333/collections/doku/points/count -H 'Content-Type: application/json' -d '{"exact": true}' |
count points |
kubectl -n qdrant wait --for=condition=Ready pod/qdrant-0 --timeout=300s |
wait for readiness |
curl -s -X DELETE http://<ip>:6333/collections/probe |
delete a collection |