In this demo I'll show you how to create a PostgreSQL cluster with the Red Hat OpenShift operator called EDB CloudNativePG. The features that I want to show you are:
- Kubernetes plugin install
- EDB Postgres for Kubernetes operator install
- Postgres cluster install
- Insert data in the cluster
- Switchover (promote)
- Failover
- Backup & Recovery (in a S3 Minio platform)
- Scale out/down
- Rolling updates (minor and major)
- Point In Time Recovery (PITR)
- Fencing
- Replication slots (for HA)
- Monitoring (scripts)
- Operator upgrade
To use this demo the following software is needed:
- Red Hat OpenShift 4.x
- Red Hat OpenShift environment (Red Hat Code Ready also works)
- oc (OpenShift CLI installed)
- jq (optional if you want to format JSON logs outputs)
- Modify
config.shfile with your parameters:- Replace variables:
id: with your name or idregion: region in which you deploy your clusters:[emea|na|apj]bucket: Your S3 bucket where you store your backups and Postgres wals.object_storage_typetominioorawsACCESS_KEY_IDACCESS_SECRET_KEYACCESS_SESSION_TOKENif necessary (only for AWS S3)
- Replace variables:
Create a file .aws.sh with this information:
export AWS_ACCESS_KEY_ID="<AWS_ACCESS_KEY_ID>"
export AWS_SECRET_ACCESS_KEY="<AWS_SECRET_ACCESS_KEY>"
export AWS_SESSION_TOKEN="<AWS_SESSION_TOKEN>"
Namespaces
├── edb-emea-user1
│ ├─ cluster-user1
│ ├─ cluster-user1-17
│ ├─ cluster-restore
├── edb-emea-user2
│ ├─ cluster-user2
│ ├─ cluster-user2-17
│ ├─ cluster-restore
├── edb-na-user3
│ ├─ cluster-user3
├── edb-na-user4
│ ├─ cluster-user4
│ ├─ cluster-user4-17
│ ├─ cluster-restore
├── edb-apj-user5
└── edb-apj-user6
├─ cluster-user6
├─ cluster-user6-17
└─ cluster-restore
File .env.sh show all the env variables created to manage
the PostgreSQL clusters in Red Hat OpensShift. This is an example:
./env.sh
----------------------------------------------------------------------------------------------
⎈ Kubernetes environment ⎈
----------------------------------------------------------------------------------------------
Context
├─ Current name : docker-desktop
├─ Current cluster : docker-desktop
└─ Current namespace : edb-emea-pgcluster
Pods
└─ Sum of pod CPU's : 1.5 / 12
Nodes
├─ Total K8s nodes : 1
└─ Number of CPU's per node: 12
Kubernetes Namespace : edb-emea-pgcluster
----------------------------------------------------------------------------------------------
PostgreSQL Cluster configuration
----------------------------------------------------------------------------------------------
PostgreSQL Cluster Name : cluster-pgcluster
Postgres Instances : 3
Postgres CPU's : 0.5
Postgres Memory : 512Mi
Postgres storage : 512Mi
Postgres WAL storage : 512Mi
----------------------------------------------------------------------------------------------
Object Storage
----------------------------------------------------------------------------------------------
Object Storage type : aws
Object Storage bucket : <your-bucket>
Destination path : s3://<your-bucket>/
Endpoint :
----------------------------------------------------------------------------------------------
Transparent Data Encryption (TDE)
----------------------------------------------------------------------------------------------
Using TDE (in progress) : N
Execute commands in the correct order:
01_install_plugin.sh
02_install_operator.sh
03_check_operator_installed.sh
04-prepare-cluster.sh
05_install_cluster.sh
06_show_status.sh
07_insert_data.sh
08_promote.sh
09_upgrade.sh
10_backup_cluster.sh
11_backup_describe.sh
12_restore_cluster.sh
13_failover.sh
14_scale_out.sh
15_scale_down.sh
16_pitr_insert_two_lines.sh
17_pitr_backup.sh
18_pitr_insert_new_line.sh
19_pitr_restore_line_one.sh
20_upgrade_major_version.sh
30_fencing_on.sh
31_fencing_off.sh
32_hibernation_on.sh
33_hibernation_off.sh
./30_fencing_on.sh
./31_fencing_off.sh
./32_hibernation_on.sh
./33_hibernation_off.sh
99_delete_env.sh