---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: zalando-postgres
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: zalando-postgres
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: zalando-postgres
subjects:
- kind: ServiceAccount
  name: zalando-postgres
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: postgres-pod-config
data:
  AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
  AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
  AWS_S3_FORCE_PATH_STYLE: "true"
  WAL_S3_BUCKET: ${NS}-dumps
  AWS_ENDPOINT: ${S3_ENDPOINT_COLD}
  WAL_S3_ENDPOINT: ${S3_ENDPOINT_COLD}
  AWS_REGION: default
  USE_WALE: "true"
  USE_WALG_BACKUP: "true"
  WALG_DISABLE_S3_SSE: "true"
  BACKUP_SCHEDULE: "5 0 * * *"
---
apiVersion: "acid.zalan.do/v1"
kind: postgresql
metadata:
  name: pg-${PG_DOMAIN}
spec:
  clone:
#https://postgres-operator.readthedocs.io/en/latest/user/#how-to-clone-an-existing-postgresql-cluster
    uid: ""
    cluster: ""
    timestamp: "2022-01-19T12:00:00+00:00"
    s3_endpoint: https://cold-objects.liiib.re
    s3_access_key_id: 
    s3_secret_access_key: 
    s3_force_path_style: true
    s3_wal_path: s3://bucket-dumps/spilo/ns-pg-name/wal/
  resources:
    limits:
      cpu: "2"
      memory: 1000Mi
    requests:
      cpu: 100m
      memory: 500Mi
  teamId: "pg"
  volume:
    size: 4975Mi
    storageClass: small
  numberOfInstances: 2
  users:
    nextcloud:  # database owner
    - superuser
    - createdb
  databases:
    nextcloud: nextcloud # dbname: owner
  postgresql:
    version: "12"
