Public Information

This commit is contained in:
2026-03-10 07:33:55 +01:00
commit 4c9519166e
499 changed files with 125937 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
# 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
```

45
samples/postgres/build.sh Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/bash
#
# This sample script builds the example as described. It is also used to build the test environment in our lab,
# so it should be well tested.
#
# Make sure it fails immediately, if anything goes wrong
set -e
# -- ENVironment variables:
# CHARTS: The path to the source code
# DEST: The path to the build destination
# SAMPLE: The directory of the sample
# NAME: The name of the sample, used as the .Release.Name
# KUBE_CONTEXT: The name of the kube context, used to build this sample depending on where you run it against. You might have different Environments such as lab, dev, qa, prod, demo, local, ...
# Check, if we have the source code available
if [ ! -d "$CHARTS" ]; then
echo "ERROR Building $SAMPLE example: The Charts Sources folder is not set. Please make sure to run this script with the full Source Code available"
exit 1
fi
if [ ! -d "$DEST" ]; then
echo "ERROR Building $SAMPLE example: DEST folder not found."
exit 1
fi
if [ ! -d "$CHARTS/instance" ]; then
echo "ERROR Building $SAMPLE example: Chart Sources in $CHARTS/instance not found. Are you running this script as a subscriber?"
exit 1
fi
# Set the Variables
SAMPLE="postgres"
NAME="sample-$SAMPLE"
# Output what is happening
echo "Building $NAME"
# Create the manifest
mkdir -p $DEST/instance
helm template --debug \
--values $SAMPLES/application/empty.yaml \
--values $SAMPLES/environment/$KUBE_CONTEXT.yaml \
--values $SAMPLES/resources/$KUBE_CONTEXT.yaml \
--values $SAMPLES/$SAMPLE/values.yaml \
$NAME $CHARTS/instance > $DEST/instance/$SAMPLE.yaml

View File

@@ -0,0 +1,10 @@
components:
database: false
postgres: true
global:
database:
url: "jdbc:postgresql://{{ .component.prefix }}postgres:5432/{{ .this.database.name }}"
nappl:
waitFor:
- "-service {{ .component.prefix }}postgres.{{ .Release.Namespace }}.svc.cluster.local:5432 -timeout 600"