Skip to content

Commit 72479d4

Browse files
RothAndrewjeff-mccoy
authored andcommitted
Add backups to postgres-operator example (zarf-dev#52)
Signed-off-by: Jeff McCoy <code@jeffm.us>
1 parent cc9fe50 commit 72479d4

10 files changed

+400
-9
lines changed

examples/postgres-operator/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ After looking at several alternatives, Zalando's postgres operator felt like the
2020
- Connection // Username: `zarf`
2121
- Connection // Password: (run the command in the table below)
2222
- SSL // SSL mode: `Require`
23+
5. Create the backups bucket in MinIO (TODO: Figure out how to create the bucket automatically)
24+
1. Navigate to [https://minio-console.localhost:8443](https://minio-console.localhost:8443)
25+
2. Log in - Username: `minio` - Password: `minio123`
26+
3. Buckets -> Create Bucket
27+
- Bucket Name: `postgres-operator-backups`
2328

2429
## Logins
2530

@@ -28,6 +33,7 @@ After looking at several alternatives, Zalando's postgres operator felt like the
2833
| Postgres Operator UI | [https://postgres-operator-ui.localhost:8443](https://postgres-operator-ui.localhost:8443) | N/A | N/A |
2934
| PGAdmin | [https://pgadmin.localhost:8443](https://pgadmin.localhost:8443) | `zarf@example.local` | Run: `zarf tools get-admin-password` |
3035
| Example Postgres Database | `acid-zarf-test.postgres-operator.svc.cluster.local` | `zarf` | Run: `echo $(kubectl get secret zarf.acid-zarf-test.credentials.postgresql.acid.zalan.do -n postgres-operator --template={{.data.password}} \| base64 -d)` |
36+
| Minio Console | [https://minio-console.localhost:8443](https://minio-console.localhost:8443) | `minio` | `minio123` |
3137

3238
## References
3339
- https://blog.flant.com/comparing-kubernetes-operators-for-postgresql/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
apiVersion: helm.cattle.io/v1
2+
kind: HelmChart
3+
metadata:
4+
name: minio-instance
5+
namespace: minio-operator
6+
spec:
7+
chart: https://%{KUBERNETES_API}%/static/charts/minio-instance-4.2.3-bb.1.tgz
8+
targetNamespace: minio-operator
9+
# https://repo1.dso.mil/platform-one/big-bang/apps/application-utilities/minio/-/blob/4.2.3-bb.1/chart/values.yaml
10+
valuesContent: |-
11+
hostname: minio.localhost
12+
tenants:
13+
pools:
14+
## Servers specifies the number of MinIO Tenant Pods / Servers in this pool.
15+
## For standalone mode, supply 1. For distributed mode, supply 4 or more.
16+
## Note that the operator does not support upgrading from standalone to distributed mode.
17+
- servers: 1
18+
## volumesPerServer specifies the number of volumes attached per MinIO Tenant Pod / Server.
19+
volumesPerServer: 4
20+
## size specifies the capacity per volume
21+
size: 1Gi
22+
## storageClass specifies the storage class name to be used for this pool
23+
storageClassName: local-path
24+
## Used to specify a toleration for a pod
25+
tolerations: {}
26+
## nodeSelector parameters for MinIO Pods. It specifies a map of key-value pairs. For the pod to be
27+
## eligible to run on a node, the node must have each of the
28+
## indicated key-value pairs as labels.
29+
## Read more here: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
30+
nodeSelector: {}
31+
## Affinity settings for MinIO pods. Read more about affinity
32+
## here: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity.
33+
affinity: {}
34+
## Configure resource requests and limits for MinIO containers
35+
resources:
36+
requests:
37+
cpu: "250m"
38+
memory: "1Gi"
39+
limits:
40+
cpu: "500m"
41+
memory: "1Gi"
42+
## Configure security context
43+
## BB Note: Defaults for Ironbank image are 1001 for user, group, and fsGroup
44+
securityContext:
45+
runAsUser: 1001
46+
runAsGroup: 1001
47+
fsGroup: 1001
48+
console:
49+
enabled: true
50+
---
51+
apiVersion: traefik.containo.us/v1alpha1
52+
kind: IngressRoute
53+
metadata:
54+
name: minio-console-ingressroute
55+
namespace: minio-operator
56+
spec:
57+
entryPoints:
58+
- websecure
59+
routes:
60+
- match: Host(`minio-console.localhost`)
61+
kind: Rule
62+
services:
63+
- name: minio-instance-console
64+
port: 9090
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: helm.cattle.io/v1
2+
kind: HelmChart
3+
metadata:
4+
name: minio-operator
5+
namespace: minio-operator
6+
spec:
7+
chart: https://%{KUBERNETES_API}%/static/charts/minio-operator-4.2.3-bb.1.tgz
8+
targetNamespace: minio-operator
9+
# https://repo1.dso.mil/platform-one/big-bang/apps/application-utilities/minio-operator/-/blob/2.0.9-bb.3/chart/values.yaml
10+
valuesContent: |-
11+
operator:
12+
image:
13+
repository: registry1.dso.mil/ironbank/opensource/minio/operator
14+
tag: v4.2.3
15+
resources:
16+
requests:
17+
cpu: 200m
18+
memory: 256Mi
19+
ephemeral-storage: 500Mi
20+
limits:
21+
cpu: 200m
22+
memory: 256Mi
23+

examples/postgres-operator/manifests/namespace.yaml

-4
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: postgres-operator
5+
---
6+
apiVersion: v1
7+
kind: Namespace
8+
metadata:
9+
name: minio-operator

examples/postgres-operator/manifests/cluster.yaml examples/postgres-operator/manifests/postgres-cluster.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ spec:
1717
zarf: []
1818
databases:
1919
zarf: zarf
20+
enableLogicalBackup: true
21+
logicalBackupSchedule: "*/2 * * * *"
2022
resources:
2123
requests:
2224
cpu: 100m

examples/postgres-operator/manifests/operator-ui.yaml examples/postgres-operator/manifests/postgres-operator-ui.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ spec:
2828
targetNamespace: "postgres-operator"
2929
teams:
3030
- "acid"
31+
extraEnvs:
32+
- name: WALE_S3_ENDPOINT
33+
value: "http+path://minio.minio-operator.svc.cluster.local:80"
34+
- name: AWS_ENDPOINT
35+
value: "http://minio.minio-operator.svc.cluster.local"
36+
- name: SPILO_S3_BACKUP_PREFIX
37+
value: "spilo/"
38+
- name: AWS_ACCESS_KEY_ID
39+
value: "minio"
40+
- name: AWS_SECRET_ACCESS_KEY
41+
value: "minio123"
42+
- name: SPILO_S3_BACKUP_BUCKET
43+
value: "postgres-operator-backups"
3144
# We are defining our own Ingress manifest
3245
ingress:
3346
enabled: false

examples/postgres-operator/manifests/operator.yaml examples/postgres-operator/manifests/postgres-operator.yaml

+27-5
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@ spec:
2222
default_memory_limit: "500Mi"
2323
min_cpu_limit: "250m"
2424
min_memory_limit: "250Mi"
25-
# configLogicalBackup:
25+
configAwsOrGcp:
26+
wal_s3_bucket: "postgres-operator-backups"
27+
configLogicalBackup:
2628
# logical_backup_docker_image: "registry1.dso.mil/.../logical-backup:v1.7.0"
27-
# logical_backup_s3_endpoint: ""
28-
# logical_backup_s3_access_key_id: ""
29-
# logical_backup_s3_secret_access_key : ""
30-
# logical_backup_schedule: "30 00 * * *"
29+
logical_backup_s3_endpoint: "http://minio.minio-operator.svc.cluster.local"
30+
logical_backup_s3_access_key_id: "minio"
31+
logical_backup_s3_bucket: "postgres-operator-backups"
32+
logical_backup_s3_secret_access_key : "minio123"
33+
logical_backup_s3_sse: ""
34+
logical_backup_schedule: "*/2 * * * *"
35+
configKubernetes:
36+
pod_environment_configmap: "postgres-operator/postgres-pod-config"
3137
configConnectionPooler:
3238
# connection_pooler_image: "registry1.dso.mil/.../pgbouncer:master-18"
3339
connection_pooler_default_cpu_request: "100m"
@@ -46,3 +52,19 @@ spec:
4652
runAsNonRoot: true
4753
readOnlyRootFilesystem: true
4854
allowPrivilegeEscalation: false
55+
---
56+
apiVersion: v1
57+
kind: ConfigMap
58+
metadata:
59+
name: postgres-pod-config
60+
namespace: postgres-operator
61+
data:
62+
AWS_ENDPOINT: http://minio.minio-operator.svc.cluster.local
63+
AWS_ACCESS_KEY_ID: minio
64+
AWS_SECRET_ACCESS_KEY: minio123
65+
BACKUP_NUM_TO_RETAIN: "3"
66+
BACKUP_SCHEDULE: "*/2 * * * *"
67+
USE_WALG_BACKUP: "true"
68+
WALG_DISABLE_S3_SSE: "true"
69+
USE_WALG_RESTORE: "false"
70+
AWS_S3_FORCE_PATH_STYLE: "true"

examples/postgres-operator/zarf.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ kind: ZarfPackageConfig
22
metadata:
33
name: postgres-operator-demo
44
description: "Demo of prod-like Postgres database(s) on an edge cluster"
5+
# uncompressed: true
56

67
local:
78
manifests: manifests
@@ -16,6 +17,12 @@ local:
1617
- name: pgadmin4
1718
url: https://helm.runix.net
1819
version: 1.7.2
20+
- name: minio-operator
21+
url: https://repo1.dso.mil/platform-one/big-bang/apps/application-utilities/minio-operator.git
22+
version: 4.2.3-bb.1
23+
- name: minio-instance
24+
url: https://repo1.dso.mil/platform-one/big-bang/apps/application-utilities/minio.git
25+
version: 4.2.3-bb.1
1926

2027
images:
2128
- registry.opensource.zalan.do/acid/postgres-operator:v1.7.0
@@ -24,3 +31,5 @@ local:
2431
- registry.opensource.zalan.do/acid/pgbouncer:master-18
2532
- registry.opensource.zalan.do/acid/postgres-operator-ui:v1.7.0
2633
- docker.io/dpage/pgadmin4:5.5
34+
- registry1.dso.mil/ironbank/opensource/minio/operator:v4.2.3
35+
- registry1.dso.mil/ironbank/opensource/minio/minio:RELEASE.2021-08-31T05-46-54Z

0 commit comments

Comments
 (0)