Postgres Operator
This example demonstrates deploying a performant and highly available PostgreSQL database to a Zarf airgap cluster. It uses Zalando's postgres-operator and provides the Postgres Operator UI and a deployment of PGAdmin for demo purposes.
To view the example source code, select the Edit this page
link below the article and select the parent folder.
This example uses Zalando's Postgres operator as after looking at several alternatives, this felt like the best choice. Other tools that were close runners-up were the postgres-operator by CrunchyData and KubeDB.
Prerequisites
Install Docker. Other container engines will likely work as well but aren't actively tested by the Zarf team.
Install Kind. Other Kubernetes distros will work as well, but we'll be using Kind for this example since it is easy and tested frequently and thoroughly.
Clone the Zarf project: for the example configuration files.
Build the package using
zarf package create examples/postgres-operator
Create a Zarf cluster as described in the Initializing a Cluster Walkthrough
Instructions
Deploy the package
Run the following commands to deploy the created package to the cluster
# Open the directory
cd examples/postgres-operator
# Build the package
zarf package create
# Deploy the package (Press TAB for the listing of available packages)
zarf package deploy
Wait a couple of minutes. You'll know it is done when Zarf exits and you get the 3 connect commands.
Create the backups bucket in MinIO (TODO: Figure out how to create the bucket automatically)
- Run
zarf connect minio
to navigate to the web console. - Log in - Username:
minio
- Password:minio123
- Buckets -> Create Bucket
- Bucket Name:
postgres-operator-backups
- Bucket Name:
Open the UI
The Postgres Operator UI will be available by running ./zarf connect postgres-operator-ui
and pgadmin
will be available by running ./zarf connect pgadmin
If you want to run other commands after/during the browsing of the postgres tools, you can add a &
character at the end of the connect command to run the command in the background ie) ./zarf connect pgadmin &
.
Set up a server in PGAdmin
- General // Name:
acid-zarf-test
- General // Server group:
Servers
- Connection // Host: (the URL in the table below)
- Connection // Port:
5432
- Connection // Maintenance database:
postgres
- Connection // Username:
zarf
- Connection // Password: (run the command in the table below)
- SSL // SSL mode:
Require
Logins
Service | URL | Username | Password |
---|---|---|---|
Postgres Operator UI | zarf connect postgres-operator-ui | N/A | N/A |
PGAdmin | zarf connect pgadmin | zarf@example.local | Run: zarf tools get-admin-password |
Example Postgres Database | acid-zarf-test.postgres-operator.svc.cluster.local | zarf | Run: `echo $(zarf tools kubectl get secret zarf.acid-zarf-test.credentials.postgresql.acid.zalan.do -n postgres-operator --template={{.data.password}} |
Minio Console | zarf connect minio | minio | minio123 |