Instana

Instana

The community for performance and observability professionals to learn, to share ideas, and to connect with others.

 View Only

How to reduce PVC size for CNPG PostgreSQL

By Oleg Samoylov posted 02/24/26 04:20 PM

  

Cloud Native Postgres Operator doesn't allow to reduce size of a PVC. The instruction is demonstrating how to use Instana backup mechanism from Instana Custom Edition "Migrating from Custom Edition to Custom Edition" to recreate Cloud Native PostgreSQL cluster with smaller size of PVCs. The instruction was tested on OpenShift cluster with Cloud Native PostgeSQL.

Step 1. Switch Instana to Maintenance mode

Switch Instana backend to maintenance mode to avoid loss of changes in configuration data:
oc -n instana-core patch core instana-core --type=merge -p '{"spec":{"operationMode": "maintenance"}}'

Step 2. Dump Postgres datastore

In our case we have instana unit tenant0-unit0 which is in the namespace instana-units. We will be using the values to dump data from the selected unit. In case of many units, we need to dump each. Execute the following command to dump unit tenant0-unit0:
oc instana dump config-data --unit tenant0-unit0 --unit-namespace instana-units
for more details refer to IBM documentation Chapter "Migrating from Custom Edition to Custom Edition".

The output of the command includes the file for example dump-20260224102830.tar.gz that we will use to import postgres data to a new cluster:
2026/02/24 10:42:19 INFO Instana config data was successfully dumped to 'dump-20260224102830.tar.gz'

Step 3. Delete Cloud Native PostgreSQL cluster

Once we have dump of all units, we can delete CNPG cluster, but first let's save current configuration of the cluster first:
oc get cluster postgres -n instana-postgres -o yaml > postgres.yaml

From the postgres.yaml file delete temporal data:
- metadata.annotations
- metadata.creationTimestamp
- metadata.generation
- metadata.resourceVersion
- metadata.uid
- status
vi postgres.yaml
And set storage size to needed value.

We're ready to delete existing CNPG cluster, it will take some time:
oc delete cluster postgres -n instana-postgres
watch "oc get pods -n instana-postgres"
Cluster deletion will keep the password secret intact, so there will be no need to care of changing postgres passwords in Instana backend.

Step 4. Create New Cloud Native PostgreSQL cluster

Once all postgres pods gone, let's create new cluster with new PVC size:
oc apply -f postgres.yaml

Step 5. Restore Cloud Native PostgreSQL data to a new cluster

When all postgres pods are up and running, restore data from existing dumps:
oc instana migrate -f dump-20260224102830.tar.gz

Step 6. Switch Instana to Normal mode

Change Instana operation mode to normal:
oc -n instana-core patch core instana-core --type=merge -p '{"spec":{"operationMode": "normal"}}'

---

Relevant documentation:
- https://www.ibm.com/docs/en/instana-observability/current?topic=edition-migrating-from-custom-custom


#Infrastructure
#Kubernetes
#Self-Hosted

0 comments
103 views

Permalink