By the end of November the Contabo cluster had everything Git could give it. Git doesn't hold the data: jithendar.com's posts and settings in PostgreSQL, the models and keys I added to LiteLLM by hand, Grafana's, Qdrant's and Open WebUI's volumes, and a few Secrets that existed only on mk4.

This part shows how I moved it with one GitHub Actions workflow, "Migrate cluster": the scripts, the real output of the trial run on 30 November, and the cutover plan with its rollback. What it moves is listed in one settings file, so you can reuse it between any two k3s clusters.

This is part 5 of a six-part series on moving jithendar.com's k3s cluster from Hetzner to Contabo. Part 1 (opens in a new tab) has the plan; Part 4 (opens in a new tab) shows how GitHub Actions reaches the cluster.

Only what Git doesn't have

Anything Git can build is rebuilt on the new cluster by its own pipeline. The migration moves only the rest, and the rest is listed in cluster-migration/migrate.conf in k8s-deployments:

Bash
DATABASES=(
  jithendar   # jithendar.com
  litellm     # LiteLLM: the models, keys and teams added by hand in its Admin UI
  moks        # MOKS SRE, for a later redeploy
)

VOLUMES=(
  monitoring/grafana            # Grafana's database: users and the "Public" org (grafana_public.org_id = 2)
  rag/qdrant-storage-qdrant-0   # vector collections (~140 MB)
  rag/open-webui-data           # Open WebUI users, chats and uploads (~890 MB, the slowest)
)

SECRETS=(
  cert-manager/cloudflare-api-token   # Let's Encrypt DNS-01 for the certificates
  jithendar/jithendar-com-env         # SETTINGS_ENCRYPTION_KEY: decrypts the R2, email and sign-in settings in the database
  # ... 16 more
)

Secrets made by Terraform, Helm or an operator aren't listed: the new cluster makes its own. Prometheus history and Valkey's caches stay behind.

I used pg_dump and pg_restore, not replication between the clusters. [ASK JITHENDAR: why dump and restore rather than a CloudNativePG replica cluster? The size (58 MB), the Contabo API being reachable only through SSH, or keeping it simple?]

One step per run

.github/workflows/migrate-cluster.yml only runs by hand, from master, one run at a time:

YAML
on:
  workflow_dispatch:
    inputs:
      step:
        type: choice
        options: [check, secrets, stop old, stop new, databases, volumes, start old, start new, compare]

concurrency:
  group: cluster-migration
  cancel-in-progress: false

Each step leaves its own log, and I start the next one. The logs are public, so a sed masks IPv4 addresses in everything the script prints.

cluster-migration/connect.sh merges both kubeconfigs into one file with contexts mk4 and contabo-k3s. Contabo's API only answers my admin addresses, so for it the script opens an SSH tunnel to the control plane and keeps the API's real name for TLS (tls-server-name). It tunnels as root with the admin kubeconfig, not as the pipelines' kube-tunnel user: it reads Secrets everywhere and runs commands in the database pod. Every run starts with:

mk4: Kubernetes v1.37.2+k3s1
contabo-k3s: Kubernetes v1.37.2+k3s1

Nothing big goes through one kubectl exec

The header of cluster-migration/lib.sh explains the design:

Bash
# The k3s API server is reached over the internet and cuts large or long `kubectl exec` streams, so nothing big goes
# through one exec: pg_dump / pg_restore run detached inside the database pod, and files move in small chunks, each
# checked, with the whole file verified by SHA-256 at the end.

So backup.sh starts pg_dump as a detached job inside the CloudNativePG primary, after pg_dumpall --globals-only for the roles. It then reads the finished archive once to prove it's whole:

Bash
# pg_restore -f /dev/null reads the whole archive, so an unreadable dump is caught here. One dump in the pod at a time.
if pod_job "dump-$db" 'pg_dump -U postgres -Fc -f "$1" -d "$2"; pg_restore -f /dev/null "$1"' "$RDIR/$db.dump" "$db" \
   && download "$RDIR/$db.dump" "$WORK/$db.dump"; then

download pulls the file in 2 MB pieces, retries each piece up to eight times, and compares the SHA-256 with the one computed in the pod. On Contabo, restore.sh uploads it the same way and runs pg_restore --single-transaction --exit-on-error, then ANALYZE.

An empty target is restored in place, so a failure leaves it empty. A target with data is never overwritten: the dump goes into a new database beside it, then a job in the pod swaps the names and keeps the old one as <db>_before_<time>. The platform Terraform creates the roles and empty databases first.

Stopping things so they can be started again

stop old and stop new stop everything that writes to these databases and volumes or has effects outside the cluster:

Bash
STOP=(
  argocd/application/moks-rag-stack
  argocd/application/moks-rag-qdrant
  jithendar/cronjob/seo-flow-dispatcher    # starts a pod per flow run
  rag/cronjob/repo-index
  jithendar/scaledobject/jithendar-com     # the site's web pods (KEDA keeps at least 2)
  jithendar/deployment/jithendar-com-worker
  # ... seo-agent, practice, litellm, rag-api, open-webui, qdrant, grafana
)

Argo CD goes first, or self-heal would start the rest again. The site is paused through KEDA, which would undo a plain scale to 0. Before changing anything, stop_item in migrate.sh saves the current value on the object, in the annotation cluster-migration/stopped:

Bash
case "$KIND_" in
  application)  KC "$ctx" -n "$NS_" patch "$r" "$NAME_" --type merge -p '{"spec":{"syncPolicy":{"automated":null}}}' >/dev/null ;;
  cronjob)      KC "$ctx" -n "$NS_" patch "$r" "$NAME_" -p '{"spec":{"suspend":true}}' >/dev/null ;;
  scaledobject) KC "$ctx" -n "$NS_" annotate "$r" "$NAME_" autoscaling.keda.sh/paused-replicas=0 --overwrite >/dev/null ;;
  *)            KC "$ctx" -n "$NS_" scale "$r" "$NAME_" --replicas=0 >/dev/null ;;
esac

start puts back exactly that, from any later run, in reverse order; stopping twice never loses it.

How I ran the move: round-robin first

I used round-robin DNS at Cloudflare and started deploying applications. The workers' three proxied A records joined mk4's record when the Create Contabo k3s apply finished at 07 UTC on 30 November. Cloudflare picks a record per request and retries another if a worker doesn't answer, so each application I deployed on Contabo started taking visitors beside mk4.

At 12 UTC the secrets step (run 46422571172) added the namespace labels Contabo lacked and copied 15 Secrets; the platform workflow had made the other three. Then came a trial databases run, with mk4 still serving (run 46423872428, trimmed):

[12:59:53] WARNING: nothing is stopped on mk4: what is written after the backup will not reach contabo-k3s
[13:00:12] jithendar
[13:00:55]   ok   22M in 43s
[13:00:56] litellm
[13:01:06]   ok   360K in 10s
[13:01:08] moks
[13:02:12]   ok   36M in 64s
[13:02:14] backup complete: /home/runner/work/_temp/backups/2026-11-30_125959 (58M)
[13:03:48]   ok   jithendar restored, 147 tables
[13:04:13]   ok   litellm restored, 120 tables
[13:05:37]   ok   moks restored, 81 tables

Under six minutes in all. The jithendar.com deploy to Contabo finished at 13 UTC (run 46429843245). From then on the Contabo site ran against this 13 copy, and mk4 against its own database.

So anything written on Contabo before the final copy exists only there, and anything written on mk4 after 13 reaches Contabo only with the final copy. That copy doesn't destroy Contabo's writes: the target has data by then, so restore.sh restores beside it and keeps the old database as <db>_before_<time> with connections disabled. [ASK JITHENDAR: was anything written on Contabo during the round-robin window carried over, or dropped?] [ASK JITHENDAR: why were two databases for that window acceptable?]

How the Migrate cluster workflow moves data from mk4 to contabo-k3s, and the cutover. At the top, GitHub Actions: Migrate cluster, started by hand, one step per run, from master only. It runs on an ubuntu-24.04-arm runner, where connect.sh builds one kubeconfig with contexts mk4 and contabo-k3s. On the left, mk4 on Hetzner (arm64): its API is reached directly; the PostgreSQL primary runs pg_dumpall for the roles and pg_dump in custom format for each database, checked with pg_restore to /dev/null, detached inside the pod; stop old and start old switch Argo CD auto-sync off, suspend CronJobs, pause KEDA and scale to 0, keeping the old value in the annotation cluster-migration/stopped. In the middle, lib.sh copies dumps and volume archives in 2 MB pieces over kubectl exec, each piece checked and the whole file checked by SHA-256. On the right, contabo-k3s on Contabo (amd64): its API answers only the admin addresses, so the runner reaches it through an SSH tunnel; its primary restores an empty database in a single transaction, or restores beside one with data and swaps the names, keeping the old copy as db_before_time. Below, in red, the eight cutover steps, from stop old to deleting mk4-edge's A record at Cloudflare, with the site down for about 30 to 45 minutes, and the rollback: point DNS back at mk4-edge, then start old; anything written on Contabo meanwhile is lost. A note: before the cutover the workers' records join mk4's in Cloudflare's round-robin and the Contabo apps run on the 13 UTC trial copy of 30 November while mk4 keeps serving.

The cutover

The plan in cluster-migration/README.md puts the site down for about 30 to 45 minutes, one workflow run per step:

  1. stop old (the site goes down), stop new, databases, volumes, start new, compare.
  2. Smoke tests: the admin sign-in, images from R2, Grafana's Public org.
  3. DNS: delete mk4-edge's record from jithendar.com at Cloudflare, so only the workers' records stay.
  4. Pipelines deploy to Contabo only; later, drop the _before_ databases.

The DNS step is a delete by hand because Terraform never owned mk4's record: contabo-k3s/terraform/cloudflare.tf leaves records it didn't make "in the rotation beside the workers until they are deleted at Cloudflare". Because the records are proxied, deleting mk4's changes where Cloudflare sends requests, not what anyone's resolver cached.

The cutover started at [ASK JITHENDAR: date and time]. The site was down for [ASK JITHENDAR: downtime seen, from stop old to Contabo's first good response]. The volumes took [ASK JITHENDAR: time for Grafana, Qdrant, Open WebUI]. Smoke tests: [ASK JITHENDAR: which, and results]. DNS: [ASK JITHENDAR: when mk4-edge's record went, and were www, postgres. and redis. moved too]. [ASK JITHENDAR: what went wrong, with the error text.]

The README's rollback, good until Hetzner is deleted: "point DNS back, then start old. Anything written on Contabo meanwhile is lost." I tested the plan and the rollback beforehand. [ASK JITHENDAR: when and how, and how long the rollback took?] [ASK JITHENDAR: was it used in the real cutover?]

Problems I hit

The volumes refused to copy. My first volumes run (46423763796) stopped:

[12:58:54] monitoring/grafana
  in use on mk4 by: grafana-5945b7687b-gtbwv (stop it first: stop old|new)
[12:58:55]   FAIL  monitoring/grafana
ERROR: not copied: monitoring/grafana rag/qdrant-storage-qdrant-0 rag/open-webui-data

That's the script doing its job: copy_volume refuses a claim that a running pod uses on either cluster. The README's trial order fixes it: stop old with the two moks-rag Argo CD Applications, Open WebUI, Qdrant and Grafana as items, then volumes, then start old. Those tools are down on mk4 for about 20 minutes. [ASK JITHENDAR: were the volumes copied later in the trial, and how long did each take?]

The trial copy is old the moment it lands. The same databases run warned nothing is stopped on mk4: what is written after the backup will not reach contabo-k3s. Expected in a trial, and the reason the cutover stops both sides first.

Verify it works

The restore log is the first check: 147, 120 and 81 tables, counted from information_schema.tables. Run the same count on Contabo's primary any time.

compare lists every Deployment, StatefulSet, DaemonSet and CronJob on mk4 that is missing or not ready on Contabo. Expected last line:

[hh:mm:ss] <N> workloads on mk4; 0 problem(s) on contabo-k3s

To test one worker without DNS, as the README does:

Bash
curl --resolve jithendar.com:443:<worker address> https://jithendar.com/

Expected output: the home page's HTML, over the gateway's Let's Encrypt certificate, the one Cloudflare checks in Full (strict) mode. After the cutover, Cloudflare's DNS page for jithendar.com should list three proxied A records with comments ending in contabo-k3s (Terraform): worker-1 to worker-3, and nothing for mk4-edge.

Key takeaways

  • Move only what Git doesn't have, and list it in one file.
  • Don't stream big files through one kubectl exec over the internet: dump in the pod, copy checked pieces.
  • Restore beside, then swap: a failed restore never touches the live database.
  • Run a trial while the old cluster serves: it shows what needs stopping and how long the copy takes.
  • Round-robin DNS let Contabo take visitors early, at the price of two databases until the final copy.

Previous: Part 4: How GitHub Actions reaches the cluster now (opens in a new tab) · Next: Part 6: What the cluster costs, and what the move taught me (opens in a new tab)