Skip to content

Commit b706242

Browse files
committed
Various examples for working with PGO
1 parent dd08635 commit b706242

32 files changed

+526
-0
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# [PGO](https://github.com/CrunchyData/postgres-operator), Crunchy [Postgres Operator](https://github.com/CrunchyData/postgres-operator) Examples
2+
3+
This repository contains examples for deploying PGO, the Postgres Operator from Crunchy Data, using a variety of examples.
4+
5+
The examples are grouped by various tools that can be used to deploy them.
6+
7+
The best way to get started is to fork this repository and experiment with the examples.
8+
9+
Each of the examples has its own README that guides you through the process of deploying it.
10+
11+
You can find out more information about [PGO](https://github.com/CrunchyData/postgres-operator), the [Postgres Operator](https://github.com/CrunchyData/postgres-operator) from [Crunchy Data](https://www.crunchydata.com) at the project page:
12+
13+
[https://github.com/CrunchyData/postgres-operator](https://github.com/CrunchyData/postgres-operator)

helm/postgres/Chart.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v3
2+
name: postgrescluster
3+
description: A Helm chart for Kubernetes
4+
type: application
5+
version: 0.1.0
6+
appVersion: 5.0.0

helm/postgres/templates/NOTES.txt

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Thank you for deploying a Crunchy PostgreSQL cluster!
2+
3+
((((((((((((((((((((((
4+
(((((((((((((%%%%%%%(((((((((((((((
5+
(((((((((((%%% %%%%((((((((((((
6+
(((((((((((%%( (((( ( %%%(((((((((((
7+
(((((((((((((%% (( ,(( %%%(((((((((((
8+
(((((((((((((((%% *%%/ %%%%%%%((((((((((
9+
(((((((((((((((((((%%(( %%%%%%%%%%#(((((%%%%%%%%%%#((((((((((((
10+
((((((((((((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%((((((((((((((
11+
*((((((((((((((((((((%%%%%% /%%%%%%%%%%%%%%%%%%%((((((((((((((((
12+
(((((((((((((((((((((((%%%/ .%, %%%((((((((((((((((((,
13+
((((((((((((((((((((((% %#(((((((((((((((((
14+
(((((((((((((((%%%%%% #%(((((((((((((((((
15+
((((((((((((((%% %%(((((((((((((((,
16+
((((((((((((%%%#% % %%(((((((((((((((
17+
((((((((((((%. % % #((((((((((((((
18+
(((((((((((%% % %%* %(((((((((((((
19+
#(###(###(#%% %%% %% %%% #%%#(###(###(#
20+
###########%%%%% /%%%%%%%%%%%%% %% %%%%% ,%%#######
21+
###############%% %%%%%% %%% %%%%%%%% %%#####
22+
################%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %%##
23+
################%% %%%%%%%%%%%%%%%%% %%%% %
24+
##############%# %% (%%%%%%% %%%%%%
25+
#############% %%%%% %%%%%%%%%%%
26+
###########% %%%%%%%%%%% %%%%%%%%%
27+
#########%% %% %%%%%%%%%%%%%%%#
28+
########%% %% %%%%%%%%%
29+
######%% %% %%%%%%
30+
####%%% %%%%% %
31+
%% %%%%

helm/postgres/templates/postgres.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: postgres-operator.crunchydata.com/v1beta1
2+
kind: PostgresCluster
3+
metadata:
4+
name: {{ .Values.name }}
5+
spec:
6+
image: {{ .Values.postgres }}
7+
postgresVersion: {{ .Values.postgresVersion }}
8+
instances:
9+
- name: instance1
10+
dataVolumeClaimSpec:
11+
accessModes:
12+
- "ReadWriteOnce"
13+
resources:
14+
requests:
15+
storage: 1Gi
16+
backups:
17+
pgbackrest:
18+
image: {{ .Values.pgBackRest}}
19+
repoHost:
20+
dedicated: {}
21+
repos:
22+
- name: repo1
23+
volume:
24+
volumeClaimSpec:
25+
accessModes:
26+
- "ReadWriteOnce"
27+
resources:
28+
requests:
29+
storage: 1Gi
30+
- name: repo2
31+
volume:
32+
volumeClaimSpec:
33+
accessModes:
34+
- "ReadWriteOnce"
35+
resources:
36+
requests:
37+
storage: 1Gi
38+
proxy:
39+
pgBouncer:
40+
image: {{ .Values.pgBouncer}}

helm/postgres/values.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
# Cluster name
3+
name: hippo
4+
5+
# PostgreSQL Version
6+
# Version should match version defined in PostgreSQL images
7+
postgresVersion: 13
8+
9+
# Images
10+
postgres: registry.developers.crunchydata.com/crunchydata/crunchy-postgres-ha:centos8-13.3-0
11+
pgBackRest: registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:centos8-2.33-0
12+
pgBouncer: registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:centos8-1.15-0

kustomize/azure/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
azure.conf

kustomize/azure/azure.conf.example

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[global]
2+
repo1-azure-account=<YOUR_AZURE_ACCOUNT>
3+
repo1-azure-key=<YOUR_AZURE_KEY>

kustomize/azure/kustomization.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace: postgres-operator
2+
3+
secretGenerator:
4+
- name: pgo-azure-creds
5+
files:
6+
- azure.conf
7+
8+
generatorOptions:
9+
disableNameSuffixHash: true
10+
11+
resources:
12+
- postgres.yaml

kustomize/azure/postgres.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apiVersion: postgres-operator.crunchydata.com/v1beta1
2+
kind: PostgresCluster
3+
metadata:
4+
name: hippo-azure
5+
spec:
6+
image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres-ha:centos8-13.3-0
7+
postgresVersion: 13
8+
instances:
9+
- dataVolumeClaimSpec:
10+
accessModes:
11+
- "ReadWriteOnce"
12+
resources:
13+
requests:
14+
storage: 1Gi
15+
backups:
16+
pgbackrest:
17+
image: registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:centos8-2.33-0
18+
repoHost:
19+
dedicated: {}
20+
configuration:
21+
- secret:
22+
name: pgo-azure-creds
23+
global:
24+
repo1-path: /pgbackrest/postgres-operator/hippo-azure/repo1
25+
repos:
26+
- name: repo1
27+
azure:
28+
container: "<YOUR_AZURE_CONTAINER>"

kustomize/gcs/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gcs-key.json

kustomize/gcs/gcs.conf

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[global]
2+
repo1-gcs-key=/etc/pgbackrest/conf.d/gcs-key.json

kustomize/gcs/kustomization.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace: postgres-operator
2+
3+
secretGenerator:
4+
- name: pgo-gcs-creds
5+
files:
6+
- gcs.conf
7+
- gcs-key.json
8+
9+
generatorOptions:
10+
disableNameSuffixHash: true
11+
12+
resources:
13+
- postgres.yaml

kustomize/gcs/postgres.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apiVersion: postgres-operator.crunchydata.com/v1beta1
2+
kind: PostgresCluster
3+
metadata:
4+
name: hippo-gcs
5+
spec:
6+
image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres-ha:centos8-13.3-0
7+
postgresVersion: 13
8+
instances:
9+
- dataVolumeClaimSpec:
10+
accessModes:
11+
- "ReadWriteOnce"
12+
resources:
13+
requests:
14+
storage: 1Gi
15+
backups:
16+
pgbackrest:
17+
image: registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:centos8-2.33-0
18+
repoHost:
19+
dedicated: {}
20+
configuration:
21+
- secret:
22+
name: pgo-gcs-creds
23+
global:
24+
repo1-path: /pgbackrest/postgres-operator/hippo-gcs/repo1
25+
repos:
26+
- name: repo1
27+
gcs:
28+
bucket: "<YOUR_GCS_BUCKET_NAME>"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
apiVersion: postgres-operator.crunchydata.com/v1beta1
2+
kind: PostgresCluster
3+
metadata:
4+
name: hippo-ha
5+
spec:
6+
image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres-ha:centos8-13.3-0
7+
postgresVersion: 13
8+
instances:
9+
- name: pgha1
10+
replicas: 2
11+
dataVolumeClaimSpec:
12+
accessModes:
13+
- "ReadWriteOnce"
14+
resources:
15+
requests:
16+
storage: 1Gi
17+
affinity:
18+
podAntiAffinity:
19+
preferredDuringSchedulingIgnoredDuringExecution:
20+
- weight: 1
21+
podAffinityTerm:
22+
topologyKey: kubernetes.io/hostname
23+
labelSelector:
24+
matchLabels:
25+
postgres-operator.crunchydata.com/cluster: hippo-ha
26+
postgres-operator.crunchydata.com/instance-set: pgha1
27+
backups:
28+
pgbackrest:
29+
image: registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:centos8-2.33-0
30+
repoHost:
31+
dedicated: {}
32+
repos:
33+
- name: repo1
34+
volume:
35+
volumeClaimSpec:
36+
accessModes:
37+
- "ReadWriteOnce"
38+
resources:
39+
requests:
40+
storage: 1Gi
41+
proxy:
42+
pgBouncer:
43+
image: registry.developers.crunchydata.com/crunchydata/crunchy-pgbouncer:centos8-1.15-0
44+
replicas: 2
45+
affinity:
46+
podAntiAffinity:
47+
preferredDuringSchedulingIgnoredDuringExecution:
48+
- weight: 1
49+
podAffinityTerm:
50+
topologyKey: kubernetes.io/hostname
51+
labelSelector:
52+
matchLabels:
53+
postgres-operator.crunchydata.com/cluster: hippo-ha
54+
postgres-operator.crunchydata.com/role: pgbouncer
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace: postgres-operator
2+
3+
resources:
4+
- ha-postgres.yaml

kustomize/keycloak/keycloak.yaml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: keycloak
5+
namespace: postgres-operator
6+
labels:
7+
app.kubernetes.io/name: keycloak
8+
spec:
9+
selector:
10+
matchLabels:
11+
app.kubernetes.io/name: keycloak
12+
template:
13+
metadata:
14+
labels:
15+
app.kubernetes.io/name: keycloak
16+
spec:
17+
containers:
18+
- image: quay.io/keycloak/keycloak:latest
19+
name: keycloak
20+
env:
21+
- name: DB_VENDOR
22+
value: "postgres"
23+
- name: DB_ADDR
24+
valueFrom: { secretKeyRef: { name: keycloakdb-pguser, key: host } }
25+
- name: DB_PORT
26+
valueFrom: { secretKeyRef: { name: keycloakdb-pguser, key: port } }
27+
- name: DB_DATABASE
28+
valueFrom: { secretKeyRef: { name: keycloakdb-pguser, key: dbname } }
29+
- name: DB_USER
30+
valueFrom: { secretKeyRef: { name: keycloakdb-pguser, key: user } }
31+
- name: DB_PASSWORD
32+
valueFrom: { secretKeyRef: { name: keycloakdb-pguser, key: password } }
33+
- name: KEYCLOAK_USER
34+
value: "admin"
35+
- name: KEYCLOAK_PASSWORD
36+
value: "admin"
37+
- name: PROXY_ADDRESS_FORWARDING
38+
value: "true"
39+
ports:
40+
- name: http
41+
containerPort: 8080
42+
- name: https
43+
containerPort: 8443
44+
readinessProbe:
45+
httpGet:
46+
path: /auth/realms/master
47+
port: 8080
48+
restartPolicy: Always

kustomize/keycloak/kustomization.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace: postgres-operator
2+
3+
resources:
4+
- postgres.yaml
5+
- keycloak.yaml

kustomize/keycloak/postgres.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: postgres-operator.crunchydata.com/v1beta1
2+
kind: PostgresCluster
3+
metadata:
4+
name: keycloakdb
5+
spec:
6+
image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres-ha:centos8-13.3-0
7+
postgresVersion: 13
8+
openshift: false
9+
instances:
10+
- replicas: 2
11+
dataVolumeClaimSpec:
12+
accessModes:
13+
- "ReadWriteOnce"
14+
resources:
15+
requests:
16+
storage: 1Gi
17+
affinity:
18+
podAntiAffinity:
19+
preferredDuringSchedulingIgnoredDuringExecution:
20+
- weight: 1
21+
podAffinityTerm:
22+
topologyKey: kubernetes.io/hostname
23+
labelSelector:
24+
matchLabels:
25+
postgres-operator.crunchydata.com/cluster: keycloakdb
26+
postgres-operator.crunchydata.com/instance-set: "00"
27+
backups:
28+
pgbackrest:
29+
image: registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:centos8-2.33-0
30+
repoHost:
31+
dedicated: {}
32+
repos:
33+
- name: repo1
34+
volume:
35+
volumeClaimSpec:
36+
accessModes:
37+
- "ReadWriteOnce"
38+
resources:
39+
requests:
40+
storage: 1Gi
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
azure.conf
2+
gcs-key.json
3+
s3.conf
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[global]
2+
repo4-azure-account=<YOUR_AZURE_ACCOUNT>
3+
repo4-azure-key=<YOUR_AZURE_KEY>

kustomize/multi-backup-repo/gcs.conf

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[global]
2+
repo3-gcs-key=/etc/pgbackrest/conf.d/gcs-key.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace: postgres-operator
2+
3+
secretGenerator:
4+
- name: pgo-multi-repo-creds
5+
files:
6+
- azure.conf
7+
- gcs.conf
8+
- gcs-key.json
9+
- s3.conf
10+
11+
generatorOptions:
12+
disableNameSuffixHash: true
13+
14+
resources:
15+
- postgres.yaml

0 commit comments

Comments
 (0)