Skip to main content

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.

info

To view the example source code, select the Edit this page link below the article and select the parent folder.

note

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

  1. Install Docker. Other container engines will likely work as well but aren't actively tested by the Zarf team.

  2. 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.

  3. Clone the Zarf project: for the example configuration files.

  4. Build the package using zarf package create examples/postgres-operator

  5. 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)

  1. Run zarf connect minio to navigate to the web console.
  2. Log in - Username: minio - Password: minio123
  3. Buckets -> Create Bucket
    • Bucket Name: postgres-operator-backups

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

note

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

ServiceURLUsernamePassword
Postgres Operator UIzarf connect postgres-operator-uiN/AN/A
PGAdminzarf connect pgadminzarf@example.localRun: zarf tools get-admin-password
Example Postgres Databaseacid-zarf-test.postgres-operator.svc.cluster.localzarfRun: `echo $(zarf tools kubectl get secret zarf.acid-zarf-test.credentials.postgresql.acid.zalan.do -n postgres-operator --template={{.data.password}}
Minio Consolezarf connect miniominiominio123

References