Skip to content
Mementropy
RecipesHomelab recipesReference

Moving a Docker Compose service and its Postgres to K3s

Secret parity, dump and restore, cutover, then a reversible shutdown of the old host.

By Ryan Hammang

Moving a stateful Compose service to K3s without losing data or leaving clients behind.

  1. Secret parity. Compare each secret in the old .env with the secrets manager by hash, not by eye:
Terminal window
printf %s "$VALUE" | sha256sum
  1. Database. Deploy a Postgres StatefulSet for the service (pgvector image if it needs vectors). Dump the old database with pg_dump -Fc and restore with pg_restore.

  2. Verify. Compare table counts and row counts on the important tables (see the scratch-restore recipe).

  3. Deploy the service with its secrets from the operator and its database URL pointing at the new StatefulSet.

  4. Smoke test a real request, and check traces and metrics arrive.

  5. Cut over clients. Update host entries and client configs.

  6. Add to backups and monitoring.

  7. Quiesce the old host. Unload old backup jobs. docker stop the containers. Keep the volumes until you’re sure.

  • Row counts match.
  • Real requests succeed against the new service.
  • The old containers are stopped and nothing reports errors.
  • Resource limits that were fine under Docker can choke a service under a Kubernetes CPU limit. Watch latency after the move (see the reranker recipe).