From d5c6429205cfda2cde5b966b00f1ba1a41be3949 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Mon, 15 Dec 2025 03:13:39 +0100 Subject: [PATCH] feat: Added cnpg --- clusters/testing/kustomization.yaml | 1 + controllers/artifacts.yaml | 7 ++++- controllers/cnpg/base/helm-release.yaml | 29 +++++++++++++++++++ controllers/cnpg/base/helm-repository.yaml | 8 +++++ controllers/cnpg/base/kustomization.yaml | 15 ++++++++++ controllers/cnpg/base/name-reference.yaml | 6 ++++ controllers/cnpg/base/namespace.yaml | 4 +++ controllers/cnpg/base/values.yaml | 0 controllers/cnpg/cnpg.yaml | 15 ++++++++++ .../cnpg/production/kustomization.yaml | 10 +++++++ controllers/cnpg/production/values.yaml | 1 + controllers/cnpg/staging/kustomization.yaml | 10 +++++++ controllers/cnpg/staging/values.yaml | 1 + 13 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 controllers/cnpg/base/helm-release.yaml create mode 100644 controllers/cnpg/base/helm-repository.yaml create mode 100644 controllers/cnpg/base/kustomization.yaml create mode 100644 controllers/cnpg/base/name-reference.yaml create mode 100644 controllers/cnpg/base/namespace.yaml create mode 100644 controllers/cnpg/base/values.yaml create mode 100644 controllers/cnpg/cnpg.yaml create mode 100644 controllers/cnpg/production/kustomization.yaml create mode 100644 controllers/cnpg/production/values.yaml create mode 100644 controllers/cnpg/staging/kustomization.yaml create mode 100644 controllers/cnpg/staging/values.yaml diff --git a/clusters/testing/kustomization.yaml b/clusters/testing/kustomization.yaml index 0534bf9..3add58d 100644 --- a/clusters/testing/kustomization.yaml +++ b/clusters/testing/kustomization.yaml @@ -9,6 +9,7 @@ resources: - ../../controllers/spegel/spegel.yaml - ../../controllers/longhorn/longhorn.yaml - ../../controllers/local-path-provisioner/local-path-provisioner.yaml + - ../../controllers/cnpg/cnpg.yaml - ../../configs/artifacts.yaml - ../../configs/letsencrypt/letsencrypt.yaml diff --git a/controllers/artifacts.yaml b/controllers/artifacts.yaml index 97c751f..d8b7341 100644 --- a/controllers/artifacts.yaml +++ b/controllers/artifacts.yaml @@ -37,5 +37,10 @@ spec: - name: local-path-provisioner originRevision: "@foundation" copy: - - from: "@foundation/controllers/local-path-provisioner/**" + - from: "@foundation/controllers/local-path-provisioner**" + to: "@artifact/" + - name: cnpg + originRevision: "@foundation" + copy: + - from: "@foundation/controllers/cnpg/**" to: "@artifact/" diff --git a/controllers/cnpg/base/helm-release.yaml b/controllers/cnpg/base/helm-release.yaml new file mode 100644 index 0000000..d53f583 --- /dev/null +++ b/controllers/cnpg/base/helm-release.yaml @@ -0,0 +1,29 @@ +apiVersion: helm.toolkit.fluxcd.io/v2 +kind: HelmRelease +metadata: + name: cnpg + namespace: cnpg-system +spec: + interval: 12h + install: + strategy: + name: RetryOnFailure + retryInterval: 2m + upgrade: + strategy: + name: RetryOnFailure + retryInterval: 3m + chart: + spec: + chart: cloudnative-pg + version: "0.27.x" + sourceRef: + kind: HelmRepository + name: cnpg + interval: 24h + valuesFrom: + - kind: ConfigMap + name: values-base + - kind: ConfigMap + name: values-overlay + optional: true diff --git a/controllers/cnpg/base/helm-repository.yaml b/controllers/cnpg/base/helm-repository.yaml new file mode 100644 index 0000000..8d65353 --- /dev/null +++ b/controllers/cnpg/base/helm-repository.yaml @@ -0,0 +1,8 @@ +apiVersion: source.toolkit.fluxcd.io/v1 +kind: HelmRepository +metadata: + name: cnpg + namespace: cnpg-system +spec: + interval: 24h + url: https://cloudnative-pg.github.io/charts diff --git a/controllers/cnpg/base/kustomization.yaml b/controllers/cnpg/base/kustomization.yaml new file mode 100644 index 0000000..0003ced --- /dev/null +++ b/controllers/cnpg/base/kustomization.yaml @@ -0,0 +1,15 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - namespace.yaml + - helm-repository.yaml + - helm-release.yaml + +configurations: + - name-reference.yaml + +configMapGenerator: + - name: values-base + namespace: cnpg-system + files: + - values.yaml diff --git a/controllers/cnpg/base/name-reference.yaml b/controllers/cnpg/base/name-reference.yaml new file mode 100644 index 0000000..a80be15 --- /dev/null +++ b/controllers/cnpg/base/name-reference.yaml @@ -0,0 +1,6 @@ +nameReference: + - kind: ConfigMap + version: v1 + fieldSpecs: + - path: spec/valuesFrom/name + kind: HelmRelease diff --git a/controllers/cnpg/base/namespace.yaml b/controllers/cnpg/base/namespace.yaml new file mode 100644 index 0000000..8deac4c --- /dev/null +++ b/controllers/cnpg/base/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: cnpg-system diff --git a/controllers/cnpg/base/values.yaml b/controllers/cnpg/base/values.yaml new file mode 100644 index 0000000..e69de29 diff --git a/controllers/cnpg/cnpg.yaml b/controllers/cnpg/cnpg.yaml new file mode 100644 index 0000000..ce2594b --- /dev/null +++ b/controllers/cnpg/cnpg.yaml @@ -0,0 +1,15 @@ +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: cnpg + namespace: flux-system +spec: + interval: 1h + retryInterval: 2m + timeout: 5m + sourceRef: + kind: ExternalArtifact + name: cnpg + path: ./${cluster_env} + prune: true + wait: true diff --git a/controllers/cnpg/production/kustomization.yaml b/controllers/cnpg/production/kustomization.yaml new file mode 100644 index 0000000..1c527eb --- /dev/null +++ b/controllers/cnpg/production/kustomization.yaml @@ -0,0 +1,10 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../base + +configMapGenerator: + - name: values-overlay + namespace: cnpg-system + files: + - values.yaml diff --git a/controllers/cnpg/production/values.yaml b/controllers/cnpg/production/values.yaml new file mode 100644 index 0000000..5ef7832 --- /dev/null +++ b/controllers/cnpg/production/values.yaml @@ -0,0 +1 @@ +replicaCount: 2 diff --git a/controllers/cnpg/staging/kustomization.yaml b/controllers/cnpg/staging/kustomization.yaml new file mode 100644 index 0000000..1c527eb --- /dev/null +++ b/controllers/cnpg/staging/kustomization.yaml @@ -0,0 +1,10 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../base + +configMapGenerator: + - name: values-overlay + namespace: cnpg-system + files: + - values.yaml diff --git a/controllers/cnpg/staging/values.yaml b/controllers/cnpg/staging/values.yaml new file mode 100644 index 0000000..ebf6be8 --- /dev/null +++ b/controllers/cnpg/staging/values.yaml @@ -0,0 +1 @@ +replicaCount: 1