Skip to content

Commit

Permalink
(kc-pg) Add first cnpg cluster #1341
Browse files Browse the repository at this point in the history
  • Loading branch information
h3mmy committed Mar 17, 2023
1 parent 0521925 commit 4978d01
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ infrastructure/bare-metal/*
infrastructure/shared/networks.yaml
infrastructure/terraform/vault/*
*volsync-config.yaml
cluster/apps/auth/realms/*
cluster/apps/auth/realms/bloopysphere/keycloak.yaml
cluster/apps/auth/realms/bloopysphere/certificate.yaml
2 changes: 1 addition & 1 deletion cluster/apps/auth/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# - keycloak
- keycloak
- authentik
Empty file.
3 changes: 3 additions & 0 deletions cluster/apps/auth/realms/bloopysphere/db/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Database

For this instance I am using [cloudnative-pg](https://github.com/cloudnative-pg/cloudnative-pg) for the postgres database. The backing storage will just be `local-path` as it is kind of wasteful to use ceph for backing storage since the cnpg operator will be replicating it anyway. Backups will be done into a ceph-rgw object-store. For this an `ObjectBucketClaim` is created. The `rook-ceph-operator` will provision the bucket and then add a configMap and secret to the bucket namespace which will contain credentials that can be used by the backup process. See [ObjectBucketClaim Documentation](https://rook.io/docs/rook/v1.9/Storage-Configuration/Object-Storage-RGW/ceph-object-bucket-claim/)
12 changes: 12 additions & 0 deletions cluster/apps/auth/realms/bloopysphere/db/backup-schedule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apiVersion: postgresql.cnpg.io/v1
kind: ScheduledBackup
metadata:
name: postgres-v15
namespace: database
spec:
schedule: "@daily"
immediate: true
backupOwnerReference: self
cluster:
name: postgres-v15
44 changes: 44 additions & 0 deletions cluster/apps/auth/realms/bloopysphere/db/cnpg-v15.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: kc-postgres
namespace: database
spec:
instances: 3

imageName: ghcr.io/cloudnative-pg/postgresql:15.2

primaryUpdateStrategy: unsupervised

storage:
size: 5Gi
storageClass: local-path
postgresql:
parameters:
max_connections: "300"
shared_buffers: 512MB

monitoring:
enablePodMonitor: true

superuserSecret:
name: cloudnative-pg-postgres-superuser

backup:
retentionPolicy: 30d
barmanObjectStore:
wal:
compression: bzip2
maxParallel: 5
destinationPath: s3://cnpg/v15/v1
endpointURL: http://rook-ceph-rgw-ceph-objectstore.rook-ceph.svc.cluster.local
s3Credentials:
accessKeyId:
name: cloudnative-pg-postgres-s3
key: S3_ACCESS_KEY
secretAccessKey:
name: cloudnative-pg-postgres-s3
key: S3_SECRET_KEY

externalClusters: []
12 changes: 12 additions & 0 deletions cluster/apps/auth/realms/bloopysphere/db/obc-backup-v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apiVersion: objectbucket.io/v1alpha1
kind: ObjectBucketClaim
metadata:
name: cnpg-kc-backup-v1
namespace: auth
spec:
generateBucketName: kc-postgres-backup
storageClassName: rook-ceph-bucket
additionalConfig:
maxObjects: "1000"
maxSize: "2G"
20 changes: 20 additions & 0 deletions cluster/apps/auth/realms/bloopysphere/keycloak.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: k8s.keycloak.org/v2alpha1
kind: Keycloak
metadata:
name: example-kc
spec:
instances: 1
db:
vendor: postgres
host: postgres-db
usernameSecret:
name: keycloak-db-secret
key: username
passwordSecret:
name: keycloak-db-secret
key: password
http:
tlsSecret: example-tls-secret
hostname:
hostname: test.keycloak.org
6 changes: 6 additions & 0 deletions cluster/apps/auth/realms/bloopysphere/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
# - ./certificate.yaml
- ./db
5 changes: 5 additions & 0 deletions cluster/apps/auth/realms/kustomizations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./bloopysphere

0 comments on commit 4978d01

Please sign in to comment.