From 7bdc495f8d922e9141d5aaf328e26ff8553fcf60 Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 30 Jul 2025 12:53:19 +0930 Subject: [PATCH 01/12] feat(postgres): Add base manifests ref: #18 --- manifests/postgres/base/Cluster.yaml | 83 ++++++++++++++++++++++ manifests/postgres/base/kustomization.yaml | 8 +++ 2 files changed, 91 insertions(+) create mode 100644 manifests/postgres/base/Cluster.yaml create mode 100644 manifests/postgres/base/kustomization.yaml diff --git a/manifests/postgres/base/Cluster.yaml b/manifests/postgres/base/Cluster.yaml new file mode 100644 index 0000000..c9eab54 --- /dev/null +++ b/manifests/postgres/base/Cluster.yaml @@ -0,0 +1,83 @@ +--- +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + labels: + app.kubernetes.io/component: base + app.kubernetes.io/instance: production + app.kubernetes.io/name: postgres + app.kubernetes.io/part-of: postgres + name: main +spec: + + affinity: + additionalPodAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 50 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: kubernetes.io/hostname + operator: Exists + topologyKey: kubernetes.io/hostname + + enablePodAntiAffinity: true + nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + preference: + matchExpressions: + - key: node-role.kubernetes.io/prime + operator: Exists + topologyKey: kubernetes.io/hostname + + # bootstrap: {} + + description: "Cluster PostgreSQL Instance" + + enableSuperuserAccess: false + + # externalClusters: [] + + imageName: ghcr.io/cloudnative-pg/postgresql:-updated_by_patch- + + inheritedMetadata: + labels: + app.kubernetes.io/component: base + app.kubernetes.io/instance: production + app.kubernetes.io/name: postgres + app.kubernetes.io/part-of: postgres + + instances: 3 + + # monitoring: {} + + nodeMaintenanceWindow: + inProgress: false + reusePVC: false + + primaryUpdateStrategy: supervised + + postgresql: + parameters: + max_parallel_workers: '34' + max_replication_slots: '32' + max_worker_processes: '34' + + # replica: {} + + resources: + requests: + cpu: "100m" + memory: "100Mi" + limits: + cpu: "2" + memory: "1Gi" + + startDelay: 300 + + stopDelay: 300 + + storage: + resizeInUseVolumes: false + size: 10Gi diff --git a/manifests/postgres/base/kustomization.yaml b/manifests/postgres/base/kustomization.yaml new file mode 100644 index 0000000..95cb127 --- /dev/null +++ b/manifests/postgres/base/kustomization.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: postgres + +resources: + - Cluster.yaml From fcb968714b49da22e879705b6fb186cc4f95a6b3 Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 30 Jul 2025 12:57:40 +0930 Subject: [PATCH 02/12] feat(postgres): Add Component to enable super user access ref: #18 --- .../kustomization.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 manifests/postgres/components/enable-super_user_access/kustomization.yaml diff --git a/manifests/postgres/components/enable-super_user_access/kustomization.yaml b/manifests/postgres/components/enable-super_user_access/kustomization.yaml new file mode 100644 index 0000000..38c0bf3 --- /dev/null +++ b/manifests/postgres/components/enable-super_user_access/kustomization.yaml @@ -0,0 +1,24 @@ +--- + +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + + +patches: + # yamllint disable rule:indentation + - patch: |- + + - op: replace + path: /spec/enableSuperuserAccess + value: true + + - op: add + path: /spec/superuserSecret + value: + name: cluster-superuser + + # yamllint enable rule:indentation + target: + group: postgresql.cnpg.io + version: v1 + kind: Cluster From 0b11792e942ba4b5f11c992a4d6af0967b36f67d Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 30 Jul 2025 12:58:20 +0930 Subject: [PATCH 03/12] feat(postgres): Add Component for HA multi-cluster replication ref: #18 --- .../components/ha/Cluster-main-02.yaml | 86 +++++++++++ .../components/ha/Service-main-r.yaml | 21 +++ .../components/ha/Service-main-ro.yaml | 21 +++ .../components/ha/Service-main-rw.yaml | 21 +++ .../postgres/components/ha/kustomization.yaml | 140 ++++++++++++++++++ 5 files changed, 289 insertions(+) create mode 100644 manifests/postgres/components/ha/Cluster-main-02.yaml create mode 100644 manifests/postgres/components/ha/Service-main-r.yaml create mode 100644 manifests/postgres/components/ha/Service-main-ro.yaml create mode 100644 manifests/postgres/components/ha/Service-main-rw.yaml create mode 100644 manifests/postgres/components/ha/kustomization.yaml diff --git a/manifests/postgres/components/ha/Cluster-main-02.yaml b/manifests/postgres/components/ha/Cluster-main-02.yaml new file mode 100644 index 0000000..aaeef40 --- /dev/null +++ b/manifests/postgres/components/ha/Cluster-main-02.yaml @@ -0,0 +1,86 @@ +--- +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + labels: + app.kubernetes.io/component: ha + app.kubernetes.io/instance: production + app.kubernetes.io/name: postgres + app.kubernetes.io/part-of: production-ha + name: main-02 +spec: + affinity: + additionalPodAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 50 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: kubernetes.io/hostname + operator: Exists + topologyKey: kubernetes.io/hostname + + enablePodAntiAffinity: true + nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + preference: + matchExpressions: + - key: node-role.kubernetes.io/prime + operator: Exists + topologyKey: kubernetes.io/hostname + + bootstrap: + pg_basebackup: + source: main-01 + + description: "Cluster PostgreSQL Instance" + + enableSuperuserAccess: false + + externalClusters: [] + + imageName: ghcr.io/cloudnative-pg/postgresql:-updated_by_patch- + + inheritedMetadata: + labels: + app.kubernetes.io/component: ha + app.kubernetes.io/instance: production + app.kubernetes.io/name: postgres + app.kubernetes.io/part-of: production-ha + + instances: 3 + + monitoring: {} + + nodeMaintenanceWindow: + inProgress: false + reusePVC: false + + primaryUpdateStrategy: supervised + + postgresql: + parameters: + max_parallel_workers: '34' + max_replication_slots: '32' + max_worker_processes: '34' + + replica: + primary: main-01 + source: main-01 + + resources: + requests: + cpu: "100m" + memory: "100Mi" + limits: + cpu: "2" + memory: "1Gi" + + startDelay: 300 + + stopDelay: 300 + + storage: + resizeInUseVolumes: false + size: 10Gi diff --git a/manifests/postgres/components/ha/Service-main-r.yaml b/manifests/postgres/components/ha/Service-main-r.yaml new file mode 100644 index 0000000..ee88e99 --- /dev/null +++ b/manifests/postgres/components/ha/Service-main-r.yaml @@ -0,0 +1,21 @@ +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/component: ha + app.kubernetes.io/instance: production + app.kubernetes.io/name: postgres + app.kubernetes.io/part-of: production-ha + name: main-r +spec: + ports: + - name: postgres + port: 5432 + protocol: TCP + targetPort: 5432 + selector: + cnpg.io/cluster: -updated_by_replacement- + cnpg.io/podRole: instance + sessionAffinity: None + type: ClusterIP diff --git a/manifests/postgres/components/ha/Service-main-ro.yaml b/manifests/postgres/components/ha/Service-main-ro.yaml new file mode 100644 index 0000000..73dab48 --- /dev/null +++ b/manifests/postgres/components/ha/Service-main-ro.yaml @@ -0,0 +1,21 @@ +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/component: ha + app.kubernetes.io/instance: production + app.kubernetes.io/name: postgres + app.kubernetes.io/part-of: production-ha + name: main-ro +spec: + ports: + - name: postgres + port: 5432 + protocol: TCP + targetPort: 5432 + selector: + cnpg.io/cluster: -updated_by_replacement- + cnpg.io/instanceRole: replica + sessionAffinity: None + type: ClusterIP diff --git a/manifests/postgres/components/ha/Service-main-rw.yaml b/manifests/postgres/components/ha/Service-main-rw.yaml new file mode 100644 index 0000000..0d51ee8 --- /dev/null +++ b/manifests/postgres/components/ha/Service-main-rw.yaml @@ -0,0 +1,21 @@ +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/component: ha + app.kubernetes.io/instance: production + app.kubernetes.io/name: postgres + app.kubernetes.io/part-of: production-ha + name: main-rw +spec: + ports: + - name: postgres + port: 5432 + protocol: TCP + targetPort: 5432 + selector: + cnpg.io/cluster: -updated_by_replacement- + cnpg.io/instanceRole: primary + sessionAffinity: None + type: ClusterIP diff --git a/manifests/postgres/components/ha/kustomization.yaml b/manifests/postgres/components/ha/kustomization.yaml new file mode 100644 index 0000000..4f3610f --- /dev/null +++ b/manifests/postgres/components/ha/kustomization.yaml @@ -0,0 +1,140 @@ +--- + +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + + +resources: + # - ../../base + - Cluster-main-02.yaml + - Service-main-r.yaml + - Service-main-ro.yaml + - Service-main-rw.yaml + + +patches: + + # yamllint disable rule:indentation + - patch: |- + + - op: add + path: /metadata/name + value: main-01 + + - op: replace + path: /spec/replica + value: + primary: main-01 + source: main-02 + + # yamllint enable rule:indentation + target: + group: postgresql.cnpg.io + version: v1 + kind: Cluster + name: main + + # yamllint disable rule:indentation + - patch: |- + + - op: replace + path: /spec/externalClusters + value: + + - name: main-01 + connectionParameters: + host: main-01-rw.updated_by_replacement.svc + user: streaming_replica + dbname: postgres + sslmode: verify-full + sslKey: + name: main-01-replication + key: tls.key + sslCert: + name: main-01-replication + key: tls.crt + sslRootCert: + name: main-01-ca + key: ca.crt + + - name: main-02 + connectionParameters: + host: main-02-rw.updated_by_replacement.svc + user: streaming_replica + dbname: postgres + sslmode: verify-full + sslKey: + name: main-02-replication + key: tls.key + sslCert: + name: main-02-replication + key: tls.crt + sslRootCert: + name: main-02-ca + key: ca.crt + + # yamllint enable rule:indentation + target: + group: postgresql.cnpg.io + version: v1 + kind: Cluster + + + +replacements: + # + # Add to Top-most Kustomization.yaml + # + # Updates extenal cluster DNS name octet that contains the namespace + # - source: + # kind: Cluster + # name: main-01 + # fieldPath: metadata.namespace + # targets: + # - select: + # kind: Cluster + # fieldPaths: + # - spec.externalClusters.[name=main-01].connectionParameters.host + # - spec.externalClusters.[name=main-02].connectionParameters.host + # options: + # delimiter: "." + # index: 1 + + + # + # Add to Top-most Kustomization.yaml, if primary has be changed + # + # Updates each of the services to point the cluster that is denoted as primary + # within cluster main-02 + - source: + kind: Cluster + name: main-02 + fieldPath: spec.replica.primary + targets: + - select: + kind: Service + name: main-r + fieldPaths: + - spec.selector.[cnpg.io/cluster] + - select: + kind: Service + name: main-ro + fieldPaths: + - spec.selector.[cnpg.io/cluster] + - select: + kind: Service + name: main-rw + fieldPaths: + - spec.selector.[cnpg.io/cluster] + + # Dont change + - source: + kind: Cluster + name: main-02 + fieldPath: metadata.labels.[app.kubernetes.io/part-of] + targets: + - select: + kind: Cluster + fieldPaths: + - metadata.labels.[app.kubernetes.io/part-of] + - spec.inheritedMetadata.labels.[app.kubernetes.io/part-of] From 9ba893f79cc9208eeb4abb4a1e4a3bad29fdbded Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 30 Jul 2025 12:58:37 +0930 Subject: [PATCH 04/12] feat(postgres): Add Component to enable metrics for cluster(s) ref: #18 --- .../components/metrics/kustomization.yaml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 manifests/postgres/components/metrics/kustomization.yaml diff --git a/manifests/postgres/components/metrics/kustomization.yaml b/manifests/postgres/components/metrics/kustomization.yaml new file mode 100644 index 0000000..aaba1f9 --- /dev/null +++ b/manifests/postgres/components/metrics/kustomization.yaml @@ -0,0 +1,29 @@ +--- + +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + + +patches: + # yamllint disable rule:indentation + - patch: |- + + - op: add + path: /spec/monitoring + value: + enablePodMonitor: true + + - op: add + path: /spec/monitoring/podMonitorRelabelings + value: + - sourceLabels: ["__meta_kubernetes_pod_label_cnpg_io_cluster"] + targetLabel: cluster + action: replace + - sourceLabels: ["__meta_kubernetes_pod_name"] + targetLabel: instance + action: replace + # yamllint enable rule:indentation + target: + group: postgresql.cnpg.io + version: v1 + kind: Cluster From fbf09e6fdaf0dff4b3cd74d77305c3c36e181ecf Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 30 Jul 2025 12:59:30 +0930 Subject: [PATCH 05/12] feat(postgres): Add Overlay Production ref: #18 --- .../overlays/production/kustomization.yaml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 manifests/postgres/overlays/production/kustomization.yaml diff --git a/manifests/postgres/overlays/production/kustomization.yaml b/manifests/postgres/overlays/production/kustomization.yaml new file mode 100644 index 0000000..f448f5c --- /dev/null +++ b/manifests/postgres/overlays/production/kustomization.yaml @@ -0,0 +1,27 @@ +--- + +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + + +resources: + - ../../base + + +components: + - ../../components/metrics + + +patches: + # + # Add to Top-most Kustomization.yaml + # + # yamllint disable rule:indentation + - patch: |- + + - op: replace + path: /spec/imageName + value: ghcr.io/cloudnative-pg/postgresql:15.12-11 + # yamllint enable rule:indentation + target: + kind: Cluster From ffed3da5d964c994e7e6f9047a719a00d856cd9d Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 30 Jul 2025 12:59:37 +0930 Subject: [PATCH 06/12] feat(postgres): Add Overlay HA ref: #18 --- .../postgres/overlays/ha/kustomization.yaml | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 manifests/postgres/overlays/ha/kustomization.yaml diff --git a/manifests/postgres/overlays/ha/kustomization.yaml b/manifests/postgres/overlays/ha/kustomization.yaml new file mode 100644 index 0000000..9f388d7 --- /dev/null +++ b/manifests/postgres/overlays/ha/kustomization.yaml @@ -0,0 +1,55 @@ +--- + +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: postgres-15 + + +resources: + - ../production + + +components: + - ../../components/ha + + +patches: + + # yamllint disable rule:indentation + - patch: |- + + - op: replace + path: /spec/instances + value: 2 + # yamllint enable rule:indentation + target: + kind: Cluster + + # yamllint disable rule:indentation + - patch: |- + + - op: replace + path: /spec/imageName + value: ghcr.io/cloudnative-pg/postgresql:15.12-11 + # yamllint enable rule:indentation + target: + kind: Cluster + + +replacements: + + # Updates extenal cluster DNS name octet that contains the namespace + - source: + kind: Cluster + name: main-01 + fieldPath: metadata.namespace + targets: + - select: + kind: Cluster + fieldPaths: + - spec.externalClusters.[name=main-01].connectionParameters.host + - spec.externalClusters.[name=main-02].connectionParameters.host + options: + delimiter: "." + index: 1 From dde13cb8597796be30dc8d51d8ad283f6797bad0 Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 30 Jul 2025 14:12:38 +0930 Subject: [PATCH 07/12] feat(postgres): Add pod and node affinity ref: #18 --- manifests/postgres/base/Cluster.yaml | 18 +++++++++++++++--- .../components/ha/Cluster-main-02.yaml | 19 ++++++++++++++++--- .../postgres/components/ha/kustomization.yaml | 14 ++++++++++++++ 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/manifests/postgres/base/Cluster.yaml b/manifests/postgres/base/Cluster.yaml index c9eab54..093ff93 100644 --- a/manifests/postgres/base/Cluster.yaml +++ b/manifests/postgres/base/Cluster.yaml @@ -13,17 +13,29 @@ spec: affinity: additionalPodAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: - - weight: 50 + - weight: 100 podAffinityTerm: labelSelector: matchExpressions: - - key: kubernetes.io/hostname - operator: Exists + - key: app.kubernetes.io/name + operator: In + values: + - postgres topologyKey: kubernetes.io/hostname enablePodAntiAffinity: true nodeAffinity: preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + preference: + matchExpressions: + - key: node-role.kubernetes.io/control-plane + operator: Exists + - weight: 50 + preference: + matchExpressions: + - key: node-role.kubernetes.io/master + operator: Exists - weight: 100 preference: matchExpressions: diff --git a/manifests/postgres/components/ha/Cluster-main-02.yaml b/manifests/postgres/components/ha/Cluster-main-02.yaml index aaeef40..1cab197 100644 --- a/manifests/postgres/components/ha/Cluster-main-02.yaml +++ b/manifests/postgres/components/ha/Cluster-main-02.yaml @@ -9,20 +9,33 @@ metadata: app.kubernetes.io/part-of: production-ha name: main-02 spec: + affinity: additionalPodAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: - - weight: 50 + - weight: 100 podAffinityTerm: labelSelector: matchExpressions: - - key: kubernetes.io/hostname - operator: Exists + - key: app.kubernetes.io/name + operator: In + values: + - postgres topologyKey: kubernetes.io/hostname enablePodAntiAffinity: true nodeAffinity: preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + preference: + matchExpressions: + - key: node-role.kubernetes.io/control-plane + operator: Exists + - weight: 50 + preference: + matchExpressions: + - key: node-role.kubernetes.io/master + operator: Exists - weight: 100 preference: matchExpressions: diff --git a/manifests/postgres/components/ha/kustomization.yaml b/manifests/postgres/components/ha/kustomization.yaml index 4f3610f..f897f70 100644 --- a/manifests/postgres/components/ha/kustomization.yaml +++ b/manifests/postgres/components/ha/kustomization.yaml @@ -37,6 +37,20 @@ patches: # yamllint disable rule:indentation - patch: |- + - op: add + path: /spec/affinity/additionalPodAntiAffinity/preferredDuringSchedulingIgnoredDuringExecution/0 + value: + weight: 100 + podAffinityTerm: + labelSelector: + matchExpressions: + - key: app.kubernetes.io/part-of + operator: In + values: + - production-ha + topologyKey: kubernetes.io/hostname + + - op: replace path: /spec/externalClusters value: From 51af18af8bbab82472a30e61fa744b4bfc8ab637 Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 30 Jul 2025 14:12:50 +0930 Subject: [PATCH 08/12] docs(postgres): Add readme ref: #18 --- manifests/postgres/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 manifests/postgres/README.md diff --git a/manifests/postgres/README.md b/manifests/postgres/README.md new file mode 100644 index 0000000..cc6373c --- /dev/null +++ b/manifests/postgres/README.md @@ -0,0 +1,15 @@ +# PostgreSQL Cluster including HA Multi-cluster replication + +Following Components are available: + +- `enable-super_user_access` Enable super user account and access to cluster + +- `ha` Deploy replicated multi-cluster in master-slave configuration + +- `metrics` Enable prometheus metrics endpoint + +Following Overlays are available: + +- `Production` - Base deployment manifests + +- `HA` - HA Multi-Cluster deployment with replication between clusters From 287f784011ed714b81ac3833ddb5dc42a5ccf0dc Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 30 Jul 2025 16:11:28 +0930 Subject: [PATCH 09/12] feat(postgres): PrimaryUpdateStrategy set to `unsupervised` required so that chaning primary cluster functions ref: #18 --- manifests/postgres/base/Cluster.yaml | 2 +- manifests/postgres/components/ha/Cluster-main-02.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/postgres/base/Cluster.yaml b/manifests/postgres/base/Cluster.yaml index 093ff93..ec23942 100644 --- a/manifests/postgres/base/Cluster.yaml +++ b/manifests/postgres/base/Cluster.yaml @@ -68,7 +68,7 @@ spec: inProgress: false reusePVC: false - primaryUpdateStrategy: supervised + primaryUpdateStrategy: unsupervised postgresql: parameters: diff --git a/manifests/postgres/components/ha/Cluster-main-02.yaml b/manifests/postgres/components/ha/Cluster-main-02.yaml index 1cab197..64e1f31 100644 --- a/manifests/postgres/components/ha/Cluster-main-02.yaml +++ b/manifests/postgres/components/ha/Cluster-main-02.yaml @@ -70,7 +70,7 @@ spec: inProgress: false reusePVC: false - primaryUpdateStrategy: supervised + primaryUpdateStrategy: unsupervised postgresql: parameters: From 434e07f185ab16b2ccadf7b49396b93a929e6923 Mon Sep 17 00:00:00 2001 From: Jon Date: Sat, 2 Aug 2025 13:00:27 +0930 Subject: [PATCH 10/12] feat(postgres): Enable metrics for all clusters ref: #18 --- manifests/postgres/overlays/ha/kustomization.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/postgres/overlays/ha/kustomization.yaml b/manifests/postgres/overlays/ha/kustomization.yaml index 9f388d7..6449703 100644 --- a/manifests/postgres/overlays/ha/kustomization.yaml +++ b/manifests/postgres/overlays/ha/kustomization.yaml @@ -7,11 +7,12 @@ namespace: postgres-15 resources: - - ../production + - ../../base components: - ../../components/ha + - ../../components/metrics patches: From 65840a8e60eec0d6d14bcc44f01de5f21217745e Mon Sep 17 00:00:00 2001 From: Jon Date: Sat, 2 Aug 2025 13:52:29 +0930 Subject: [PATCH 11/12] feat(postgres): Add cnpg grafana dashboard as component ref: #18 --- .../GrafanaDashboard-cloudnativepg.yaml | 17 +++++++++++++++++ .../components/dashboard/kustomization.yaml | 7 +++++++ .../postgres/overlays/ha/kustomization.yaml | 1 + 3 files changed, 25 insertions(+) create mode 100644 manifests/postgres/components/dashboard/GrafanaDashboard-cloudnativepg.yaml create mode 100644 manifests/postgres/components/dashboard/kustomization.yaml diff --git a/manifests/postgres/components/dashboard/GrafanaDashboard-cloudnativepg.yaml b/manifests/postgres/components/dashboard/GrafanaDashboard-cloudnativepg.yaml new file mode 100644 index 0000000..504f001 --- /dev/null +++ b/manifests/postgres/components/dashboard/GrafanaDashboard-cloudnativepg.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: grafana.integreatly.org/v1beta1 +kind: GrafanaDashboard +metadata: + labels: + app.kubernetes.io/component: database + name: cloudnativepg +spec: + allowCrossNamespaceImport: true + folder: "General" + resyncPeriod: 24h + instanceSelector: + matchLabels: + dashboards: grafana + grafanaCom: + id: 20417 + revision: 4 # as @ 2025-08-02 diff --git a/manifests/postgres/components/dashboard/kustomization.yaml b/manifests/postgres/components/dashboard/kustomization.yaml new file mode 100644 index 0000000..64457a7 --- /dev/null +++ b/manifests/postgres/components/dashboard/kustomization.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + + +resources: + - GrafanaDashboard-cloudnativepg.yaml diff --git a/manifests/postgres/overlays/ha/kustomization.yaml b/manifests/postgres/overlays/ha/kustomization.yaml index 6449703..bfbcc17 100644 --- a/manifests/postgres/overlays/ha/kustomization.yaml +++ b/manifests/postgres/overlays/ha/kustomization.yaml @@ -13,6 +13,7 @@ resources: components: - ../../components/ha - ../../components/metrics + - ../../components/dashboard patches: From a5a2e7f248783ddd3c456823bf5f8fc8d9bac352 Mon Sep 17 00:00:00 2001 From: Jon Date: Sat, 2 Aug 2025 14:28:50 +0930 Subject: [PATCH 12/12] feat(cnpg-operator): Add PodMonitor as component ref: #18 --- .../metrics/PodMonitor-cnpg-controller-manager.yaml | 11 +++++++++++ .../components/metrics/kustomization.yaml | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 manifests/cloudnativepg-operator/components/metrics/PodMonitor-cnpg-controller-manager.yaml create mode 100644 manifests/cloudnativepg-operator/components/metrics/kustomization.yaml diff --git a/manifests/cloudnativepg-operator/components/metrics/PodMonitor-cnpg-controller-manager.yaml b/manifests/cloudnativepg-operator/components/metrics/PodMonitor-cnpg-controller-manager.yaml new file mode 100644 index 0000000..3926a6a --- /dev/null +++ b/manifests/cloudnativepg-operator/components/metrics/PodMonitor-cnpg-controller-manager.yaml @@ -0,0 +1,11 @@ +--- +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: cnpg-controller-manager +spec: + selector: + matchLabels: + app.kubernetes.io/name: cloudnative-pg + podMetricsEndpoints: + - port: metrics diff --git a/manifests/cloudnativepg-operator/components/metrics/kustomization.yaml b/manifests/cloudnativepg-operator/components/metrics/kustomization.yaml new file mode 100644 index 0000000..6657fd9 --- /dev/null +++ b/manifests/cloudnativepg-operator/components/metrics/kustomization.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + + +resources: + - PodMonitor-cnpg-controller-manager.yaml