From bdc35b8d452df105cf02b7e90abf6df858ec82cf Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Tue, 9 Dec 2025 02:37:21 +0100 Subject: [PATCH] feat: Separate config for production/testing --- .../longhorn/{ => base}/helm-release.yaml | 20 ++++++------------- .../longhorn/{ => base}/helm-repository.yaml | 0 controllers/longhorn/base/kustomization.yaml | 15 ++++++++++++++ controllers/longhorn/base/name-reference.yaml | 6 ++++++ .../longhorn/{ => base}/namespace.yaml | 0 controllers/longhorn/base/values.yaml | 10 ++++++++++ controllers/longhorn/kustomization.yaml | 6 ------ controllers/longhorn/longhorn.yaml | 2 +- .../longhorn/production/kustomization.yaml | 10 ++++++++++ controllers/longhorn/production/values.yaml | 4 ++++ .../longhorn/staging/kustomization.yaml | 10 ++++++++++ controllers/longhorn/staging/values.yaml | 4 ++++ 12 files changed, 66 insertions(+), 21 deletions(-) rename controllers/longhorn/{ => base}/helm-release.yaml (50%) rename controllers/longhorn/{ => base}/helm-repository.yaml (100%) create mode 100644 controllers/longhorn/base/kustomization.yaml create mode 100644 controllers/longhorn/base/name-reference.yaml rename controllers/longhorn/{ => base}/namespace.yaml (100%) create mode 100644 controllers/longhorn/base/values.yaml delete mode 100644 controllers/longhorn/kustomization.yaml create mode 100644 controllers/longhorn/production/kustomization.yaml create mode 100644 controllers/longhorn/production/values.yaml create mode 100644 controllers/longhorn/staging/kustomization.yaml create mode 100644 controllers/longhorn/staging/values.yaml diff --git a/controllers/longhorn/helm-release.yaml b/controllers/longhorn/base/helm-release.yaml similarity index 50% rename from controllers/longhorn/helm-release.yaml rename to controllers/longhorn/base/helm-release.yaml index 81b6b9e..43af7f9 100644 --- a/controllers/longhorn/helm-release.yaml +++ b/controllers/longhorn/base/helm-release.yaml @@ -22,17 +22,9 @@ spec: kind: HelmRepository name: longhorn interval: 24h - values: - # TODO: These settings are specific to testing - defaultSettings: - defaultReplicaCount: 1 - defaultDataPath: /var/mnt/longhorn - replicaAutoBalance: best-effort - defaultDataLocality: best-effort - freezeFilesystemForSnapshot: true - storageReservedPercentageForDefaultDisk: 0 - storageMinimalAvailablePercentage: 10 - storageOverProvisioningPercentage: 25 - persistence: - defaultClassReplicaCount: 1 - defaultDataLocality: best-effort + valuesFrom: + - kind: ConfigMap + name: values-base + - kind: ConfigMap + name: values-overlay + optional: true diff --git a/controllers/longhorn/helm-repository.yaml b/controllers/longhorn/base/helm-repository.yaml similarity index 100% rename from controllers/longhorn/helm-repository.yaml rename to controllers/longhorn/base/helm-repository.yaml diff --git a/controllers/longhorn/base/kustomization.yaml b/controllers/longhorn/base/kustomization.yaml new file mode 100644 index 0000000..6614f10 --- /dev/null +++ b/controllers/longhorn/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: longhorn-system + files: + - values.yaml diff --git a/controllers/longhorn/base/name-reference.yaml b/controllers/longhorn/base/name-reference.yaml new file mode 100644 index 0000000..a80be15 --- /dev/null +++ b/controllers/longhorn/base/name-reference.yaml @@ -0,0 +1,6 @@ +nameReference: + - kind: ConfigMap + version: v1 + fieldSpecs: + - path: spec/valuesFrom/name + kind: HelmRelease diff --git a/controllers/longhorn/namespace.yaml b/controllers/longhorn/base/namespace.yaml similarity index 100% rename from controllers/longhorn/namespace.yaml rename to controllers/longhorn/base/namespace.yaml diff --git a/controllers/longhorn/base/values.yaml b/controllers/longhorn/base/values.yaml new file mode 100644 index 0000000..b1ee9b1 --- /dev/null +++ b/controllers/longhorn/base/values.yaml @@ -0,0 +1,10 @@ +defaultSettings: + defaultDataPath: /var/mnt/longhorn + replicaAutoBalance: best-effort + defaultDataLocality: best-effort + freezeFilesystemForSnapshot: true + storageReservedPercentageForDefaultDisk: 0 + storageMinimalAvailablePercentage: 10 + storageOverProvisioningPercentage: 25 +persistence: + defaultDataLocality: best-effort diff --git a/controllers/longhorn/kustomization.yaml b/controllers/longhorn/kustomization.yaml deleted file mode 100644 index 30ecafd..0000000 --- a/controllers/longhorn/kustomization.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - namespace.yaml - - helm-repository.yaml - - helm-release.yaml diff --git a/controllers/longhorn/longhorn.yaml b/controllers/longhorn/longhorn.yaml index fb2c841..1b7a058 100644 --- a/controllers/longhorn/longhorn.yaml +++ b/controllers/longhorn/longhorn.yaml @@ -10,6 +10,6 @@ spec: sourceRef: kind: ExternalArtifact name: longhorn - path: ./ + path: ./${cluster_env} prune: true wait: true diff --git a/controllers/longhorn/production/kustomization.yaml b/controllers/longhorn/production/kustomization.yaml new file mode 100644 index 0000000..75f1377 --- /dev/null +++ b/controllers/longhorn/production/kustomization.yaml @@ -0,0 +1,10 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../base + +configMapGenerator: + - name: values-overlay + namespace: longhorn-system + files: + - values.yaml diff --git a/controllers/longhorn/production/values.yaml b/controllers/longhorn/production/values.yaml new file mode 100644 index 0000000..86057af --- /dev/null +++ b/controllers/longhorn/production/values.yaml @@ -0,0 +1,4 @@ +defaultSettings: + defaultReplicaCount: 2 +persistence: + defaultClassReplicaCount: 2 diff --git a/controllers/longhorn/staging/kustomization.yaml b/controllers/longhorn/staging/kustomization.yaml new file mode 100644 index 0000000..75f1377 --- /dev/null +++ b/controllers/longhorn/staging/kustomization.yaml @@ -0,0 +1,10 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../base + +configMapGenerator: + - name: values-overlay + namespace: longhorn-system + files: + - values.yaml diff --git a/controllers/longhorn/staging/values.yaml b/controllers/longhorn/staging/values.yaml new file mode 100644 index 0000000..076a8e5 --- /dev/null +++ b/controllers/longhorn/staging/values.yaml @@ -0,0 +1,4 @@ +defaultSettings: + defaultReplicaCount: 1 +persistence: + defaultClassReplicaCount: 1