From 9396dce44bcd563577ae33dd59d3958b82564f25 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Sun, 25 Oct 2026 12:59:45 +0100 Subject: [PATCH] Provision Nextcloud PostgreSQL with CloudNativePG --- .../nextcloud-postgresql/cluster/cluster.yaml | 18 ++++++++++++++++ .../cluster/kustomization.yaml | 4 ++++ .../service/kustomization.yaml | 4 ++++ .../nextcloud-postgresql/service/service.yaml | 15 +++++++++++++ bootstrap/kustomization.yaml | 2 ++ bootstrap/nextcloud-cnpg.yaml | 21 +++++++++++++++++++ bootstrap/nextcloud-postgresql.yaml | 19 +++++++++++++++++ bootstrap/nextcloud-project.yaml | 2 ++ 8 files changed, 85 insertions(+) create mode 100644 apps/nextcloud-postgresql/cluster/cluster.yaml create mode 100644 apps/nextcloud-postgresql/cluster/kustomization.yaml create mode 100644 apps/nextcloud-postgresql/service/kustomization.yaml create mode 100644 apps/nextcloud-postgresql/service/service.yaml create mode 100644 bootstrap/nextcloud-cnpg.yaml create mode 100644 bootstrap/nextcloud-postgresql.yaml diff --git a/apps/nextcloud-postgresql/cluster/cluster.yaml b/apps/nextcloud-postgresql/cluster/cluster.yaml new file mode 100644 index 0000000..0d26023 --- /dev/null +++ b/apps/nextcloud-postgresql/cluster/cluster.yaml @@ -0,0 +1,18 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: nextcloud-cnpg + namespace: nextcloud +spec: + instances: 1 + enableSuperuserAccess: true + imageName: ghcr.io/cloudnative-pg/postgresql:17.11-standard-trixie + bootstrap: + initdb: + database: nextcloud + owner: nextcloud + secret: + name: nextcloud-cnpg-bootstrap + storage: + size: 8Gi + storageClass: rook-ceph-block diff --git a/apps/nextcloud-postgresql/cluster/kustomization.yaml b/apps/nextcloud-postgresql/cluster/kustomization.yaml new file mode 100644 index 0000000..993fbde --- /dev/null +++ b/apps/nextcloud-postgresql/cluster/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - cluster.yaml diff --git a/apps/nextcloud-postgresql/service/kustomization.yaml b/apps/nextcloud-postgresql/service/kustomization.yaml new file mode 100644 index 0000000..9bb4d07 --- /dev/null +++ b/apps/nextcloud-postgresql/service/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - service.yaml diff --git a/apps/nextcloud-postgresql/service/service.yaml b/apps/nextcloud-postgresql/service/service.yaml new file mode 100644 index 0000000..2ac6115 --- /dev/null +++ b/apps/nextcloud-postgresql/service/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: nextcloud-postgresql + namespace: nextcloud +spec: + type: ClusterIP + ports: + - name: postgresql + port: 5432 + protocol: TCP + targetPort: 5432 + selector: + cnpg.io/cluster: nextcloud-cnpg + cnpg.io/instanceRole: primary diff --git a/bootstrap/kustomization.yaml b/bootstrap/kustomization.yaml index 1a784a8..b7cfe65 100644 --- a/bootstrap/kustomization.yaml +++ b/bootstrap/kustomization.yaml @@ -120,6 +120,8 @@ resources: - quay-postgresql.yaml - quay.yaml - nextcloud-project.yaml +- nextcloud-cnpg.yaml +- nextcloud-postgresql.yaml - nextcloud.yaml - fediverse-project.yaml - fediverse-namespaces.yaml diff --git a/bootstrap/nextcloud-cnpg.yaml b/bootstrap/nextcloud-cnpg.yaml new file mode 100644 index 0000000..3e6c5bc --- /dev/null +++ b/bootstrap/nextcloud-cnpg.yaml @@ -0,0 +1,21 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: nextcloud-cnpg + namespace: argocd + annotations: + argocd.argoproj.io/sync-wave: "0" +spec: + project: nextcloud + source: + repoURL: https://code.brunner.ninja/feedc0de/homelab-gitops.git + targetRevision: main + path: apps/nextcloud-postgresql/cluster + destination: + server: https://kubernetes.default.svc + namespace: nextcloud + syncPolicy: + automated: + enabled: true + prune: true + selfHeal: true diff --git a/bootstrap/nextcloud-postgresql.yaml b/bootstrap/nextcloud-postgresql.yaml new file mode 100644 index 0000000..f104970 --- /dev/null +++ b/bootstrap/nextcloud-postgresql.yaml @@ -0,0 +1,19 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: nextcloud-postgresql + namespace: argocd +spec: + project: nextcloud + source: + repoURL: https://code.brunner.ninja/feedc0de/homelab-gitops.git + targetRevision: main + path: apps/nextcloud-postgresql/service + destination: + server: https://kubernetes.default.svc + namespace: nextcloud + syncPolicy: + automated: + enabled: true + prune: true + selfHeal: true diff --git a/bootstrap/nextcloud-project.yaml b/bootstrap/nextcloud-project.yaml index 298efdb..04475f4 100644 --- a/bootstrap/nextcloud-project.yaml +++ b/bootstrap/nextcloud-project.yaml @@ -29,6 +29,8 @@ spec: kind: Deployment - group: apps kind: StatefulSet + - group: postgresql.cnpg.io + kind: Cluster - group: networking.k8s.io kind: Ingress - group: networking.k8s.io