91 lines
2.0 KiB
Markdown
91 lines
2.0 KiB
Markdown
|
|
# 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
|
||
|
|
|
||
|
|
1. Add the postgres component
|
||
|
|
|
||
|
|
```
|
||
|
|
components:
|
||
|
|
database: true
|
||
|
|
postgres: true
|
||
|
|
```
|
||
|
|
|
||
|
|
2. Copy the database from the `database` component to the `postgres` component (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
|
||
|
|
```
|
||
|
|
|
||
|
|
3. Set nappl to use the new postgres component
|
||
|
|
|
||
|
|
```
|
||
|
|
global:
|
||
|
|
database:
|
||
|
|
url: "jdbc:postgresql://{{ .component.prefix }}postgres:5432/{{ .this.database.name }}"
|
||
|
|
```
|
||
|
|
|
||
|
|
4. Remove the old database component
|
||
|
|
|
||
|
|
```
|
||
|
|
components:
|
||
|
|
database: false
|
||
|
|
postgres: true
|
||
|
|
```
|