Switching to the Official Postgres Image
If you want to move from the Bitnami Postgres image to the official Postgres image, set:
components:
database: false
postgres: true
global:
database:
url: "jdbc:postgresql://{{ .component.prefix }}postgres:5432/{{ .this.database.name }}"
in the values file. This will instantiate the official Postgres image. All values are identical.
You can also run both components side-by-side to perform migrations.
Make sure you set the database URL to the new DB when you are done.
Migration Scenario
- Add the postgres component
components:
database: true
postgres: true
- Copy the database from the
databasecomponent to thepostgrescomponent (single DB)
Because default-deny egress is enabled for the instance, allow temporary egress for the migration client:
kubectl apply -n lab -f - <<'EOF1'
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: sample-postgres-allow-migration-egress
spec:
podSelector:
matchLabels:
nplus/group: sample-postgres
nplus/type: core
policyTypes:
- Egress
egress:
- to:
- podSelector:
matchLabels:
nplus/group: sample-postgres
nplus/type: database
- to:
- podSelector:
matchLabels:
nplus/group: sample-postgres
nplus/type: postgres
EOF1
kubectl run -n lab pg-client --rm -i --image=postgres:17 \
--labels nplus/group=sample-postgres,nplus/type=core -- \
sh -c 'export PGPASSWORD=nscale; \
pg_dump -h sample-postgres-database -U nscale -Fc nscale | \
pg_restore -h sample-postgres-postgres -U nscale -d nscale --clean --if-exists'
Clean up the temporary egress rule:
kubectl delete -n lab networkpolicy sample-postgres-allow-migration-egress
- Set nappl to use the new postgres component
global:
database:
url: "jdbc:postgresql://{{ .component.prefix }}postgres:5432/{{ .this.database.name }}"
- Remove the old database component
components:
database: false
postgres: true