Brume · Docs
Maintenance

Troubleshoot an instance

Seven common incidents on a K3s instance: symptom, diagnosis, and resolution for each.

In brief

Seven incidents encountered by a K3s instance, in symptom -> diagnosis -> resolution form. In commands, <instance> is global.instanceName or, when that value is empty, the Helm release name; <namespace> is the configured namespace, whose chart default is misty. <pg-owner> is pg.owner, whose default value is <instance>. All commands run with the instance kubeconfig (export KUBECONFIG=...) in that application namespace.

IncidentVisible symptomPage
Node Ready but sites unreachableNode Ready, sites hosted on it silentRouting
Pod in CrashLoopBackOffA pod restarts in a loopCrash pod
Migration crashloop must be ownerBackend crashloops at boot, log FATAL: must be ownerOwner migration
Primary and replica desynchronizedPostgreSQL replication lagReplication
Node NotReadyNode NotReady in the listNode
Manual primary failoverNeed to promote a replicaFailover
Processing queue blockedFile indexing stallsQueue

Cluster access

The kubeconfig lives in your secret manager. Retrieve it into a temporary file, export KUBECONFIG, operate, then delete the file. Verify access with kubectl get nodes and kubectl get pods -n <namespace> before any diagnosis.

The routing procedure below uses Cloudflare Tunnel as an example of upstream access control. Cloudflare is not a product prerequisite: any equivalent upstream access control works, and the cloudflared commands apply only to this example.

1. Node Ready but sites unreachable

Symptom. The node appears Ready in kubectl get nodes, but the sites hosted on it do not respond.

Cause. In this Cloudflare Tunnel example, Traefik (DaemonSet hostNetwork) did not restart on the node, or cloudflared is not running. ServiceLB is disabled: Traefik must listen on each worker node for traffic to arrive, and cloudflared is the entry path from Cloudflare Tunnel. Without one of the two, the node is invisible to the load balancer.

Check that Traefik runs on all workers. The list must show one pod per worker node (not on the arbiter).

kubectl get pods -n kube-system -l app.kubernetes.io/name=traefik -o wide

Check that ports 80 and 443 are listening on the node.

ssh <node> "ss -tlnp | grep -E ':(80|443) '"

In this example, check cloudflared.

ssh <node> "systemctl status cloudflared --no-pager"

Test routing from the node itself.

curl -s -o /dev/null -w '%{http_code}' -H 'Host: www.<your-domain>' http://localhost

Resolution. In this example, if cloudflared is stopped: systemctl start cloudflared. If Traefik is missing from the node, check taints (kubectl describe node <name>) and events (kubectl get events -n kube-system): a residual taint prevents the DaemonSet from being scheduled there.

2. Pod in CrashLoopBackOff

Symptom. A pod restarts in a loop, state CrashLoopBackOff.

Diagnosis. Read the description (events, reason for the last kill), then logs from the previous container, which contain the error that caused the crash.

kubectl describe pod <name> -n <namespace>
kubectl logs <name> -n <namespace> --previous

Resolution. Depends on the error read. If the pod is a backend crashlooping on a migration, see the next incident.

3. Migration crashloop: must be owner of relation

Symptom. A new backend pod crashloops at boot. The logs show:

Applying NNN_xxxxx.sql...
FATAL: must be owner of relation <table>

Cause. The migration attempts an ALTER TABLE / DROP TRIGGER / DROP INDEX on a table that does not belong to <pg-owner> (the application user, which also runs migrations). Some tables were created by postgres during a seed or restore and were never reassigned. The runner runs as <pg-owner>, which has data rights but not structure rights on these tables.

Identify the PostgreSQL primary.

kubectl get pods -n <namespace> -l cnpg.io/cluster=<instance>-pg -L cnpg.io/instanceRole

List public schema tables owned by postgres.

kubectl exec -n <namespace> <pg-primary> -c postgres -- psql -U postgres -d brume -c \
  "SELECT tablename FROM pg_tables WHERE schemaname='public' AND tableowner='postgres';"

Reassign all these tables to <pg-owner>, in a transaction, on the primary.

kubectl exec -n <namespace> <pg-primary> -c postgres -- psql -U postgres -d brume -v ON_ERROR_STOP=1 -c \
  "BEGIN; DO \$\$ DECLARE r record; BEGIN FOR r IN SELECT tablename FROM pg_tables WHERE schemaname='public' AND tableowner='postgres' LOOP EXECUTE format('ALTER TABLE public.%I OWNER TO \"<pg-owner>\"', r.tablename); END LOOP; END \$\$; COMMIT;"

Delete the crashlooping backend pod so it retries migrations.

kubectl delete pod -n <namespace> <crashlooping-pod>

Do not reassign extension functions

Functions in the public schema owned by postgres belong to installed extensions (pg_trgm, pgvector: vector_*, halfvec_*, gtrgm_*). They must remain owned by postgres, otherwise the extensions break. Reassign tables only. If a migration wants to delete a specific postgres-owned application function (e.g. enqueue_embedding_job), reassign only that one: ALTER FUNCTION public.enqueue_embedding_job() OWNER TO "<pg-owner>";.

The Upgrade page covers the context of forward-only migrations and when this trap occurs.

4. Primary and replica PostgreSQL desynchronized

Symptom. Replication lag between primary and replica grows.

Diagnosis. CloudNativePG status gives the lag and state of each instance.

kubectl cnpg status <instance>-pg -n <namespace>

Resolution. If the lag is significant, check the network between nodes and disk space on the replica: a full disk on the replica blocks WAL application. Detailed replication state is readable directly:

kubectl exec -n <namespace> <instance>-pg-1 -- psql -c "SELECT * FROM pg_stat_replication;"

5. Node NotReady

Symptom. A node appears NotReady in kubectl get nodes.

Diagnosis. The node description indicates the condition involved (network, disk, memory). System commands on the node confirm it.

kubectl describe node <name>
ssh <node> "dmesg | tail -20"
ssh <node> "df -h"
ssh <node> "free -m"

Resolution. Depending on the cause: free disk space (df -h), address memory pressure (free -m), or a hardware incident surfaced by dmesg. After recovery, check that the node rejoins the cluster and, in the Cloudflare Tunnel example, that cloudflared is running (systemctl status cloudflared).

6. Manual PostgreSQL primary failover

Symptom. Need to promote a replica to primary, for a test or for maintenance on the current primary.

Diagnosis. First check who is the current primary.

kubectl get cluster <instance>-pg -n <namespace> -o jsonpath='{.status.currentPrimary}'

Resolution. Promote a replica instance. CloudNativePG switches the role and redirects the <instance>-pg-rw service.

kubectl cnpg promote <instance>-pg <instance>-pg-2 -n <namespace>

Then verify the cluster state:

kubectl cnpg status <instance>-pg -n <namespace>

7. Drain a blocked processing queue

Symptom. File indexing stalls, jobs remain in todo without progressing.

Diagnosis. The file pipeline runs on Procrastinate, a PostgreSQL-native task queue. Inspect current and pending jobs:

SELECT id, task_name, status, attempts, queue_name, scheduled_at
FROM procrastinate_jobs
WHERE status IN ('todo', 'doing')
ORDER BY id DESC
LIMIT 50;

List failed jobs over the last day:

SELECT id, task_name, attempts, args
FROM procrastinate_jobs
WHERE status = 'failed' AND scheduled_at > now() - interval '1 day'
ORDER BY id DESC;

Resolution. Cancel pending jobs on the affected queue (manual cancellation).

UPDATE procrastinate_jobs SET status = 'cancelled'
WHERE status = 'todo' AND queue_name = 'processing';

See also

Details of the two queues (processing for document conversion, embedding for embedding calls) and their sizing are described in Monitor your instance. The architecture that keeps the queue in PostgreSQL is in Architecture.

On this page