Skip to content
k0s and LINSTOR · Chapter 24 of 27 Day 22: Single-writer services that survive a node failure – Prometheus with RWO, HA Controller and fencing

Day 22: Single-writer services that survive a node failure – Prometheus with RWO, HA Controller and fencing

Goal: Prometheus survives the failure of its node on its own. It moves to another node and keeps all its samples. The old node can no longer write into the data in the meantime. · Duration: approx. 2½ hours · Prerequisite: Day 21 (HA Controller on), Day 10, Day 11

State before this chapter

You have worked through Day 21. The HA Controller and the NFS server are running. You removed Grafana and the writers in the Day 21 cleanup. Check this now with three short commands.

The HA Controller runs on all three workers. First you check that the HA Controller is running. It is a DaemonSet, so one pod per worker. Without it, Drill 3 does not work.

# on k0s-ctrl
kubectl -n piraeus-datastore get ds

Expected:

NAME                     DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
ha-controller            3         3         3       3            3           <none>          9m47s
linstor-csi-nfs-server   3         3         3       3            3           <none>          9m47s
linstor-csi-node         3         3         3       3            3           <none>          19h

What you see: The ha-controller line shows 3 three times: three pods wanted, three running. If ha-controller is missing from the list or shows DESIRED 0, work through Day 21, Drill 4.

No resource is faulty. Now you ask LINSTOR whether any volume has a problem. You want to start today with a healthy cluster.

# on k0s-ctrl
linstor --no-utf8 --no-color resource list --faulty

Expected: an empty table. Empty means: no volume is faulty.

No worker carries a taint. A taint is a marker on a node that keeps new pods away. You check that none is left. Otherwise Prometheus cannot move freely today.

# on k0s-ctrl
kubectl get nodes \
  -o custom-columns=NAME:.metadata.name,TAINTS:.spec.taints[*].key

Expected:

NAME     TAINTS
k0s-w1   <none>
k0s-w2   <none>
k0s-w3   <none>

What you see: <none> means: no taint on this worker. If drbd.linbit.com/lost-quorum from Day 21 is still there, wait until the HA Controller removes it. In the lab this took up to half an hour.

Introduction

What today is about

Imagine your monitoring runs on one of the workers. At three in the morning this server fails. Maybe the power supply broke, maybe the network cable came loose. From now on Prometheus collects no more samples. No alert arrives any more – exactly when you need it most.

Today’s goal: After such a failure Prometheus should keep running on another worker on its own. It should keep all samples from before and be back within a few minutes. And two Prometheus instances must never write into the same data at the same time.

Why this does not work like Grafana

On Day 21 you made Grafana highly available. Two Grafana pods share one volume over NFS. If one fails, the other keeps working.

That does not work with Prometheus. Prometheus stores its samples in its own time series database, the TSDB. The TSDB tolerates exactly one process that writes. Two Prometheus pods in the same directory destroy each other’s data. The Prometheus documentation also explicitly advises against NFS.

Such services are called single-writer services: only one may write. Most databases belong to this group, too.

What you build today

For a single-writer service one way remains: one instance whose data lives on two machines. If its machine fails, it restarts on the other one. There it finds its data. For this you need three building blocks. You already know all of them:

Building block what it does you know it from
a LINSTOR volume with two replicas (ReadWriteOnce) the samples live on k0s-w1 and k0s-w2; if one fails, they are still on the other Day 8
the HA Controller notices the failure within seconds and clears the old pod away; then Kubernetes may restart it Day 21
the DRBD quorum (fencing) halts the failed node in case it is still running; it can then no longer write Day 11

This is what the lab looks like today:

Node Role today
k0s-ctrl your workstation, you control everything from here
k0s-w1 Prometheus runs here, first replica of the data
k0s-w2 second replica of the data – Prometheus should move here
k0s-w3 no replica; fallback for other pods

The figure shows what happens today. At the top, normal operation: Prometheus writes on k0s-w1, DRBD mirrors every block to k0s-w2, and k0s-ctrl casts the third vote as the referee. At the bottom, the state after the failure in Drill 3: k0s-w1 is cut off, its writes are frozen, and Prometheus carries on on k0s-w2.

Single writer: Prometheus moves from k0s-w1 to k0s-w2, the old pen is frozen

The plan

  1. Drill 1 – you decide in which form Prometheus runs: as a Deployment with strategy: Recreate, not as a StatefulSet. The drill explains why.
  2. Drill 2 – you install Prometheus on a volume with two replicas. Then you note a time and ask Prometheus for the samples of exactly that time. After every failure you ask the same question again.
  3. Drill 3 – you cut k0s-w1 off the network. The node keeps running but is no longer reachable. That is the most dangerous case. You measure how long Prometheus needs until it runs again on k0s-w2. And you see that DRBD has frozen the old Prometheus on k0s-w1.
  4. Drill 4 – you bring k0s-w1 back. You check what happens to the old Prometheus’s last write attempts: they are discarded. The data on k0s-w2 stays intact.
  5. Drill 5 – the same failure without the HA Controller. This is a comparison – you can skip it. The waiting alone takes more than a quarter of an hour.

The result in the lab up front: with the HA Controller, Prometheus was running again after 2 minutes 16 seconds. Without it, it never came back on its own. It only ran again after one manual step, after almost 17 minutes in total. Both times all samples from before the failure were still there.

Today you learn:

  • to explain why Prometheus runs as a Deployment with strategy: Recreate and an RWO volume – not with two replicas and not over NFS,
  • to install Prometheus with Helm on linstor-replicated and query samples at a fixed time,
  • to show on the failed node that DRBD has frozen the old instance,
  • to measure a failure with the HA Controller and see what happens to the old node’s last write attempts when it comes back,
  • to measure the same failure without the HA Controller. Then Kubernetes does not release the volume until you confirm the failure with the out-of-service taint.

Background

The picture of the day: the ledger and the frozen pen

Picture a ledger. Prometheus writes every sample into its TSDB. In the same way a bookkeeper enters every receipt into the book. Only one bookkeeper ever writes into a ledger. If two write at the same time without knowing of each other, the book is worthless afterwards.

  • If the bookkeeper drops out, a stand-in takes over the book. That should be quick. But never while the old one might still be writing.
  • The referee (DRBD quorum) keeps watch. If the bookkeeper can no longer see the majority, the referee freezes his pen. Reading still works, writing does not.
  • Only once the pen is frozen may the stand-in open the book. This is called fencing: safely shutting down the old writer.
  • Sometimes someone tears the book out of the old bookkeeper’s hands without knowing whether he is still writing. That is called an unsafe detach. It only ends well if the pen is already frozen.

The terms

Term Meaning In the picture
Single-writer service whose data only one process may write at a time (Prometheus TSDB, most databases) one bookkeeper per ledger
ReadWriteOnce (RWO) volume attached to exactly one node at a time the book lies in one office
strategy: Recreate Deployment first stops the old pod, then starts the new one first the old one leaves, then the stand-in comes
StatefulSet pods with a fixed name (…-0); each name exists at most once name badge that exists only once
Fencing safely shutting down the old writer before a new one writes freezing the old bookkeeper’s pen
on-no-quorum suspend-io DRBD holds every write on a node without quorum pen frozen
Force detach (unsafe detach) releasing the volume from the old node without the old node agreeing tearing the book out of his hands

Remember: Freeze first, then hand over. A single-writer service may only write on a new node once the old one certainly can no longer write. Speed comes second.

Drill 1: Deployment or StatefulSet?

Where you are: on k0s-ctrl.

In this drill:

  • You create a folder for today.
  • You register the source for Prometheus with Helm.
  • You look up how the chart starts Prometheus.
  • You decide: Deployment instead of StatefulSet.

Step 1 – the directory for today. You create a folder. All of today’s files go there.

# on k0s-ctrl
mkdir -p ~/k0s-lab/tag22
  • -p also creates missing parent folders. If the folder already exists, that is not an error.

Now you change into the new folder. All further files are then created here.

# on k0s-ctrl
cd ~/k0s-lab/tag22

Step 2 – add the repository. The Prometheus charts live in a community repository of their own. A repository is a collection of charts, i.e. installation packages. You register it with Helm so that Helm knows it:

# on k0s-ctrl
helm repo add prometheus-community \
  https://prometheus-community.github.io/helm-charts

Expected:

"prometheus-community" has been added to your repositories

What you see: Helm now knows the repository under the name prometheus-community.

Now you download the repository’s index. Only then does Helm know which charts and versions exist.

# on k0s-ctrl
helm repo update prometheus-community
  • With the name at the end, helm repo update refreshes only this one repository.

Step 3 – what form does the server take? Two charts can install Prometheus:

  • The big package kube-prometheus-stack (Day 17) brings the Prometheus Operator. It creates every Prometheus instance as a StatefulSet. A Deployment is not provided for there.
  • The lean chart prometheus-community/prometheus works without an operator. Here you can choose between both forms.

Now you read the defaults of the lean chart. You want to know in which form it starts Prometheus if you change nothing.

# on k0s-ctrl
helm show values prometheus-community/prometheus --version 31.0.1
  • helm show values prints a chart’s values file with all defaults. It installs nothing.
  • --version 31.0.1 pins the chart version. It ships Prometheus v3.16.0.

Expected (excerpt – look for the lines with strategy:, statefulSet: and terminationGracePeriodSeconds):

  strategy:
    type: Recreate
  statefulSet:
    ## If true, use a statefulset instead of a deployment for pod management.
    ## This allows to scale replicas to more than 1 pod
    ##
    enabled: false
  terminationGracePeriodSeconds: 300

What you see:

  • strategy: type: Recreate – the server is a Deployment. It first stops the old pod, then starts the new one.
  • statefulSet: enabled: false – no StatefulSet. With true it would become one.
  • terminationGracePeriodSeconds: 300 – on an orderly shutdown Prometheus has 300 seconds to write out its data.

Step 4 – today’s decision. You take the lean chart and the Deployment. The table shows how the two forms differ:

Question Deployment with Recreate StatefulSet
Name of the pod changes on every restart fixed: …-server-0
Replacement on node failure new pod with a new name as soon as Kubernetes or the HA Controller clears the old one only once the old pod is finally deleted. If its node no longer answers, that does not happen on its own
What protects the volume RWO volume and DRBD additionally the fixed name
Multiple replicas not sensible (one TSDB) possible, but each with its own volume and its own data

A StatefulSet promises: “At most one pod with this name.” The price: after a hard node failure possibly none runs at all. The Deployment relies on the RWO volume and on DRBD for the same protection. Whether that is enough is what you measure today.

There is also a practical reason. kube-prometheus-stack only knows the StatefulSet. For a Deployment you would have to rebuild the chart or the operator there. In the lean chart it is one line in the values file. Here it is even the default already.

Remember: Today Prometheus runs as one pod: a Deployment with strategy: Recreate on an RWO volume. What protects against a second writer is the volume with DRBD, not a fixed pod name like …-server-0 in a StatefulSet.

Save your progress? Sign up for free

Drill 2: Prometheus on two replicas

Where you are: on k0s-ctrl, in ~/k0s-lab/tag22.

In this drill:

  • You pull the Prometheus images onto all workers in advance.
  • You install Prometheus on a volume with two replicas.
  • You check where Prometheus runs, where the replicas are and which addresses your nodes have.
  • You note a time and ask Prometheus for the samples from back then.

Step 1 – pull the images in advance. Later you only want to measure how long the move takes. The image download should not distort that time. So you pull both images onto every worker beforehand, as on Day 21, Drill 3.

First the image of Prometheus itself:

# on k0s-w1
sudo k0s ctr -n k8s.io images pull quay.io/prometheus/prometheus:v3.16.0

Then the second image. It is a small helper in the pod: when the configuration changes, it makes Prometheus reload it.

# on k0s-w1
sudo k0s ctr -n k8s.io images pull \
  quay.io/prometheus-operator/prometheus-config-reloader:v0.95.2

Do the same on k0s-w2 and k0s-w3. The images exist for amd64 and arm64. k0s ctr pulls the variant that matches your node.

Now you check that the image really is on the node:

# on k0s-w1
sudo k0s ctr -n k8s.io images ls \
  name==quay.io/prometheus/prometheus:v3.16.0
  • images ls lists the images in the k8s.io namespace.
  • name==… shows only exactly this one image.

Expected (truncated on the right):

REF                                   TYPE                                    DIGEST
quay.io/prometheus/prometheus:v3.16.0 application/vnd.oci.image.index.v1+json sha256:93320545...

What you see: One line with the name of the image – it is on the node. If the list is empty, the download is missing.

Step 2 – the values file. In a values file you tell Helm what Prometheus should look like. You create it with nano:

# on k0s-ctrl
nano prometheus-werte.yaml

Content:

~/k0s-lab/tag22/prometheus-werte.yaml new file
server:
  strategy:
    type: Recreate
  persistentVolume:
    enabled: true
    storageClass: linstor-replicated
    accessModes:
      - ReadWriteOnce
    size: 2Gi
  retention: 2d
  service:
    type: NodePort
    nodePort: 32090
alertmanager:
  enabled: false
kube-state-metrics:
  enabled: false
prometheus-node-exporter:
  enabled: false
prometheus-pushgateway:
  enabled: false
Setting Value Meaning
server.strategy.type Recreate first stop the old pod, then start the new one. This is already the default. You write it down anyway so nobody changes it by accident
persistentVolume.storageClass linstor-replicated the StorageClass from Day 8: two replicas, writecache, quorum
persistentVolume.accessModes ReadWriteOnce the volume is attached to exactly one node at a time
persistentVolume.size 2Gi room for the TSDB
retention 2d keep samples for two days, as on Day 17
service.type, nodePort NodePort, 32090 Prometheus is reachable on every worker at port 32090
alertmanager … prometheus-pushgateway enabled: false switch off the chart’s extras. Today only the server matters, and RAM is tight

Save with Ctrl+O and Enter, exit with Ctrl+X.

Step 3 – namespace and installation. First you create a namespace of its own. A namespace is a separate area in the cluster. This keeps everything belonging to Prometheus together and easy to delete later.

# on k0s-ctrl
kubectl create namespace prometheus

Now you install Prometheus with your values file:

# on k0s-ctrl
helm install prom prometheus-community/prometheus --version 31.0.1 \
  -n prometheus -f prometheus-werte.yaml
Setting Value Meaning
Release name prom the names derive from it, e.g. prom-prometheus-server
Chart prometheus-community/prometheus the lean chart without an operator
--version 31.0.1 fixed chart version
-n, -f prometheus, prometheus-werte.yaml namespace and values file

Expected (excerpt):

NAME: prom
LAST DEPLOYED: Wed Dec  2 14:08:11 2026
NAMESPACE: prometheus
STATUS: deployed
REVISION: 1

What you see: STATUS: deployed – Helm has created everything. This does not yet tell you whether Prometheus is running.

So now you wait until the pod really runs. The command only returns once the Deployment is ready – or after 300 seconds.

# on k0s-ctrl
kubectl -n prometheus rollout status \
  deploy/prom-prometheus-server --timeout=300s

Expected (after just under a minute):

deployment "prom-prometheus-server" successfully rolled out

What you see: successfully rolled out – Prometheus is running.

Step 4 – where does it run, where are the replicas? You check on which node Prometheus runs. You need this because you cut exactly this node off the network in Drill 3. You also see the name of the volume.

# on k0s-ctrl
kubectl -n prometheus get deploy,pods,pvc -o wide
  • -o wide shows extra columns, including the node.

Expected (excerpt, truncated on the right – the lines of the pod and the PVC):

NAME                                          READY   STATUS    RESTARTS   AGE   IP            NODE
pod/prom-prometheus-server-6d8c7c96f4-5njmt   2/2     Running   0          49s   10.244.1.14   k0s-w1

NAME                                           STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS
persistentvolumeclaim/prom-prometheus-server   Bound    pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd   2Gi        RWO            linstor-replicated

What you see:

Column Value Meaning
NODE k0s-w1 Prometheus runs here
STATUS (PVC) Bound the volume is created and belongs to Prometheus
VOLUME pvc-0ee7… the name of the volume – you need it in a moment
ACCESS MODES RWO the volume is attached to exactly one node

Now you ask LINSTOR where the replicas of this volume are. Put in the name of your volume (column VOLUME).

# on k0s-ctrl
linstor --no-utf8 --no-color resource list \
  -r pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd

Expected:

| pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd | k0s-ctrl | DRBD,STORAGE            | Unused | Ok    | Diskless | Yes  |
| pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd | k0s-w1   | DRBD,WRITECACHE,STORAGE | InUse  | Ok    | UpToDate | Yes  |
| pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd | k0s-w2   | DRBD,WRITECACHE,STORAGE | Unused | Ok    | UpToDate | Yes  |

What you see:

  • k0s-w1 is InUse: Prometheus runs there and writes.
  • k0s-w2 is Unused and UpToDate: the second replica lives there, up to date.
  • k0s-ctrl is Diskless: it has no replica of its own. It is the referee for the quorum.

Note the node with InUse. On your setup it may be a different one.

Important for Drills 3 to 5: In the book, the node running Prometheus (InUse) is called k0s-w1, and the one with the second replica (Unused, UpToDate) is k0s-w2. If it is different on your setup, swap the names (and the IPs) everywhere in Drills 3–5.

Step 5 – look into the ledger. Now you look inside the volume. You want to see what Prometheus keeps there.

# on k0s-ctrl
kubectl -n prometheus exec deploy/prom-prometheus-server \
  -c prometheus-server -- ls -la /data
  • exec deploy/… runs the command in the pod of this Deployment.
  • -c prometheus-server selects the container in the pod. The second one is the reload helper.
  • ls -la /data lists the contents of /data. That is where the volume is.

Expected:

total 52
drwxrwsr-x    5 root     nobody        4096 Dec  2 14:08 .
drwxr-xr-x    1 root     root          4096 Dec  2 14:08 ..
drwxr-sr-x    2 nobody   nobody        4096 Dec  2 14:08 chunks_head
-rw-r--r--    1 nobody   nobody           0 Dec  2 14:08 lock
drwxrws---    2 root     nobody       16384 Dec  2 14:08 lost+found
-rw-r--r--    1 nobody   nobody       20001 Dec  2 14:10 queries.active
drwxr-sr-x    2 nobody   nobody        4096 Dec  2 14:08 wal

What you see: Three entries matter:

Entry Meaning
wal write-ahead log: every new sample lands here first. This is the bookkeeper’s notepad
chunks_head the most recent samples, already in blocks
lock lock file: “a Prometheus is already writing here.”

The lock file looks like protection against two writers. What it is worth after a node failure, you see in Drill 3.

Step 6 – the addresses of your nodes. In a moment you need the IP addresses of your workers and of k0s-ctrl. They appear in the commands of this chapter. On your setup they differ from the book. So now you read off your own. First the workers:

# on k0s-ctrl
kubectl get nodes -o wide
  • -o wide shows extra columns, including INTERNAL-IP, the address of the node.

Expected (only the first columns):

NAME     STATUS   ROLES    AGE     VERSION       INTERNAL-IP
k0s-w1   Ready    <none>   5d17h   v1.36.6+k0s   172.16.0.184
k0s-w2   Ready    <none>   5d17h   v1.36.6+k0s   172.16.0.218
k0s-w3   Ready    <none>   5d17h   v1.36.6+k0s   172.16.0.163

What you see: The INTERNAL-IP column shows the address of each worker. k0s-ctrl is missing from the list. It is only the control station and not a node in the cluster (see Day 1).

So you ask k0s-ctrl directly for its address:

# on k0s-ctrl
hostname -I
  • -I prints all addresses of the machine. The first one is the one you need.

Expected (excerpt, first address):

172.16.0.117

What you see: The first address is the one of k0s-ctrl.

Node role today in the book on your setup (name and address)
k0s-ctrl workstation and referee 172.16.0.117
k0s-w1 Prometheus runs here (InUse) – cut off in Drill 3 172.16.0.184
k0s-w2 second replica (Unused) – Prometheus moves here 172.16.0.218
k0s-w3 no replica 172.16.0.163

Write down your four addresses. Put them in wherever the chapter shows a 172.16.0.x. In the last column, also note which of your workers has which role – after Step 4 you know.

Step 7 – note the time. In a moment you ask Prometheus: “Were the three workers reachable at time X?” After every failure you ask the same question again. For that you need a fixed time that you write down:

# on k0s-ctrl
date -u +%Y-%m-%dT%H:%M:00Z
  • -u – the time in UTC; that is how Prometheus counts,
  • +%Y-%m-%dT%H:%M:00Z – the format Prometheus understands: date, T, time, Z for UTC.

In the author’s lab it was 2026-12-02T14:15:00Z. Write down your time – you need it again in Drill 3 and Drill 4.

Step 8 – ask Prometheus. What is this for? You take a snapshot as proof of the data. You ask Prometheus: “Which values did you have at time X?” After the failure you ask exactly the same question for exactly the same time. If the answer is the same, the new Prometheus has the old data. Then the replica on the other node was complete.

The question “How are things now?” would not prove this. A new Prometheus starts measuring again at once, even with an empty volume.

Put your time in place of 2026-12-02T14:15:00Z. 172.16.0.218 is the address of k0s-w2 from Step 6 – put in yours.

Why k0s-w2 and not k0s-w1? Prometheus is reachable through the NodePort on every worker. The worker forwards the request to the pod, wherever it runs. But you ask through a worker that you do not cut off in Drill 3. Otherwise there would be no answer after the cut.

# on k0s-ctrl
curl -s -o punkt.json -G http://172.16.0.218:32090/api/v1/query \
  --data-urlencode 'query=up{job="kubernetes-nodes"}' \
  --data-urlencode 'time=2026-12-02T14:15:00Z'

In words: “Prometheus, give me the value up of all workers for time X, and put the answer in punkt.json.”

Part what it does
-o punkt.json write the answer to the file punkt.json instead of the terminal
http://172.16.0.218:32090/api/v1/query Prometheus’ query endpoint, via the NodePort on k0s-w2 (any worker that is not cut off works)
query=up{job="kubernetes-nodes"} the question: up is 1 if Prometheus reached the worker, otherwise 0
time=… for which point in time – your noted time
-G and --data-urlencode append question and time to the address, packing special characters like { and " properly
\ at the end of a line the command continues on the next line; the last line has none

Step 9 – read the answer.

# on k0s-ctrl
jq -c '.data.result[] | {node: .metric.instance, wert: .value[1]}' \
  punkt.json
  • -c prints each result compactly on one line.

Expected:

{"node":"k0s-w2","wert":"1"}
{"node":"k0s-w1","wert":"1"}
{"node":"k0s-w3","wert":"1"}

After every failure you ask exactly this question again – if the answer is the same, the ledger has survived.

Remember: Prometheus’ ledger lives in /data on an RWO volume with two replicas. A query with time= in the past is your proof of data after every failure.

Save your progress? Sign up for free

Drill 3: The failure with the HA Controller – and the frozen pen

Where you are: on k0s-ctrl. You set the block on the node with the Prometheus pod.

In this drill:

  • You look at how DRBD shuts down the old node.
  • You cut the node running Prometheus off the network.
  • You watch the HA Controller move Prometheus.
  • You check: the old node can no longer write, and the samples are still there.

Step 1 – look at the DRBD rules before you need them. Now you read the rules DRBD uses for this volume. They say what DRBD does when a node loses contact. You ask the node with the pod. Put in the name of your volume.

# on k0s-ctrl
ssh k0s-w1 sudo drbdsetup show --show-defaults \
  pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd
  • drbdsetup show prints the configuration the kernel is currently running the resource with.
  • --show-defaults also shows the values nobody set. They carry the comment # default.

The output is long. Today only three lines in it matter: quorum, on-no-quorum and on-suspended-primary-outdated. You can skip all the others.

Expected (excerpt – the options block):

    options {
        cpu-mask            ""; # default
        on-no-data-accessible   suspend-io;
        auto-promote        yes; # default
        peer-ack-window     4096s; # bytes, default
        peer-ack-delay      100; # milliseconds, default
        twopc-timeout       300; # 1/10 seconds, default
        twopc-retry-timeout 1; # 1/10 seconds, default
        auto-promote-timeout    20; # 1/10 seconds, default
        max-io-depth        8000; # default
        quorum              majority;
        on-no-quorum        suspend-io; # default
        quorum-minimum-redundancy   off; # default
        on-suspended-primary-outdated   force-secondary;
        drbd8-api-compatibility no; # default
    }

What you see: Three lines are your fencing today. They shut down the old writer:

Line Meaning In the picture
quorum majority only a node that sees the majority of participants may write (Day 11) the referee
on-no-quorum suspend-io if a node loses quorum, DRBD holds every write. The node waits instead of writing pen frozen
on-suspended-primary-outdated force-secondary if a frozen node comes back and the others have newer data, it loses the right to write. Its held writes fail the old bookkeeper hands over the book, his half-finished entries are discarded

Instead of suspend-io there is also io-error. Then the node gets an error at once instead of waiting. The application is then more likely to crash. But it cannot write either way. The StorageClass from Day 8 sets suspend-io, and the HA Controller relies on it.

Step 2 – the safety net: a timer. In a moment you cut the node with the pod off the network. You do not switch it off for that. Four rules in the packet filter iptables drop everything that reaches or leaves it – only SSH from k0s-ctrl still gets through. To the cluster this looks like a dead node. The node itself keeps running, though, and the old Prometheus with it. That is the most dangerous case.

Beforehand you set up a safety net: after 30 minutes a timer removes the block on its own. That way you can always get back to the node, even if you lock yourself out.

Warning: The block lets SSH through only from k0s-ctrl. If you are logged in to k0s-w1 directly from your laptop, you lose that session. Exactly that happened in the author’s lab. So log in to k0s-ctrl first and from there use ssh k0s-w1.

The commands here are for k0s-w1.

# on k0s-w1
sudo systemd-run --unit=netz-zurueck --on-active=30min \
  iptables -t raw -F
  • systemd-run --unit=netz-zurueck starts a job named netz-zurueck.
  • --on-active=30min runs it only in 30 minutes.
  • iptables -t raw -F is the job: delete all rules in the raw table, i.e. the block.

Before you cut it off – your prediction:

  1. How long does it take until Prometheus answers again: seconds, about two minutes, or more than ten minutes?
  2. Can the old Prometheus on k0s-w1 still write to its volume after the cut?

Write down both answers. At the end of the drill you compare them with the measurement.

Step 3 – the block, rule by rule. Now you build the block from four rules. The order matters: iptables checks the rules of a chain from top to bottom, and the first matching rule decides. So you first allow SSH from k0s-ctrl and only then drop everything else.

Rule 1: incoming SSH from k0s-ctrl may come in. 172.16.0.117 is the address of k0s-ctrl from Drill 2, Step 6 – put in yours.

# on k0s-w1
sudo iptables -t raw -A PREROUTING -s 172.16.0.117 \
  -p tcp --dport 22 -j ACCEPT
Option Meaning
iptables the Linux kernel’s packet filter; changes need sudo
-t raw the raw table. The kernel checks it before all other tables, including before the rules Kubernetes creates itself. That way the block takes effect reliably
-A PREROUTING append the rule to the PREROUTING chain (-A = append). This chain sees every packet that comes in
-s 172.16.0.117 only packets with this source address – k0s-ctrl
-p tcp only TCP packets
--dport 22 only packets to destination port 22 – where SSH listens
-j ACCEPT a matching packet is let through (-j = jump to the target). The kernel checks no further rules for it

Rule 2: everything else coming in is dropped. Only lo, the machine’s path to itself, stays open. Processes on the node talk to each other over lo, for example the kubelet with containerd.

# on k0s-w1
sudo iptables -t raw -A PREROUTING ! -i lo -j DROP
  • ! -i lo – all packets that do not (!) come in through the interface lo (-i = input interface).
  • -j DROP – silently drop the packet. The sender gets no answer and waits until its timeout expires – just like with a dead node.

Rule 3: SSH replies to k0s-ctrl may go out. Here, too, 172.16.0.117 is the address of k0s-ctrl – put in yours.

# on k0s-w1
sudo iptables -t raw -A OUTPUT -d 172.16.0.117 \
  -p tcp --sport 22 -j ACCEPT
  • -A OUTPUT – the chain for packets the node sends itself.
  • -d 172.16.0.117 – only packets to this destination address, i.e. to k0s-ctrl.
  • --sport 22 – only packets from source port 22: the SSH server’s replies.

Rule 4: everything else going out is dropped. From now on the node is cut off the network.

# on k0s-w1
sudo iptables -t raw -A OUTPUT ! -o lo -j DROP
  • ! -o lo – all packets that do not go out through lo (-o = output interface).
  • -j DROP – drop them. From this rule on, no packet from the node reaches the network.

Note the time. In the author’s lab the last answer from Prometheus came at 14:18:22.

Step 4 – watch. Open a second terminal on k0s-ctrl. There you watch live how the pods change:

# on k0s-ctrl
kubectl -n prometheus get pods -o wide -w
  • -w (watch) stays open and shows every change as a new line. Stop it with Ctrl+C.

Let the command run until a line with 2/2 and Running on k0s-w2 appears.

Expected (excerpt from the author’s lab run, only the columns NAME, READY, STATUS and NODE; RESTARTS, AGE and IP omitted, spaces shortened). The author ran the command with two additions your terminal does not show: on the left is the time the line appeared. The EVENT column comes from the option --output-watch-events – ADDED means new pod, MODIFIED changed, DELETED deleted. On your setup each line starts with the pod name:

14:18:13 EVENT    NAME                                    READY STATUS            NODE
14:18:13 ADDED    prom-prometheus-server-6d8c7c96f4-5njmt 2/2   Running           k0s-w1
14:18:45 MODIFIED prom-prometheus-server-6d8c7c96f4-5njmt 2/2   Terminating       k0s-w1
14:18:45 ADDED    prom-prometheus-server-6d8c7c96f4-hf9z8 0/2   Pending           <none>
14:18:45 MODIFIED prom-prometheus-server-6d8c7c96f4-hf9z8 0/2   Pending           k0s-w3
14:19:15 DELETED  prom-prometheus-server-6d8c7c96f4-5njmt 2/2   Terminating       k0s-w1
14:19:54 MODIFIED prom-prometheus-server-6d8c7c96f4-hf9z8 1/2   Running           k0s-w3
14:19:55 MODIFIED prom-prometheus-server-6d8c7c96f4-hf9z8 1/2   Terminating       k0s-w3
14:19:55 ADDED    prom-prometheus-server-6d8c7c96f4-ccdgw 0/2   Pending           <none>
14:19:56 MODIFIED prom-prometheus-server-6d8c7c96f4-ccdgw 0/2   Pending           k0s-w2
14:19:56 MODIFIED prom-prometheus-server-6d8c7c96f4-ccdgw 0/2   ContainerCreating k0s-w2
14:20:07 MODIFIED prom-prometheus-server-6d8c7c96f4-ccdgw 0/2   Running           k0s-w2
14:20:39 MODIFIED prom-prometheus-server-6d8c7c96f4-ccdgw 2/2   Running           k0s-w2

What you see: Each line is a change to a pod. You tell the three pods apart by the last five characters of their names:

Time Line Event
14:18:13 5njmt Running on k0s-w1 starting point: the old Prometheus
14:18:45 5njmt Terminating the HA Controller evicts the old pod
14:18:45 hf9z8 Pending, first <none>, then k0s-w3 the Deployment creates a new pod; Kubernetes schedules it on k0s-w3
14:19:15 5njmt DELETED the old pod is gone from Kubernetes
14:19:54 – 14:19:55 hf9z8 1/2 Running, then Terminating detour: the pod on k0s-w3 starts and is evicted again at once (box below)
14:19:55 – 14:19:56 ccdgw Pending, then k0s-w2 the next pod, now on the node with the second replica
14:20:07 ccdgw 0/2 Running the containers run, Prometheus replays its WAL
14:20:39 ccdgw 2/2 Running Prometheus is ready

This command does not show the other points in time. The author measured them in the same run with further commands:

Time since the cut Event measured in the lab with
14:18:23 0 s k0s-w1 cut off curl on /-/ready every 2 seconds: last answer at 14:18:22
14:18:27 4 s DRBD on k0s-w1 loses quorum and suspends writes kernel log of k0s-w1 (journalctl -k): susp-io( no -> quorum )
14:18:45 22 s HA Controller evicts the old pod watch above and events (Step 6)
14:19:12 49 s node k0s-w1 NotReady kubectl get nodes -w
14:19:51 88 s volume attached to k0s-w3 (detour) kubectl get volumeattachments -w
14:20:05 102 s volume attached to k0s-w2 kubectl get volumeattachments -w
14:20:39 136 s Prometheus ready (2/2) watch above
Drill 3, measured: from the cut until Prometheus is ready again

The main sequence in one line: k0s-w1 cut off → DRBD freezes its writes → the HA Controller clears up → Prometheus starts on k0s-w2 → the data is there (Step 7). After just over two minutes Prometheus was running again – without manual work.

What else happened in the lab: A detour cost a good 70 seconds. Kubernetes first chose k0s-w3, a node without a replica of its own. There LINSTOR attached the volume diskless: the data then comes over the network from another node. While doing so, the HA Controller briefly reported quorum loss on k0s-w3. The log shows NodeStorageQuorumLost and, in the same minute, NodeStorageQuorumRegained. So the HA Controller cleared the fresh pod away again at once. Only the pod on k0s-w2 stayed. That is where the second replica lives. On your setup Kubernetes may pick the right node straight away.

Step 5 – the frozen pen. Now you ask the cut-off node about its replica. That still works, because SSH from k0s-ctrl gets through. You want to see whether DRBD really halted it.

# on k0s-ctrl
ssh k0s-w1 sudo drbdsetup status --verbose \
  pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd
  • drbdsetup status shows the state of the resource on this node.
  • --verbose shows extra fields, including suspended and blocked.

Expected:

pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd node-id:0 role:Primary suspended:quorum
    force-io-failures:no
  volume:0 minor:1001 disk:UpToDate
      backing_dev:/dev/mapper/linstor_writecache_pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd_00000
      quorum:no open:yes blocked:upper
  k0s-ctrl node-id:2 connection:Connecting role:Unknown tls:no congested:no
      ap-in-flight:0 rs-in-flight:0
    volume:0 replication:Off peer-disk:DUnknown resync-suspended:no
  k0s-w2 node-id:1 connection:Connecting role:Unknown tls:no congested:no
      ap-in-flight:0 rs-in-flight:0
    volume:0 replication:Off peer-disk:DUnknown resync-suspended:no

What you see:

Field Value Meaning
role Primary k0s-w1 still holds the volume open
suspended quorum halted because quorum is missing
quorum no it sees neither k0s-w2 nor the referee
blocked upper writes from above (file system, Prometheus) are piling up

In the picture: the old bookkeeper still sits in the office holding the pen. But the pen is frozen. No entry reaches the disk. That is exactly why k0s-w2 may take over.

Step 6 – who acted? Now you read the events in the cluster. You want to see what the HA Controller did, and in which order.

# on k0s-ctrl
kubectl get events -A --sort-by=.lastTimestamp
  • -A shows the events of all namespaces. The HA Controller writes some to default, because nodes and VolumeAttachments do not belong to any namespace.
  • --sort-by=.lastTimestamp sorts by time, newest at the bottom.

Expected (excerpt – look for the lines with quorum):

default             15m         Warning   NodeStorageQuorumLost       node/k0s-w1                                                                             Tainted node because some volumes have lost quorum
default             15m         Warning   VolumeWithoutQuorum         volumeattachment/csi-923f153faad3ea3e416be18ade96e8a371abd494b9ff7c262b7eb5bc2cb5594b   Volume attachment was force-detached because node lost quorum
prometheus          15m         Warning   VolumeWithoutQuorum         pod/prom-prometheus-server-6d8c7c96f4-5njmt                                             Pod was evicted because attached volume lost quorum

What you see: The HA Controller did three things:

  1. NodeStorageQuorumLost: a taint on k0s-w1. New pods no longer land there.
  2. VolumeWithoutQuorum on the pod: it evicted the old pod.
  3. VolumeWithoutQuorum on the VolumeAttachment: it forcibly released the volume from the old node (force-detached). A VolumeAttachment is the Kubernetes record of which node a volume is attached to.

This is a force detach, but not a blind one. The HA Controller only does it when DRBD reports that k0s-w2 may take over. DRBD only reports that when k0s-w1 no longer has quorum. And without quorum k0s-w1 is frozen.

Step 7 – is the data there? Now you compare with the proof snapshot from Drill 2. To do so, you ask the same question as in Drill 2, Step 8. Use your noted time. This time the answer goes into punkt-danach.json. 172.16.0.218 is the address of k0s-w2 from Drill 2, Step 6 – put in yours.

# on k0s-ctrl
curl -s -o punkt-danach.json -G http://172.16.0.218:32090/api/v1/query \
  --data-urlencode 'query=up{job="kubernetes-nodes"}' \
  --data-urlencode 'time=2026-12-02T14:15:00Z'

Then you read the answer, as in Drill 2, Step 9:

# on k0s-ctrl
jq -c '.data.result[] | {node: .metric.instance, wert: .value[1]}' \
  punkt-danach.json

Expected:

{"node":"k0s-w2","wert":"1"}
{"node":"k0s-w1","wert":"1"}
{"node":"k0s-w3","wert":"1"}

What you see: The same answer as on the proof snapshot before the failure. The ledger survived the move.

Now you read the log of the new Prometheus instance. It shows how the instance opened the ledger.

# on k0s-ctrl
kubectl -n prometheus logs deploy/prom-prometheus-server \
  -c prometheus-server

Expected (excerpt – look for the lines with lockfile and WAL replay; the second truncated on the right):

time=2026-12-02T14:20:09.207Z level=WARN source=dir_locker.go:75 msg="A lockfile from a previous execution already existed. It was replaced" component=tsdb file=/data/lock
time=2026-12-02T14:20:10.426Z level=INFO source=head.go:987 msg="WAL replay completed" component=tsdb checkpoint_replay_duration=197.486µs wal_replay_duration=1.211570906s wbl_replay_duration=377ns chunk_snapshot_load_duration=0s

What you see:

  • Line 1: Prometheus found the old instance’s lock file – and simply replaced it. So the lock file only protects against a second Prometheus on the same machine. It does not protect against a second node.
  • Line 2: Prometheus replayed the notepad (wal) in 1.2 seconds.

So it is not Prometheus that protects against a second writer on another node. DRBD does that.

Your prediction – the answer:

  1. In the lab Prometheus answered again after 136 seconds, just over two minutes after the cut – without manual work.
  2. No. Four seconds after the cut, k0s-w1 lost quorum and DRBD suspended every write. You saw it in Step 5: suspended:quorum and blocked:upper.

Remember: Freeze first, then hand over: DRBD freezes the old primary without quorum, and only because of that may the HA Controller forcibly release the volume. Prometheus’ lock file does not help here.

Save your progress? Sign up for free

Drill 4: The old bookkeeper comes back

Where you are: on k0s-ctrl.

In this drill:

  • You look at what the old Prometheus on k0s-w1 is doing right now.
  • You lift the block and bring k0s-w1 back.
  • You check: the old Prometheus’s last write attempts were discarded.
  • You check that both replicas are the same again.

Step 1 – what is the old instance doing? The cut-off node knows nothing of the move. Its kubelet cannot reach the API server. So it keeps the old pod running, or tries to. Now you check whether the old Prometheus process on k0s-w1 is still there:

# on k0s-ctrl
ssh k0s-w1 ps -o pid,stat,etime,wchan:20,cmd -C prometheus
Setting Meaning
-C prometheus only processes with this name
-o pid,stat,etime,wchan:20,cmd columns: process ID, state, run time, what the process waits for in the kernel (20 characters wide), command

Expected (truncated on the right):

    PID STAT     ELAPSED WCHAN                CMD
 185106 Zsl        19:38 -                    [prometheus] <defunct>

What you see: Z in STAT means zombie. The process has ended but is not fully cleaned up yet. Note the number in PID.

Now you look at the threads of this process one by one. A thread is a part of the process that works on its own. This shows you why the process does not go away.

# on k0s-ctrl
ssh k0s-w1 ps -L -o tid,stat,wchan:32,comm -p 185106
  • -L shows each thread separately.
  • -p 185106 shows only this process. Put in your PID.

Expected:

    TID STAT WCHAN                            COMMAND
 185106 Zsl  -                                prometheus
 185120 Dsl  -                                prometheus

What you see: One thread is in D. That means uninterruptible sleep: it waits and cannot even be killed. It waits for a write that DRBD has held. The kubelet wanted to restart the container. While doing so, the process became a zombie. It cannot get free. In the picture: the pen is frozen, nobody in the office can enter anything.

Step 2 – lift the block. Now you bring k0s-w1 back onto the network. To do so you delete all rules in the raw table:

# on k0s-w1
sudo iptables -t raw -F

Then you stop the timer from Drill 3. It has nothing left to do.

# on k0s-w1
sudo systemctl stop netz-zurueck.timer

In the lab this happened at 14:28:22, just under ten minutes after the cut.

Step 3 – what DRBD does on reunion. Now you read the kernel log of k0s-w1. You want to see what DRBD did in the seconds of the return. Put your time into the command.

# on k0s-ctrl
ssh k0s-w1 sudo journalctl -k --since 14:28:20 --until 14:28:30 \
  --grep "force\ secondary\|I/O\ error" --no-pager
Setting Meaning
-k kernel messages only
--since, --until time window – put in your time
--grep "force\ secondary\|I/O\ error" only lines with one of the two patterns (\| = “or”). The backslashes protect spaces and \| from the shell on the node
--no-pager print everything at once, not page by page

Expected (excerpt, the first lines):

Dec 02 14:28:22 k0s-w1 kernel: drbd pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd k0s-ctrl: Remote node has more recent data; force secondary!
Dec 02 14:28:22 k0s-w1 kernel: EXT4-fs warning (device drbd1001): ext4_end_bio:353: I/O error 10 writing to inode 15 starting block 9050)
Dec 02 14:28:22 k0s-w1 kernel: Buffer I/O error on device drbd1001, logical block 9050
Dec 02 14:28:22 k0s-w1 kernel: EXT4-fs warning (device drbd1001): ext4_end_bio:353: I/O error 10 writing to inode 15 starting block 9051)
Dec 02 14:28:22 k0s-w1 kernel: Buffer I/O error on device drbd1001, logical block 9051

What you see:

  • Remote node has more recent data; force secondary! – k0s-w1 sees the others again. They have newer data. So it loses the right to write. That is the effect of the line on-suspended-primary-outdated force-secondary from Drill 3.
  • I/O error – all held writes of the old Prometheus fail.

These writes do not land on the disk, let alone on k0s-w2. In the picture: the old bookkeeper’s half-finished entries are discarded.

Step 4 – the replicas. Now you ask LINSTOR whether both replicas are healthy again.

# on k0s-ctrl
linstor --no-utf8 --no-color resource list \
  -r pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd

Expected:

| pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd | k0s-ctrl | DRBD,STORAGE            | Unused | Ok    | Diskless | Yes  |
| pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd | k0s-w1   | DRBD,WRITECACHE,STORAGE | Unused | Ok    | UpToDate | Yes  |
| pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd | k0s-w2   | DRBD,WRITECACHE,STORAGE | InUse  | Ok    | UpToDate | Yes  |
| pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd | k0s-w3   | DRBD,STORAGE            | Unused | Ok    | Diskless | No   |

What you see:

  • k0s-w1 is UpToDate again. According to the kernel log the resync took less than a second. In ten minutes little had changed in Prometheus.
  • k0s-w2 is InUse: Prometheus runs there now.
  • k0s-w3 has a diskless resource, left over from the detour in Drill 3. It is Unused and does no harm.

Step 5 – the HA Controller’s taint. Now you check whether k0s-w1 still carries the HA Controller’s taint. As long as it is there, no new pods land on k0s-w1.

# on k0s-ctrl
kubectl get node k0s-w1 -o jsonpath='{.spec.taints}{"\n"}'
  • -o jsonpath='{.spec.taints}{"\n"}' prints only the node’s taints, with a line break at the end.

Expected (right after the return):

[{"effect":"NoSchedule","key":"drbd.linbit.com/lost-quorum","timeAdded":"2026-12-02T14:18:45Z"}]

What you see: The taint drbd.linbit.com/lost-quorum with NoSchedule is still there. In the lab the HA Controller removed it by itself a good four minutes after the return (event NodeStorageQuorumRegained for k0s-w1). Until then Kubernetes schedules no new pods on k0s-w1.

Remember: When the old node comes back, the newer side wins: force-secondary demotes it, and its held writes end up as I/O error in the kernel log – not in your data.

Save your progress? Sign up for free

Drill 5: The failure without the HA Controller (comparison – can be skipped)

Comparison – can be skipped: This drill shows what happens without the HA Controller. The waiting alone takes more than a quarter of an hour. If you are short on time, just read it and continue with the checkpoint.

Where you are: on k0s-ctrl, in ~/k0s-lab/tag22.

In this drill:

  • You switch off the HA Controller.
  • You cut the node running Prometheus off the network once more.
  • You see: Kubernetes never releases the volume on its own.
  • You confirm the failure by hand and switch the HA Controller back on.

Without the HA Controller, Kubernetes decides alone. You switch the HA Controller off briefly for this. At the end of the drill you switch it back on.

Step 1 – switch the HA Controller off. You need a values file for LINSTOR in which the HA Controller is off. To get one, you copy the values file from Day 21:

# on k0s-ctrl
cp ~/k0s-lab/tag21/werte-nfs.yaml werte-ohne-ha.yaml

Now you open the copy and change one line: enabled: true becomes enabled: false.

# on k0s-ctrl
nano werte-ohne-ha.yaml
~/k0s-lab/tag22/werte-ohne-ha.yaml (Auszug) changes in green
  highAvailabilityController:
    enabled: false
    podTemplate:
      spec:
        nodeSelector:
          piraeus.io/managed-satellite: null

Save with Ctrl+O and Enter, exit with Ctrl+X.

Now you apply the changed values file. Helm then removes the HA Controller.

# on k0s-ctrl
helm upgrade linstor-cluster piraeus-charts/linstor-cluster \
  --version 1.3.2 -n piraeus-datastore -f werte-ohne-ha.yaml
  • helm upgrade changes an existing installation with new values.
  • --version 1.3.2 is the same chart version as before. So only the one value changes.

Now you check that the HA Controller is really gone:

# on k0s-ctrl
kubectl -n piraeus-datastore get ds

Expected:

NAME                     DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
linstor-csi-nfs-server   3         3         3       3            3           <none>          36m
linstor-csi-node         3         3         3       3            3           <none>          20h

What you see: The ha-controller DaemonSet is missing. DRBD and its quorum keep working as before. Only nobody reads the DRBD state for Kubernetes any more.

Step 2 – where does Prometheus run now? You check on which node Prometheus is running right now. You cut exactly this node off the network in a moment.

# on k0s-ctrl
kubectl -n prometheus get pods -o wide

Expected (excerpt):

NAME                                      READY   STATUS    RESTARTS   AGE   IP            NODE
prom-prometheus-server-6d8c7c96f4-br459   2/2     Running   0          73s   10.244.0.16   k0s-w2

What you see: In the author’s lab the pod ran on k0s-w2. It had a new name by then, because the author had restarted it in between. On your setup it is the node from Drill 3.

Before you cut it off – your prediction:

  1. Without the HA Controller: when does Kubernetes schedule a new pod – and does it then start?
  2. Does Kubernetes ever release the cut-off node’s volume on its own?

Write down both answers.

Step 3 – cut off. You now cut off the node with the pod – here k0s-w2 – exactly as in Drill 3. First the timer as a safety net again: it removes the block after 30 minutes. This time it is called netz-zurueck2. The name netz-zurueck may already be taken on k0s-w2.

# on k0s-w2
sudo systemd-run --unit=netz-zurueck2 --on-active=30min \
  iptables -t raw -F

Then you set the same four rules as in Drill 3, now on k0s-w2. The address 172.16.0.117 in them is again the one of k0s-ctrl – put in yours.

Rule 1: SSH from k0s-ctrl may come in.

# on k0s-w2
sudo iptables -t raw -A PREROUTING -s 172.16.0.117 \
  -p tcp --dport 22 -j ACCEPT

Rule 2: everything else coming in is dropped – except via lo.

# on k0s-w2
sudo iptables -t raw -A PREROUTING ! -i lo -j DROP

Rule 3: SSH replies to k0s-ctrl may go out.

# on k0s-w2
sudo iptables -t raw -A OUTPUT -d 172.16.0.117 \
  -p tcp --sport 22 -j ACCEPT

Rule 4: everything else going out is dropped. From now on k0s-w2 is cut off.

# on k0s-w2
sudo iptables -t raw -A OUTPUT ! -o lo -j DROP

The options are the same as in Drill 3: -t raw the table checked first, -A PREROUTING or -A OUTPUT for incoming or outgoing packets, -s/-d source or destination address, --dport/--sport destination or source port, ! -i lo/! -o lo everything except lo, -j ACCEPT let through, -j DROP drop. In the lab k0s-w2 was cut off at 14:41:30.

Step 4 – watch. You watch as in Drill 3, Step 4, with kubectl -n prometheus get pods -o wide -w. The author again measured with the same commands as in Drill 3 (pods, nodes and events in watch mode). In the author’s lab:

Time Event since the cut
14:41:30 k0s-w2 cut off, DRBD freezes the old instance 0 s
14:42:19 node NotReady, taint node.kubernetes.io/unreachable 49 s
14:47:20 TaintManagerEviction: old pod Terminating, new pod on k0s-w1 5 min 50 s
from 14:47:20 new pod stuck in ContainerCreating –
14:57:20 still the same state 15 min 50 s

What you see: Kubernetes only schedules a new pod after almost six minutes. And that pod does not start.

Step 5 – why nothing happens. Ten minutes after the rescheduling you look for the cause. First you look at the two pods:

# on k0s-ctrl
kubectl -n prometheus get pods -o wide

Expected (excerpt):

NAME                                      READY   STATUS              RESTARTS   AGE   IP            NODE
prom-prometheus-server-6d8c7c96f4-br459   2/2     Terminating         0          17m   10.244.0.16   k0s-w2
prom-prometheus-server-6d8c7c96f4-f28ks   0/2     ContainerCreating   0          10m   <none>        k0s-w1

What you see: The old pod on k0s-w2 is in Terminating. The new pod on k0s-w1 is stuck in ContainerCreating. It is waiting for its volume.

Now you ask which node the volume is attached to according to Kubernetes. The VolumeAttachment says so:

# on k0s-ctrl
kubectl get volumeattachments \
  -o custom-columns=PV:.spec.source.persistentVolumeName,NODE:.spec.nodeName,ATTACHED:.status.attached
  • custom-columns shows only three columns: the volume, the node and whether it is attached.

Expected:

PV                                         NODE     ATTACHED
pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd   k0s-w2   true

What you see: According to Kubernetes the volume is still attached to k0s-w2 (ATTACHED true) – the cut-off node.

Finally you read the events in the namespace. They say what the new pod is waiting for:

# on k0s-ctrl
kubectl -n prometheus get events --sort-by=.lastTimestamp

Expected (excerpt – look for the line with FailedAttachVolume):

10m         Warning   FailedAttachVolume       pod/prom-prometheus-server-6d8c7c96f4-f28ks    Waiting for detach for volume "pvc-0ee7bcc3-6e31-4726-bd1b-4de2a6e218fd" Volume is already used by pod(s) prom-prometheus-server-6d8c7c96f4-br459

What you see: Waiting for detach – the new pod waits until the volume is released from the old node. Volume is already used by pod(s) names the old pod.

Why does this not resolve? Only the kubelet on k0s-w2 could finally delete the old pod. And it is unreachable. As long as the old pod exists, the volume counts as in use. So the VolumeAttachment keeps pointing at k0s-w2. In the picture: Kubernetes does not tear the book out of anyone’s hands if it does not know whether he is still writing. In the lab the state was unchanged after almost 16 minutes. There was no sign that it would resolve on its own.

A StatefulSet is even stricter here. It does not even create a new pod as long as the old …-0 is in Terminating. You saw that on Day 10, Drill 5, with pg-0. For both forms: without confirmation from outside, the service stays down.

Step 6 – the manual confirmation. Now you tell Kubernetes: “This node is safely off.” You must have checked that first. Here it is the case: k0s-w2 is off the network, and DRBD has frozen it (Drill 3, Step 5). Only then do you set the out-of-service taint from Day 10:

# on k0s-ctrl
kubectl taint node k0s-w2 \
  node.kubernetes.io/out-of-service=nodeshutdown:NoExecute
  • node.kubernetes.io/out-of-service is a taint with a fixed meaning: the node is out of service.
  • NoExecute means: pods on this node are removed, and Kubernetes releases their volumes.

Expected:

node/k0s-w2 tainted

Now you wait until the new pod is ready. Put in the name of your new pod.

# on k0s-ctrl
kubectl -n prometheus wait --for=condition=Ready \
  pod/prom-prometheus-server-6d8c7c96f4-f28ks --timeout=240s
  • --for=condition=Ready waits until the pod is ready.
  • --timeout=240s gives up after 240 seconds.

Expected:

pod/prom-prometheus-server-6d8c7c96f4-f28ks condition met

What you see: condition met – Prometheus is running again. In the lab: taint at 14:57:27, volume attached to k0s-w1 at 14:57:41, Prometheus ready at 14:58:16. That is 49 seconds after the taint and 16 minutes 46 seconds after the cut. How long it takes for you depends only on when you set the taint.

Your prediction – the answer:

  1. Kubernetes scheduled the new pod only after 5 minutes 50 seconds – and it did not start. It hung in ContainerCreating, waiting for the volume.
  2. No. After almost 16 minutes, Kubernetes still had the volume attached to the cut-off node. Only the out-of-service taint released it. 49 seconds later Prometheus was running again.

Step 7 – the data. Now you compare with the proof snapshot from Drill 2 again. You ask the same question as in Drill 2, Step 8, with your noted time. This time you ask via k0s-w1, because k0s-w2 is still cut off. 172.16.0.184 is the address of k0s-w1 from Drill 2, Step 6 – put in yours.

# on k0s-ctrl
curl -s -o punkt-ohne-ha.json -G http://172.16.0.184:32090/api/v1/query \
  --data-urlencode 'query=up{job="kubernetes-nodes"}' \
  --data-urlencode 'time=2026-12-02T14:15:00Z'

Then you read the answer:

# on k0s-ctrl
jq -c '.data.result[] | {node: .metric.instance, wert: .value[1]}' \
  punkt-ohne-ha.json

Expected:

{"node":"k0s-w2","wert":"1"}
{"node":"k0s-w1","wert":"1"}
{"node":"k0s-w3","wert":"1"}

What you see: The same answer as on the proof snapshot again. This move did not cost any samples either.

Step 8 – bring it back and switch the HA Controller on again. Now you clean up in three steps: network back, taint gone, HA Controller on.

First you lift the block on k0s-w2:

# on k0s-w2
sudo iptables -t raw -F

Then you stop the timer, it is no longer needed:

# on k0s-w2
sudo systemctl stop netz-zurueck2.timer

Here, too, the kernel log of k0s-w2 reported force secondary! and I/O error on the return. In addition there was Rejected WRITE request, not in Primary role. So the old instance could no longer reach the data.

Now you remove the out-of-service taint again (Day 10, Drill 7). Otherwise k0s-w2 stays out of service for Kubernetes.

# on k0s-ctrl
kubectl taint node k0s-w2 \
  node.kubernetes.io/out-of-service=nodeshutdown:NoExecute-
  • The - at the end removes the taint.

Expected:

node/k0s-w2 untainted

Finally you bring the HA Controller back. To do so you apply the values file from Day 21 again:

# on k0s-ctrl
helm upgrade linstor-cluster piraeus-charts/linstor-cluster \
  --version 1.3.2 -n piraeus-datastore \
  -f ~/k0s-lab/tag21/werte-nfs.yaml

Now you check that the HA Controller is running again:

# on k0s-ctrl
kubectl -n piraeus-datastore get ds

Expected:

NAME                     DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
ha-controller            3         3         3       3            3           <none>          38s
linstor-csi-nfs-server   3         3         3       3            3           <none>          54m
linstor-csi-node         3         3         3       3            3           <none>          20h

What you see: ha-controller is back, with three pods. The AGE of 38 seconds shows: it has just been restarted.

The comparison of the two runs in the lab:

with HA Controller without HA Controller
new pod scheduled after 22 s after 5 min 50 s
volume free for the new node after 88 s (automatic) only after the out-of-service taint
Prometheus ready again after 2 min 16 s 49 s after the taint, in the lab after 16 min 46 s
manual work none set the taint and remove it again
samples from before the failure complete complete

Remember: Without the HA Controller, Kubernetes waits until a human confirms “the node is safely off”. That is slow, but right: a volume that nobody safely releases is never written twice.

Save your progress? Sign up for free

If it doesn’t work

  • After setting the iptables rules your SSH session no longer responds: You were logged in directly from another machine, not via k0s-ctrl. Log in to k0s-ctrl and from there use ssh k0s-w1. The rules let this connection through. After 30 minutes at the latest, the timer lifts the block.
  • curl reports nothing, and punkt.json is missing: You wrote the query directly into the URL. curl then interprets {…} and […] itself. Pass the query with -G --data-urlencode.
  • The new pod lands on a node without a replica and is cleared away again at once: That happened in the lab too (Drill 3). The HA Controller briefly reported quorum loss there. Wait: the next pod stayed on the node with the replica.
  • You want to exempt only Prometheus from the HA Controller: There is the pod annotation drbd.linbit.com/ignore-fail-over: "" for that (in the values: server.podAnnotations). Then the HA Controller does not evict the pod. In the lab it still released the failed node’s VolumeAttachment (force-detached). Prometheus was back after 7 minutes 39 seconds. For a clean comparison you therefore switch the HA Controller off completely (Drill 5).
  • The worker still carries drbd.linbit.com/lost-quorum after the return: Wait. The HA Controller removes the taint by itself, in the lab a good four minutes after the return.

Checkpoint

Finally you check that everything is back to normal.

Is the HA Controller running again?

# on k0s-ctrl
kubectl -n piraeus-datastore get ds

Expected: ha-controller, linstor-csi-nfs-server and linstor-csi-node each with 3 in DESIRED and READY. The HA Controller is on again.

Does any worker still carry a taint?

# on k0s-ctrl
kubectl get nodes \
  -o custom-columns=NAME:.metadata.name,TAINTS:.spec.taints[*].key

Expected: <none> for all three workers. You have not forgotten an out-of-service taint.

Is any volume faulty?

# on k0s-ctrl
linstor --no-utf8 --no-color resource list --faulty

Expected: an empty table.

Is the block on k0s-w2 really gone? -S lists all rules of the raw table.

# on k0s-ctrl
ssh k0s-w2 sudo iptables -t raw -S

Expected:

-P PREROUTING ACCEPT
-P OUTPUT ACCEPT

What you see: Only the two default policies ACCEPT, no block any more. Check the same on k0s-w1: no rules left in the raw table.

Cleanup

Now you remove Prometheus again. First you delete the Helm installation:

# on k0s-ctrl
helm uninstall prom -n prometheus

Expected:

release "prom" uninstalled

Then you delete the namespace. The PVC disappears with it. The StorageClass has reclaimPolicy: Delete, so LINSTOR then deletes the volume as well.

# on k0s-ctrl
kubectl delete namespace prometheus

Now you check that LINSTOR really deleted the volume:

# on k0s-ctrl
linstor --no-utf8 --no-color resource list

Expected: only linstor_db is left.

The HA Controller and the NFS server stay switched on, as after Day 21.

Test yourself

  1. Why don’t you run Prometheus like the writers from Day 21, over NFS or with two replicas on one volume?
  2. How do you recognise on the failed node that it can no longer write?
  3. What happened to the old instance’s last write attempts when its node came back?
  4. Why does the file /data/lock not protect against two Prometheus instances on two nodes?
  5. The HA Controller forcibly releases a VolumeAttachment (force-detached). Why is this not a dangerous unsafe detach here?
  6. Without the HA Controller, the new pod was still stuck after 15 minutes. What freed it – and what must you check first?

Answers:

  1. The Prometheus TSDB tolerates only one process that writes. The Prometheus documentation advises against NFS. Two instances on the same files would destroy the data. So: one instance, one RWO volume, strategy: Recreate.
  2. drbdsetup status --verbose shows suspended:quorum, quorum:no and blocked:upper. In ps a Prometheus thread hung in state D.
  3. They failed. DRBD demoted the node with force secondary!. The kernel log showed I/O error or Rejected WRITE request. Nothing arrived on the disk or on the new replica.
  4. The new instance found the lock file and replaced it (“A lockfile from a previous execution already existed. It was replaced”). The lock only applies on one machine.
  5. Because DRBD froze the old node beforehand. The HA Controller only acts when DRBD reports that another replica may take over. That is only possible when the old node no longer has quorum.
  6. The out-of-service taint. Before that you must be sure the node no longer writes: it is off, cut off the network or – as shown here – frozen by DRBD.

Interview Note

“How do you make Prometheus highly available without running two instances?” – One instance on an RWO volume with two synchronous replicas, as a Deployment with Recreate. If the node fails, a controller close to the storage decides based on the DRBD quorum: the second replica may take over. The old node is already frozen at that point. In the lab Prometheus was back after just over two minutes, without manual work and with all samples. Without this controller, Kubernetes waits for a manual confirmation – rightly so.

Enterprise Note

  • Fencing belongs in two layers. The DRBD quorum freezes the old writer at the storage level. In production you also require that the old machine is provably off before the volume is attached elsewhere. It is powered off via IPMI/Redfish or the hypervisor. Proxmox VE (HA manager with watchdog) and OpenNebula (hook for the host error that powers off the host before the VMs restart) bring their own mechanisms for this. In the course lab the iptables block stands in for pulling the plug.
  • No unsafe detach. Never forcibly release a volume by hand while the old node might still write. That means: deleting the VolumeAttachment, removing finalizers, deleting the pod with --force. Set the out-of-service taint only after confirmed fencing – even if a script sets it.
  • Two Prometheus instead of one. If you cannot tolerate a gap, run two independent instances, each with its own volume. Both scrape the same targets. Thanos or Mimir merge the data. That is not failover but double bookkeeping – with double the storage and RAM.
  • kube-prometheus-stack creates Prometheus as a StatefulSet via the operator. A Deployment like today’s is not provided for there. On node failure Kubernetes then creates no replacement pod as long as the old …-0 hangs in Terminating. The HA Controller or the out-of-service taint has to free the pod.

Summary

Prometheus is a single-writer service: one TSDB, one writer. You installed it with the chart prometheus-community/prometheus: as a Deployment with strategy: Recreate, on an RWO volume with two DRBD replicas.

  • With the HA Controller: when its node failed, DRBD froze the old instance (suspended:quorum). The HA Controller evicted the pod after 22 seconds and released the volume. After 2 minutes 16 seconds Prometheus ran on the node with the second replica – with all samples.
  • The old node returns: DRBD demoted it and discarded its held writes.
  • Without the HA Controller: Kubernetes rescheduled after 5 minutes 50 seconds but never released the volume. Only the out-of-service taint brought Prometheus back 49 seconds later.

Prometheus’ lock file protected in no case. The fencing always came from DRBD.

Commands at a glance

Command What it does Parameters
helm show values <chart> --version <v> read a chart’s defaults –
helm install prom prometheus-community/prometheus --version 31.0.1 -n prometheus -f <werte> install Prometheus -f values file
sudo k0s ctr -n k8s.io images ls name==<image> check whether an image is on the node name== filter
curl -s -G <url>/api/v1/query --data-urlencode 'query=…' --data-urlencode 'time=…' PromQL query at a fixed point in time -G as GET, --data-urlencode escapes
jq -c '.data.result[] …' <datei> read the result compactly -c one line per result
drbdsetup show --show-defaults <res> effective DRBD options including defaults --show-defaults
drbdsetup status --verbose <res> suspended, quorum, blocked of a replica --verbose
ps -L -o tid,stat,wchan:32,comm -p <pid> threads of a process and their state -L per thread
journalctl -k --since … --grep "…" search the kernel log for patterns --grep pattern
kubectl get events -A --sort-by=.lastTimestamp events of all namespaces, sorted by time -A all namespaces
kubectl taint node <node> node.kubernetes.io/out-of-service=nodeshutdown:NoExecute confirm a failure - at the end removes the taint
helm upgrade linstor-cluster … -f werte-ohne-ha.yaml switch the HA Controller off and on again –

Contents

More