diff --git a/Makefile b/Makefile index f658747f..25a9cc25 100644 --- a/Makefile +++ b/Makefile @@ -48,13 +48,15 @@ manifests: > _out/assets/cozystack-operator.yaml # Generic Kubernetes variant (k3s, kubeadm, RKE2) helm template installer packages/core/installer -n cozy-system \ - -s templates/cozystack-operator-generic.yaml \ + -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 \ - -s templates/cozystack-operator-hosted.yaml \ + -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/templates/cozystack-operator-generic.yaml b/packages/core/installer/templates/cozystack-operator-generic.yaml deleted file mode 100644 index 510a92c8..00000000 --- a/packages/core/installer/templates/cozystack-operator-generic.yaml +++ /dev/null @@ -1,90 +0,0 @@ ---- -apiVersion: v1 -kind: Namespace -metadata: - name: cozy-system - labels: - cozystack.io/system: "true" - pod-security.kubernetes.io/enforce: privileged ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - name: cozystack - namespace: cozy-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: cozystack -subjects: -- kind: ServiceAccount - name: cozystack - namespace: cozy-system -roleRef: - kind: ClusterRole - name: cluster-admin - apiGroup: rbac.authorization.k8s.io ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: cozystack-operator - namespace: cozy-system -spec: - replicas: 1 - selector: - matchLabels: - app: cozystack-operator - strategy: - type: RollingUpdate - rollingUpdate: - maxSurge: 0 - maxUnavailable: 1 - template: - metadata: - labels: - app: cozystack-operator - spec: - serviceAccountName: cozystack - containers: - - name: cozystack-operator - image: "{{ .Values.cozystackOperator.image }}" - args: - - --leader-elect=true - - --install-flux=true - - --metrics-bind-address=0 - - --health-probe-bind-address= - {{- if .Values.cozystackOperator.disableTelemetry }} - - --disable-telemetry - {{- end }} - - --platform-source-name=cozystack-platform - - --platform-source-url={{ .Values.cozystackOperator.platformSourceUrl }} - {{- if .Values.cozystackOperator.platformSourceRef }} - - --platform-source-ref={{ .Values.cozystackOperator.platformSourceRef }} - {{- end }} - env: - # Generic Kubernetes: read from ConfigMap - # Create cozystack-operator-config ConfigMap before applying this manifest - - name: KUBERNETES_SERVICE_HOST - valueFrom: - configMapKeyRef: - name: cozystack-operator-config - key: KUBERNETES_SERVICE_HOST - optional: false - - name: KUBERNETES_SERVICE_PORT - valueFrom: - configMapKeyRef: - name: cozystack-operator-config - key: KUBERNETES_SERVICE_PORT - optional: false - hostNetwork: true - tolerations: - - key: "node.kubernetes.io/not-ready" - operator: "Exists" - - key: "node.kubernetes.io/unreachable" - operator: "Exists" - - key: "node.cilium.io/agent-not-ready" - operator: "Exists" - - key: "node.cloudprovider.kubernetes.io/uninitialized" - operator: "Exists" diff --git a/packages/core/installer/templates/cozystack-operator-hosted.yaml b/packages/core/installer/templates/cozystack-operator-hosted.yaml deleted file mode 100644 index 38ccdf75..00000000 --- a/packages/core/installer/templates/cozystack-operator-hosted.yaml +++ /dev/null @@ -1,77 +0,0 @@ ---- -apiVersion: v1 -kind: Namespace -metadata: - name: cozy-system - labels: - cozystack.io/system: "true" - pod-security.kubernetes.io/enforce: privileged ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - name: cozystack - namespace: cozy-system ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: cozystack -subjects: -- kind: ServiceAccount - name: cozystack - namespace: cozy-system -roleRef: - kind: ClusterRole - name: cluster-admin - apiGroup: rbac.authorization.k8s.io ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: cozystack-operator - namespace: cozy-system -spec: - replicas: 1 - selector: - matchLabels: - app: cozystack-operator - strategy: - type: RollingUpdate - rollingUpdate: - maxSurge: 0 - maxUnavailable: 1 - template: - metadata: - labels: - app: cozystack-operator - spec: - serviceAccountName: cozystack - containers: - - name: cozystack-operator - image: "{{ .Values.cozystackOperator.image }}" - args: - - --leader-elect=true - - --install-flux=true - - --metrics-bind-address=0 - - --health-probe-bind-address= - {{- if .Values.cozystackOperator.disableTelemetry }} - - --disable-telemetry - {{- end }} - - --platform-source-name=cozystack-platform - - --platform-source-url={{ .Values.cozystackOperator.platformSourceUrl }} - {{- if .Values.cozystackOperator.platformSourceRef }} - - --platform-source-ref={{ .Values.cozystackOperator.platformSourceRef }} - {{- end }} - # Hosted: use in-cluster service account, no env override needed - env: [] - hostNetwork: true - tolerations: - - key: "node.kubernetes.io/not-ready" - operator: "Exists" - - key: "node.kubernetes.io/unreachable" - operator: "Exists" - - key: "node.cilium.io/agent-not-ready" - operator: "Exists" - - key: "node.cloudprovider.kubernetes.io/uninitialized" - operator: "Exists" diff --git a/packages/core/installer/templates/cozystack-operator.yaml b/packages/core/installer/templates/cozystack-operator.yaml index c40dc663..96ce9b87 100644 --- a/packages/core/installer/templates/cozystack-operator.yaml +++ b/packages/core/installer/templates/cozystack-operator.yaml @@ -63,12 +63,33 @@ spec: {{- if .Values.cozystackOperator.platformSourceRef }} - --platform-source-ref={{ .Values.cozystackOperator.platformSourceRef }} {{- end }} + {{- if eq .Values.cozystackOperator.variant "talos" }} env: # Talos KubePrism endpoint - name: KUBERNETES_SERVICE_HOST value: "localhost" - name: KUBERNETES_SERVICE_PORT value: "7445" + {{- else if eq .Values.cozystackOperator.variant "generic" }} + env: + # Generic Kubernetes: read from ConfigMap + # Create cozystack-operator-config ConfigMap before applying this manifest + - name: KUBERNETES_SERVICE_HOST + valueFrom: + configMapKeyRef: + name: cozystack-operator-config + key: KUBERNETES_SERVICE_HOST + optional: false + - name: KUBERNETES_SERVICE_PORT + valueFrom: + configMapKeyRef: + name: cozystack-operator-config + key: KUBERNETES_SERVICE_PORT + optional: false + {{- else if eq .Values.cozystackOperator.variant "hosted" }} + # Hosted: use in-cluster service account, no env override needed + env: [] + {{- end }} hostNetwork: true tolerations: - key: "node.kubernetes.io/not-ready" diff --git a/packages/core/installer/values.yaml b/packages/core/installer/values.yaml index 1bfa2040..e9de3f13 100644 --- a/packages/core/installer/values.yaml +++ b/packages/core/installer/values.yaml @@ -1,4 +1,6 @@ cozystackOperator: + # Deployment variant: talos, generic, hosted + variant: talos image: ghcr.io/cozystack/cozystack/cozystack-operator:v1.0.0-beta.3@sha256:3cacecfc318e8314300bba8538b475fb8d50b2bf3106533faa8d942e4ed14448 platformSourceUrl: 'oci://ghcr.io/cozystack/cozystack/cozystack-packages' platformSourceRef: 'digest=sha256:e5ddcf5a02d17b17fc7ffa8c87ddeaa25a01d928a63fb297f6b25b669bb6b7c7'