From 7ca6e5ce9e4ea49a73b28ae86ab46bc38dafd0fa Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Mon, 16 Feb 2026 18:47:04 +0300 Subject: [PATCH] feat(installer): add variant-aware templates for generic Kubernetes support Co-Authored-By: Claude Signed-off-by: Aleksei Sviridkin --- Makefile | 5 +++-- packages/core/installer/.helmignore | 11 +++++++++++ packages/core/installer/Makefile | 8 +++++++- .../installer/templates/cozystack-operator.yaml | 15 +++------------ .../core/installer/templates/packagesource.yaml | 4 ++++ packages/core/installer/values.yaml | 10 ++++++++++ 6 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 packages/core/installer/.helmignore diff --git a/Makefile b/Makefile index e6c50458..12554861 100644 --- a/Makefile +++ b/Makefile @@ -48,15 +48,16 @@ manifests: > _out/assets/cozystack-operator-talos.yaml # Generic Kubernetes variant (k3s, kubeadm, RKE2) helm template installer packages/core/installer -n cozy-system \ + --set cozystackOperator.variant=generic \ + --set cozystack.apiServerHost=REPLACE_ME \ -s templates/cozystack-operator.yaml \ -s templates/packagesource.yaml \ - --set cozystackOperator.variant=generic \ > _out/assets/cozystack-operator-generic.yaml # Hosted variant (managed Kubernetes) helm template installer packages/core/installer -n cozy-system \ + --set cozystackOperator.variant=hosted \ -s templates/cozystack-operator.yaml \ -s templates/packagesource.yaml \ - --set cozystackOperator.variant=hosted \ > _out/assets/cozystack-operator-hosted.yaml cozypkg: diff --git a/packages/core/installer/.helmignore b/packages/core/installer/.helmignore new file mode 100644 index 00000000..ba88ffe8 --- /dev/null +++ b/packages/core/installer/.helmignore @@ -0,0 +1,11 @@ +# VCS and IDE +.git +.gitignore + +# Build artifacts +Makefile +images/ +example/ +*.tgz + +# NOTE: definitions/ is intentionally NOT excluded — needed by crds.yaml via .Files.Glob diff --git a/packages/core/installer/Makefile b/packages/core/installer/Makefile index ad9982b5..7038bb9c 100644 --- a/packages/core/installer/Makefile +++ b/packages/core/installer/Makefile @@ -15,7 +15,7 @@ apply: diff: cozyhr show --namespace $(NAMESPACE) $(NAME) --plain | kubectl diff -f - -image: pre-checks image-operator image-packages +image: pre-checks image-operator image-packages chart image-operator: docker buildx build -f images/cozystack-operator/Dockerfile ../../.. \ @@ -43,3 +43,9 @@ image-packages: test -n "$$DIGEST" && \ yq -i '.cozystackOperator.platformSourceUrl = strenv(REPO)' values.yaml && \ yq -i '.cozystackOperator.platformSourceRef = "digest=" + strenv(DIGEST)' values.yaml + +chart: + set -e; \ + PKG=$$(helm package . --version $(COZYSTACK_VERSION) | awk '{print $$NF}'); \ + trap 'rm -f "$$PKG"' EXIT; \ + if [ "$(PUSH)" = "1" ]; then helm push "$$PKG" oci://$(REGISTRY); fi diff --git a/packages/core/installer/templates/cozystack-operator.yaml b/packages/core/installer/templates/cozystack-operator.yaml index 96ce9b87..4568e18b 100644 --- a/packages/core/installer/templates/cozystack-operator.yaml +++ b/packages/core/installer/templates/cozystack-operator.yaml @@ -72,20 +72,11 @@ spec: value: "7445" {{- else if eq .Values.cozystackOperator.variant "generic" }} env: - # Generic Kubernetes: read from ConfigMap - # Create cozystack-operator-config ConfigMap before applying this manifest + # Generic Kubernetes: API server endpoint - name: KUBERNETES_SERVICE_HOST - valueFrom: - configMapKeyRef: - name: cozystack-operator-config - key: KUBERNETES_SERVICE_HOST - optional: false + value: {{ required "cozystack.apiServerHost is required in generic mode" .Values.cozystack.apiServerHost | quote }} - name: KUBERNETES_SERVICE_PORT - valueFrom: - configMapKeyRef: - name: cozystack-operator-config - key: KUBERNETES_SERVICE_PORT - optional: false + value: {{ .Values.cozystack.apiServerPort | quote }} {{- else if eq .Values.cozystackOperator.variant "hosted" }} # Hosted: use in-cluster service account, no env override needed env: [] diff --git a/packages/core/installer/templates/packagesource.yaml b/packages/core/installer/templates/packagesource.yaml index f4a5f6d0..65b1e4bf 100644 --- a/packages/core/installer/templates/packagesource.yaml +++ b/packages/core/installer/templates/packagesource.yaml @@ -1,3 +1,7 @@ +{{- $validVariants := list "talos" "generic" "hosted" -}} +{{- if not (has .Values.cozystackOperator.variant $validVariants) -}} +{{- fail (printf "Invalid cozystackOperator.variant %q: must be one of talos, generic, hosted" .Values.cozystackOperator.variant) -}} +{{- end -}} --- apiVersion: cozystack.io/v1alpha1 kind: PackageSource diff --git a/packages/core/installer/values.yaml b/packages/core/installer/values.yaml index 64ff817b..95633e8e 100644 --- a/packages/core/installer/values.yaml +++ b/packages/core/installer/values.yaml @@ -4,3 +4,13 @@ cozystackOperator: image: ghcr.io/cozystack/cozystack/cozystack-operator:v1.0.0-beta.4@sha256:322dd7358df369525f76e6e43512482e38caec5315d36a878399d2d60bf2f18d platformSourceUrl: 'oci://ghcr.io/cozystack/cozystack/cozystack-packages' platformSourceRef: 'digest=sha256:b88502242b535a31ab33c06ffc0a96d1c67230d2db2c5e873fa23f6523592ff6' + +# Generic variant configuration (only used when cozystackOperator.variant=generic) +cozystack: + # Kubernetes API server host (IP only, no protocol/port) + # Must be the INTERNAL IP of the control-plane node + # (the IP visible on the node's network interface, not a public/NAT IP) + # Used by the operator and networking components (cilium, kube-ovn) + apiServerHost: "" + # Kubernetes API server port + apiServerPort: "6443"