Skip to content

Commit 7908d4a

Browse files
committed
Enhance migration guide with detailed backup instructions for Keycloak and pgAdmin
1 parent 70ac1df commit 7908d4a

1 file changed

Lines changed: 81 additions & 12 deletions

File tree

migration-guides/GENERIC_BITNAMI_TO_CLOUDPIRATES_KEYCLOAK_MIGRATION_GUIDE.md

Lines changed: 81 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,95 @@ This guide provides generic migration instructions for any project using the Bit
2424

2525
### Step 1: Backup Current Installation
2626

27+
#### 1a. Export Realm from Keycloak Admin Console
28+
2729
```bash
2830
# Get the Keycloak admin password
2931
KEYCLOAK_PASSWORD=$(kubectl get secret <release-name>-keycloak -n <namespace> \
3032
-o jsonpath="{.data.admin-password}" | base64 --decode)
3133

32-
# Port forward to Keycloak
34+
# Port forward to Keycloak (skip if using ingress)
3335
kubectl port-forward svc/<release-name>-keycloak 8080:80 -n <namespace> &
36+
```
37+
38+
1. Navigate to the Keycloak Admin Console (`http://localhost:8080/auth/admin` or your ingress URL)
39+
2. Login with admin credentials
40+
3. Go to **Realm Settings → Action → Partial Export**
41+
4. Select all options and export to JSON
42+
5. Save the JSON file (e.g., `realm-export.json`)
43+
44+
#### 1b. Backup Database Using pgAdmin
45+
46+
> 💡 **Tip**: If your Helm chart already deploys pgAdmin as a subchart (e.g., `pgadmin4.enabled: true`), you can use that instance directly — it already has network access to the PostgreSQL service within the cluster.
47+
>
48+
> Example subchart configuration:
49+
> ```yaml
50+
> pgadmin4:
51+
> enabled: true
52+
> env:
53+
> email: admin@example.com
54+
> password: admin-password
55+
> ingress:
56+
> enabled: true
57+
> hosts:
58+
> - host: pgadmin.example.com
59+
> paths:
60+
> - path: /
61+
> pathType: Prefix
62+
> ```
63+
64+
**Option A — pgAdmin runs inside the same cluster (recommended):**
65+
66+
Since pgAdmin can resolve Kubernetes service names directly, no port-forward is needed:
67+
68+
| Field | Value |
69+
|-------|-------|
70+
| **Host name/address** | `<release-name>-postgresql` (Kubernetes service name) |
71+
| **Port** | `5432` |
72+
| **Maintenance database** | your Keycloak database name |
73+
| **Username** | your Keycloak database user |
74+
| **Password** | *(retrieve from your Kubernetes secret, see below)* |
75+
76+
**Option B — pgAdmin runs outside the cluster:**
77+
78+
Create a port-forward first, then connect to `localhost`:
79+
80+
```bash
81+
kubectl port-forward svc/<release-name>-postgresql 5432:5432 -n <namespace> &
82+
```
3483
35-
# Export realm from Admin Console:
36-
# 1. Navigate to http://localhost:8080/auth/admin
37-
# 2. Login with admin credentials
38-
# 3. Go to Realm Settings → Action → Partial Export
39-
# 4. Select all options and export to JSON
40-
# 5. Save the JSON file
84+
| Field | Value |
85+
|-------|-------|
86+
| **Host name/address** | `localhost` |
87+
| **Port** | `5432` |
88+
| **Maintenance database** | your Keycloak database name |
89+
| **Username** | your Keycloak database user |
90+
| **Password** | *(retrieve from your Kubernetes secret, see below)* |
4191
42-
# If using dedicated PostgreSQL, backup the database:
43-
kubectl exec <postgresql-pod> -n <namespace> -- \
44-
pg_dump -U keycloak -d keycloak > keycloak_backup.sql
92+
To retrieve the database password from your Kubernetes secret:
93+
```bash
94+
kubectl get secret <your-db-secret> -n <namespace> -o jsonpath='{.data.<password-key>}' | base64 -d
4595
```
4696
97+
**Register the server and create the backup:**
98+
99+
1. Open pgAdmin and log in
100+
2. Right-click **Servers** → **Register** → **Server...**
101+
3. In the **General** tab, set a name (e.g., `Keycloak PostgreSQL`)
102+
4. In the **Connection** tab, fill in the values from the table above
103+
5. Click **Save**
104+
6. In the browser tree, expand **Servers → Keycloak PostgreSQL → Databases**
105+
7. Right-click your database → **Backup...**
106+
8. Configure the backup:
107+
- **Filename**: `keycloak_backup` (pgAdmin will add the extension)
108+
- **Format**: `Custom` (recommended, supports selective restore) or `Plain` (SQL text)
109+
- **Encoding**: `UTF8`
110+
9. *(Optional)* In the **Data/Objects** tab:
111+
- Enable **Include CREATE DATABASE statement** for a full restore option
112+
- Enable **Use Column Inserts** for maximum compatibility
113+
10. Click **Backup**
114+
11. Verify the backup completed successfully in the pgAdmin notifications panel (bell icon, bottom-right)
115+
47116
### Step 2: Update Chart.yaml
48117
49118
Change the Keycloak dependency:
@@ -358,7 +427,7 @@ keycloak:
358427
## Migration Checklist
359428
360429
- [ ] Backup existing realm data (export from Admin Console)
361-
- [ ] Backup database (if applicable)
430+
- [ ] Backup database using pgAdmin (or equivalent tool)
362431
- [ ] Update `Chart.yaml` dependency
363432
- [ ] Update `values.yaml` configuration structure
364433
- [ ] Create/update database secret with `db-username`/`db-password` keys
@@ -439,4 +508,4 @@ keycloak:
439508
This work is licensed under the [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode).
440509
441510
- SPDX-License-Identifier: CC-BY-4.0
442-
- SPDX-FileCopyrightText: 2025 Contributors to the Eclipse Foundation
511+
- SPDX-FileCopyrightText: 2026 Contributors to the Eclipse Foundation

0 commit comments

Comments
 (0)