|
| 1 | +--- |
| 2 | +title: "pgAdmin 4" |
| 3 | +date: |
| 4 | +draft: false |
| 5 | +weight: 900 |
| 6 | +--- |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +[pgAdmin 4](https://www.pgadmin.org/) is a popular graphical user interface that |
| 11 | +makes it easy to work with PostgreSQL databases from both a desktop or web-based |
| 12 | +client. With its ability to manage and orchestrate changes for PostgreSQL users, |
| 13 | +the PostgreSQL Operator is a natural partner to keep a pgAdmin 4 environment |
| 14 | +synchronized with a PostgreSQL environment. |
| 15 | + |
| 16 | +The PostgreSQL Operator lets you deploy a pgAdmin 4 environment alongside a |
| 17 | +PostgreSQL cluster and keeps users' database credentials synchronized. You can |
| 18 | +simply log into pgAdmin 4 with your PostgreSQL username and password and |
| 19 | +immediately have access to your databases. |
| 20 | + |
| 21 | +## Deploying pgAdmin 4 |
| 22 | + |
| 23 | +For example, let's use a PostgreSQL cluster called hippo `hippo` that has a user |
| 24 | +named `hippo` with password `datalake`: |
| 25 | + |
| 26 | +``` |
| 27 | +pgo create cluster hippo --username=hippo --password=datalake |
| 28 | +``` |
| 29 | + |
| 30 | +After the PostgreSQL cluster becomes ready, you can create a pgAdmin 4 |
| 31 | +deployment with the [`pgo create pgadmin`]({{< relref "/pgo-client/reference/pgo_create_pgadmin.md" >}}) |
| 32 | +command: |
| 33 | + |
| 34 | +``` |
| 35 | +pgo create pgadmin hippo |
| 36 | +``` |
| 37 | + |
| 38 | +This creates a pgAdmin 4 deployment unique to this PostgreSQL cluster and |
| 39 | +synchronizes the PostgreSQL user information into it. To access pgAdmin 4, you |
| 40 | +can set up a port-forward to the Service, which follows the pattern `<clusterName>-pgadmin`, to port `5050`: |
| 41 | + |
| 42 | +``` |
| 43 | +kubectl port-forward svc/hippo-pgadmin 5050:5050 |
| 44 | +``` |
| 45 | + |
| 46 | +Point your browser at `http://localhost:5050` and use your database |
| 47 | +username (e.g. `hippo`) and password (e.g. `datalake`) to log in. Though the |
| 48 | +prompt says "email address", using your PostgreSQL username will work. |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +(**Note**: if your password does not appear to work, you can retry setting up |
| 53 | +the user with the [`pgo update user`]({{< relref "/pgo-client/reference/pgo_update_user.md" >}}) |
| 54 | +command: `pgo update user hippo --password=datalake`) |
| 55 | + |
| 56 | +## User Synchronization |
| 57 | + |
| 58 | +The [`pgo create user`]({{< relref "/pgo-client/reference/pgo_create_user.md" >}}), |
| 59 | +[`pgo update user`]({{< relref "/pgo-client/reference/pgo_update_user.md" >}}), |
| 60 | +and [`pgo delete user`]({{< relref "/pgo-client/reference/pgo_delete_user.md" >}}) |
| 61 | +commands are synchronized with the pgAdmin 4 deployment. Note that if you use |
| 62 | +`pgo create user` without the `--managed` flag prior to deploying pgAdmin 4, |
| 63 | +then the user's credentials will not be synchronized to the pgAdmin 4 |
| 64 | +deployment. However, a subsequent run of `pgo update user --password` will |
| 65 | +synchronize the credentials with pgAdmin 4. |
| 66 | + |
| 67 | +## Deleting pgAdmin 4 |
| 68 | + |
| 69 | +You can remove the pgAdmin 4 deployment with the |
| 70 | +[`pgo delete pgadmin`]({{< relref "/pgo-client/reference/pgo_delete_pgadmin.md" >}}) |
| 71 | +command. |
0 commit comments