PostgreSQL Slave
Introduction
This stack creates PostgreSQL Slave Database using GitOps. Before you use this stack, make sure you have a PostgreSQL Master Database is up and running.
Stack Code
- Postgres_slave-12.2 - To be mentioned in
build.image_template
inappz.yml
. See Sample AppZ Yaml.
Pre-requisites
Before deploying Postgres Slave, make sure both the [Vault]{https://github.com/ecloudcontrol/Vault] and [postgres-master]{https://github.com/ecloudcontrol/postgres-master} applications are deployed.
Sample Project
Postgres Slave - Optionally use this sample project to deploy PostgreSQL Slave database. Before running this, make sure master database is up and running.
Sample AppZ YAML
If you fork Postgres Slave , you will see the following appz.yml
in the root of the project.
app:
name: Postgres Slave
code: POSTGRESSLAVE
notify: appzdev@cloudbourne.co
build:
version: 12.2
env: DEV
build_file: none
output_files: output/*.zip
image_template: postgres_slave-12.2
image_name: alpha/postgres_slave
deploy:
context: alpha/DEV
type: statefulset
replicas: 1
port:
- 5432
volumes:
- claim: postgres-slave-data
mount: /appz/data
name: data
size: 5Gi
mode: ReadWriteOnce
class: microk8s-hostpath
monitor:
notify: appzops@cloudbourne.co
properties:
POSTGRESQL_REPLICATION_MODE: slave
POSTGRESQL_DATA: /appz/data
POSTGRESQL_CONNECTUSER: postgres
POSTGRESQL_PASSWORD:
vault: POSTGRESQL_PASSWORD
POSTGRESQL_REP_USER: replica
PGPASSWORD:
vault: PGPASSWORD
POSTGRESQL_MASTER_HOST: postgres-master-12-2
POSTGRESQL_PORT: 5432
revision : 25
See below the explanation of appz.yml which user can customize.
Properties
The image is vault enabled so secrets can be pulled from vault. These are placed under properties
in appz.yml
. Please check each one below, with its actual purpose.
- POSTGRESQL_REPLICATION_MODE - Server replication mode (master/slave)
- POSTGRESQL_DATA - Data storage location
- POSTGRESQL_CONNECTUSER - The default user 'postgres' in the PostgreSQL server
- POSTGRESQL_PASSWORD - Password of the user 'postgres', enter this into AppZ Vault
- POSTGRESQL_REP_USER - Replication user to sync from Master to Slave
- PGPASSWORD - Replication user password, enter this into AppZ Vault
- POSTGRESQL_MASTER_HOST - The Master PostgreSQL server
- POSTGRESQL_PORT - Default port for PostgreSQL
- revision - A dummy property to help trigger GitOps
Volumes
It is stateful deployment and volumes are created for /appz/data as per volumes: section in appz.yml
Standard AppZ Volumes is also enabled.