The module lifecycle stage: General Availability
Migration from operator-postgres to managed-postgres (Deckhouse Observability Platform version 1.10)
Starting from Deckhouse Observability Platform version 1.10, the managed-postgres module is used instead of operator-postgres. Support for operator-postgres will be removed in Deckhouse Observability Platform version 1.12.
Important: If you see the
NeedMigrationPostgresalert, follow this guide to migrate your PostgreSQL database.
Prerequisites
- Ensure you have access to the Kubernetes cluster with
kubectl
Migration Steps
-
Enable the
managed-postgresmodule:d8 system module enable managed-postgres -
Wait for the new PostgreSQL database to be provisioned. This may take several minutes as it requires two module reconciliation cycles:
echo "Waiting for managed-postgres-credentials secret..." until kubectl -n d8-observability-platform get secret managed-postgres-credentials &>/dev/null; do sleep 10 done echo "Done" -
Save the current replica counts and stop the
backendandalertgatecomponents:export BACKEND_REPLICAS=$(kubectl -n d8-observability-platform get deploy backend -o jsonpath='{.spec.replicas}') export ALERTGATE_REPLICAS=$(kubectl -n d8-observability-platform get deploy alertgate-receiver -o jsonpath='{.spec.replicas}') kubectl -n d8-observability-platform scale deploy backend alertgate-receiver alertgate-sender alertgate-api --replicas=0 -
Export the password for the new PostgreSQL instance:
export PGPASSWORD=$(kubectl -n d8-observability-platform get secret managed-postgres-credentials \ -o jsonpath='{.data.password}' | base64 -d) -
Migrate the database from
operator-postgrestomanaged-postgres:kubectl -n d8-observability-platform exec -i \ $(kubectl -n d8-observability-platform get po -l spilo-role=master -o name) \ -- /usr/lib/postgresql/14/bin/pg_dump -U dop --no-privileges --no-owner dop | \ kubectl -n d8-observability-platform exec -i \ $(kubectl -n d8-observability-platform get po -l cnpg.internal.managed.deckhouse.io/instanceRole=primary -o name) \ -- sh -c "PGPASSWORD='$PGPASSWORD' psql -h localhost -U dop dop" -
Mark the migration as completed:
kubectl -n d8-observability-platform create cm postgres-migrated-completed -
Restore the
backendandalertgatecomponents:kubectl -n d8-observability-platform scale deploy backend --replicas=$BACKEND_REPLICAS kubectl -n d8-observability-platform scale deploy alertgate-receiver alertgate-sender alertgate-api --replicas=$ALERTGATE_REPLICAS -
Verify that the Deckhouse Observability Platform web interface is accessible and opens without errors. Workspaces and projects are displayed. Dashboards open without errors, and metrics data is correct.
Rollback (if needed)
If you encounter problems after migration, you can switch back to operator-postgres:
-
Save the current replica counts and stop the
backendandalertgatecomponents:export BACKEND_REPLICAS=$(kubectl -n d8-observability-platform get deploy backend -o jsonpath='{.spec.replicas}') export ALERTGATE_REPLICAS=$(kubectl -n d8-observability-platform get deploy alertgate-receiver -o jsonpath='{.spec.replicas}') kubectl -n d8-observability-platform scale deploy backend alertgate-receiver alertgate-sender alertgate-api --replicas=0 -
Remove the migration marker:
kubectl -n d8-observability-platform delete cm postgres-migrated-completed -
Restore the
backendandalertgatecomponents:kubectl -n d8-observability-platform scale deploy backend --replicas=$BACKEND_REPLICAS kubectl -n d8-observability-platform scale deploy alertgate-receiver alertgate-sender alertgate-api --replicas=$ALERTGATE_REPLICAS
Cleanup (after successful migration)
After verifying that the migration was successful, disable the operator-postgres module. The operator will stop running, but CRDs and the old PostgreSQL CR will remain in the cluster — this is harmless. Full cleanup of old resources will be performed automatically in version 1.12.
d8 system module disable operator-postgres