From ec33f6b980bd545ee700de4c9413dd2b83184cd9 Mon Sep 17 00:00:00 2001 From: Timofei Larkin Date: Mon, 5 Jan 2026 19:16:45 +0300 Subject: [PATCH] Draft: generate cozystack values Signed-off-by: Timofei Larkin --- packages/system/cozystack-values/Chart.yaml | 4 ++ .../system/cozystack-values/helmrelease.yaml | 65 +++++++++++++++++++ .../cozystack-values/templates/secret.yaml | 54 +++++++++++++++ packages/system/cozystack-values/values.yaml | 18 +++++ 4 files changed, 141 insertions(+) create mode 100644 packages/system/cozystack-values/Chart.yaml create mode 100644 packages/system/cozystack-values/helmrelease.yaml create mode 100644 packages/system/cozystack-values/templates/secret.yaml create mode 100644 packages/system/cozystack-values/values.yaml diff --git a/packages/system/cozystack-values/Chart.yaml b/packages/system/cozystack-values/Chart.yaml new file mode 100644 index 00000000..68760e1f --- /dev/null +++ b/packages/system/cozystack-values/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v2 +name: cozy-cozystack-values +version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process + diff --git a/packages/system/cozystack-values/helmrelease.yaml b/packages/system/cozystack-values/helmrelease.yaml new file mode 100644 index 00000000..6d14382b --- /dev/null +++ b/packages/system/cozystack-values/helmrelease.yaml @@ -0,0 +1,65 @@ +apiVersion: helm.toolkit.fluxcd.io/v2 +kind: HelmRelease +metadata: + name: cozystack-values + namespace: tenant-root + labels: + cozystack.io/repository: system + cozystack.io/system-app: "true" +spec: + interval: 5m + releaseName: cozystack-values + install: + remediation: + retries: -1 + upgrade: + remediation: + retries: -1 + chart: + spec: + chart: cozy-cozystack-values + reconcileStrategy: Revision + sourceRef: + kind: HelmRepository + name: cozystack-system + namespace: cozy-system + version: '>= 0.0.0-0' + valuesFrom: + # Cluster configuration from cozystack ConfigMap + # The ConfigMap data keys (root-host, bundle-name, etc.) will be mapped to _cluster + - kind: ConfigMap + name: cozystack + namespace: cozy-system + targetPath: _cluster + # Branding configuration from cozystack-branding ConfigMap + # All keys from the ConfigMap data will be nested under _cluster.branding + - kind: ConfigMap + name: cozystack-branding + namespace: cozy-system + targetPath: _cluster.branding + optional: true + # Scheduling configuration from cozystack-scheduling ConfigMap + # All keys from the ConfigMap data will be nested under _cluster.scheduling + - kind: ConfigMap + name: cozystack-scheduling + namespace: cozy-system + targetPath: _cluster.scheduling + optional: true + # Kube root CA from kube-root-ca.crt ConfigMap + # Extract the ca.crt key and place it at _cluster.kubeRootCa + - kind: ConfigMap + name: kube-root-ca.crt + namespace: kube-system + targetPath: _cluster.kubeRootCa + valuesKey: ca.crt + optional: true + values: + _namespace: + etcd: tenant-root + monitoring: tenant-root + ingress: tenant-root + seaweedfs: tenant-root + # host will be determined from _cluster.root-host or tenantRootHost + # Default to example.org if neither is set + host: "example.org" + diff --git a/packages/system/cozystack-values/templates/secret.yaml b/packages/system/cozystack-values/templates/secret.yaml new file mode 100644 index 00000000..32b53161 --- /dev/null +++ b/packages/system/cozystack-values/templates/secret.yaml @@ -0,0 +1,54 @@ +{{- /* Default values for _cluster config to ensure all required keys exist */}} +{{- $clusterDefaults := dict + "root-host" "" + "bundle-name" "" + "clusterissuer" "http01" + "oidc-enabled" "false" + "expose-services" "" + "expose-ingress" "tenant-root" + "expose-external-ips" "" + "cluster-domain" "cozy.local" + "api-server-endpoint" "" +}} +{{- $clusterConfig := mergeOverwrite $clusterDefaults (.Values._cluster | default dict) }} +{{- $host := .Values._namespace.host | default "example.org" }} +{{- if .Values._cluster }} + {{- if index .Values._cluster "root-host" }} + {{- $host = index .Values._cluster "root-host" }} + {{- end }} +{{- end }} +{{- /* Check if tenant-root HelmRelease host value is available */}} +{{- if .Values.tenantRootHost }} + {{- $host = .Values.tenantRootHost }} +{{- end }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: cozystack-values + namespace: {{ .Values._namespace.etcd | default "tenant-root" }} + labels: + reconcile.fluxcd.io/watch: Enabled +type: Opaque +stringData: + values.yaml: | + _cluster: + {{- $clusterConfig | toYaml | nindent 6 }} + {{- with .Values._cluster.branding }} + branding: + {{- . | toYaml | nindent 8 }} + {{- end }} + {{- with .Values._cluster.scheduling }} + scheduling: + {{- . | toYaml | nindent 8 }} + {{- end }} + {{- with .Values._cluster.kubeRootCa }} + kube-root-ca: {{ . | b64enc | quote }} + {{- end }} + _namespace: + etcd: {{ .Values._namespace.etcd | default "tenant-root" | quote }} + monitoring: {{ .Values._namespace.monitoring | default "tenant-root" | quote }} + ingress: {{ .Values._namespace.ingress | default "tenant-root" | quote }} + seaweedfs: {{ .Values._namespace.seaweedfs | default "tenant-root" | quote }} + host: {{ $host | quote }} + diff --git a/packages/system/cozystack-values/values.yaml b/packages/system/cozystack-values/values.yaml new file mode 100644 index 00000000..86d1c288 --- /dev/null +++ b/packages/system/cozystack-values/values.yaml @@ -0,0 +1,18 @@ +# Default values for cozystack-values chart +# These values will be populated via valuesFrom in the HelmRelease + +# Cluster configuration from cozystack ConfigMap +# The ConfigMap data keys will be mapped directly to _cluster +_cluster: {} + +# Namespace configuration +_namespace: + etcd: tenant-root + monitoring: tenant-root + ingress: tenant-root + seaweedfs: tenant-root + host: "example.org" + +# Host value from tenant-root HelmRelease (if available) +tenantRootHost: "" +