From f73bc60cba90cf90e7d4ab9297bd0f3285d67d3d Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Sun, 25 Oct 2026 12:56:00 +0100 Subject: [PATCH] Move Minecraft PostgreSQL to CloudNativePG --- .../postgresql/mcserver/kustomization.yaml | 5 +++-- .../minecraft-postgresql/cluster/cluster.yaml | 18 ++++++++++++++++ .../cluster/kustomization.yaml | 4 ++++ .../service/kustomization.yaml | 4 ++++ .../minecraft-postgresql/service/service.yaml | 15 +++++++++++++ bootstrap/kustomization.yaml | 1 + bootstrap/minecraft-cnpg.yaml | 21 +++++++++++++++++++ bootstrap/minecraft-postgresql.yaml | 16 +++++--------- bootstrap/minecraft-project.yaml | 2 ++ 9 files changed, 73 insertions(+), 13 deletions(-) create mode 100644 apps/minecraft-postgresql/cluster/cluster.yaml create mode 100644 apps/minecraft-postgresql/cluster/kustomization.yaml create mode 100644 apps/minecraft-postgresql/service/kustomization.yaml create mode 100644 apps/minecraft-postgresql/service/service.yaml create mode 100644 bootstrap/minecraft-cnpg.yaml diff --git a/apps/backup/postgresql/mcserver/kustomization.yaml b/apps/backup/postgresql/mcserver/kustomization.yaml index 584094f..5cf5ad3 100644 --- a/apps/backup/postgresql/mcserver/kustomization.yaml +++ b/apps/backup/postgresql/mcserver/kustomization.yaml @@ -19,6 +19,7 @@ patches: - name: pg-dump env: - {name: BACKUP_TARGET, value: mcserver} - - {name: PGHOST, value: paper-postgresql} + - {name: PGHOST, value: paper-cnpg-rw} + - {name: PGUSER, value: postgres} - name: PGPASSWORD - valueFrom: {secretKeyRef: {name: paper-postgres, key: postgres-password}} + valueFrom: {secretKeyRef: {name: paper-cnpg-superuser, key: password}} diff --git a/apps/minecraft-postgresql/cluster/cluster.yaml b/apps/minecraft-postgresql/cluster/cluster.yaml new file mode 100644 index 0000000..b46d60b --- /dev/null +++ b/apps/minecraft-postgresql/cluster/cluster.yaml @@ -0,0 +1,18 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: paper-cnpg + namespace: mcserver +spec: + instances: 1 + enableSuperuserAccess: true + imageName: ghcr.io/cloudnative-pg/postgresql:18.6-standard-trixie + bootstrap: + initdb: + database: minecraft + owner: minecraft + secret: + name: paper-cnpg-bootstrap + storage: + size: 8Gi + storageClass: rook-ceph-block-ec diff --git a/apps/minecraft-postgresql/cluster/kustomization.yaml b/apps/minecraft-postgresql/cluster/kustomization.yaml new file mode 100644 index 0000000..993fbde --- /dev/null +++ b/apps/minecraft-postgresql/cluster/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - cluster.yaml diff --git a/apps/minecraft-postgresql/service/kustomization.yaml b/apps/minecraft-postgresql/service/kustomization.yaml new file mode 100644 index 0000000..9bb4d07 --- /dev/null +++ b/apps/minecraft-postgresql/service/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - service.yaml diff --git a/apps/minecraft-postgresql/service/service.yaml b/apps/minecraft-postgresql/service/service.yaml new file mode 100644 index 0000000..066f319 --- /dev/null +++ b/apps/minecraft-postgresql/service/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: paper-postgresql + namespace: mcserver +spec: + type: ClusterIP + ports: + - name: postgresql + port: 5432 + protocol: TCP + targetPort: 5432 + selector: + cnpg.io/cluster: paper-cnpg + cnpg.io/instanceRole: primary diff --git a/bootstrap/kustomization.yaml b/bootstrap/kustomization.yaml index f2db37e..1a784a8 100644 --- a/bootstrap/kustomization.yaml +++ b/bootstrap/kustomization.yaml @@ -106,6 +106,7 @@ resources: - mumble-namespace.yaml - mumble-postgresql.yaml - minecraft-project.yaml +- minecraft-cnpg.yaml - minecraft-paper.yaml - minecraft-atm10.yaml - bitnami-helm-repo.yaml diff --git a/bootstrap/minecraft-cnpg.yaml b/bootstrap/minecraft-cnpg.yaml new file mode 100644 index 0000000..d1ef001 --- /dev/null +++ b/bootstrap/minecraft-cnpg.yaml @@ -0,0 +1,21 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: minecraft-cnpg + namespace: argocd + annotations: + argocd.argoproj.io/sync-wave: "0" +spec: + project: minecraft + source: + repoURL: https://code.brunner.ninja/feedc0de/homelab-gitops.git + targetRevision: main + path: apps/minecraft-postgresql/cluster + destination: + server: https://kubernetes.default.svc + namespace: mcserver + syncPolicy: + automated: + enabled: true + prune: true + selfHeal: true diff --git a/bootstrap/minecraft-postgresql.yaml b/bootstrap/minecraft-postgresql.yaml index 90dfb03..d6af02a 100644 --- a/bootstrap/minecraft-postgresql.yaml +++ b/bootstrap/minecraft-postgresql.yaml @@ -5,23 +5,17 @@ metadata: namespace: argocd spec: project: minecraft - sources: - - repoURL: registry-1.docker.io/bitnamicharts - chart: postgresql - targetRevision: 18.12.4 - helm: - releaseName: paper - valueFiles: [$values/apps/minecraft-postgresql/values.yaml] - - repoURL: https://code.brunner.ninja/feedc0de/homelab-gitops.git - targetRevision: main - ref: values + source: + repoURL: https://code.brunner.ninja/feedc0de/homelab-gitops.git + targetRevision: main + path: apps/minecraft-postgresql/service destination: server: https://kubernetes.default.svc namespace: mcserver syncPolicy: automated: enabled: true - prune: false + prune: true selfHeal: true syncOptions: - CreateNamespace=true diff --git a/bootstrap/minecraft-project.yaml b/bootstrap/minecraft-project.yaml index 8fcb66a..acb3010 100644 --- a/bootstrap/minecraft-project.yaml +++ b/bootstrap/minecraft-project.yaml @@ -31,6 +31,8 @@ spec: kind: Deployment - group: apps kind: StatefulSet + - group: postgresql.cnpg.io + kind: Cluster - group: networking.k8s.io kind: NetworkPolicy - group: policy