From 35130617c43764f2d4072ee79648f54c119c5e28 Mon Sep 17 00:00:00 2001 From: Chris Werner Rau Date: Thu, 18 Jul 2024 15:34:23 +0200 Subject: [PATCH] feat(t8s-cluster/workload-cluster): latch onto legacy cni when used (#1039) This should allow us to adopt the legacy clusters into our customer portal --- charts/t8s-cluster/templates/_helpers.tpl | 12 ++++++++++++ .../management-cluster/repositories/cni-calico.yaml | 2 +- .../workload-cluster/cinder-csi-plugin.yaml | 2 +- .../workload-cluster/cloud-controller-manager.yaml | 2 +- .../templates/workload-cluster/cni-calico.yaml | 2 +- .../templates/workload-cluster/cni-cilium.yaml | 2 +- .../workload-cluster/pre-install/uninstall-cni.yaml | 2 +- charts/t8s-cluster/values.schema.json | 2 ++ charts/t8s-cluster/values.yaml | 2 +- 9 files changed, 21 insertions(+), 7 deletions(-) diff --git a/charts/t8s-cluster/templates/_helpers.tpl b/charts/t8s-cluster/templates/_helpers.tpl index cacaeab19..3b346fe75 100644 --- a/charts/t8s-cluster/templates/_helpers.tpl +++ b/charts/t8s-cluster/templates/_helpers.tpl @@ -14,3 +14,15 @@ {{- end -}} {{- $hasGPUFlavor | ternary true "" -}} {{- end -}} + +{{- define "t8s-cluster.cni" -}} + {{- if eq .Values.cni "auto" -}} + {{- if lookup "kustomize.toolkit.fluxcd.io/v1" "Kustomization" .Release.Namespace (printf "%s-cni" .Release.Name) -}} + calico + {{- else -}} + cilium + {{- end -}} + {{- else -}} + {{- .Values.cni -}} + {{- end -}} +{{- end -}} diff --git a/charts/t8s-cluster/templates/management-cluster/repositories/cni-calico.yaml b/charts/t8s-cluster/templates/management-cluster/repositories/cni-calico.yaml index 4788cc4cd..73999608c 100644 --- a/charts/t8s-cluster/templates/management-cluster/repositories/cni-calico.yaml +++ b/charts/t8s-cluster/templates/management-cluster/repositories/cni-calico.yaml @@ -1,4 +1,4 @@ -{{- if eq .Values.cni "calico" }} +{{- if eq (include "t8s-cluster.cni" .) "calico" }} apiVersion: source.toolkit.fluxcd.io/v1 kind: GitRepository metadata: diff --git a/charts/t8s-cluster/templates/workload-cluster/cinder-csi-plugin.yaml b/charts/t8s-cluster/templates/workload-cluster/cinder-csi-plugin.yaml index 3a60a1b76..5b7705f33 100644 --- a/charts/t8s-cluster/templates/workload-cluster/cinder-csi-plugin.yaml +++ b/charts/t8s-cluster/templates/workload-cluster/cinder-csi-plugin.yaml @@ -16,7 +16,7 @@ spec: interval: 1h driftDetection: mode: enabled - {{- if eq .Values.cni "cilium" }} + {{- if eq (include "t8s-cluster.cni" .) "cilium" }} dependsOn: - name: {{ printf "%s-cni" .Release.Name }} namespace: {{ .Release.Namespace }} diff --git a/charts/t8s-cluster/templates/workload-cluster/cloud-controller-manager.yaml b/charts/t8s-cluster/templates/workload-cluster/cloud-controller-manager.yaml index 6138e32aa..9ef699624 100644 --- a/charts/t8s-cluster/templates/workload-cluster/cloud-controller-manager.yaml +++ b/charts/t8s-cluster/templates/workload-cluster/cloud-controller-manager.yaml @@ -16,7 +16,7 @@ spec: interval: 1h driftDetection: mode: enabled - {{- if eq .Values.cni "cilium" }} + {{- if eq (include "t8s-cluster.cni" .) "cilium" }} dependsOn: - name: {{ printf "%s-cni" .Release.Name }} namespace: {{ .Release.Namespace }} diff --git a/charts/t8s-cluster/templates/workload-cluster/cni-calico.yaml b/charts/t8s-cluster/templates/workload-cluster/cni-calico.yaml index d839c45f0..ee4f81713 100644 --- a/charts/t8s-cluster/templates/workload-cluster/cni-calico.yaml +++ b/charts/t8s-cluster/templates/workload-cluster/cni-calico.yaml @@ -1,4 +1,4 @@ -{{- if eq .Values.cni "calico" }} +{{- if eq (include "t8s-cluster.cni" .) "calico" }} apiVersion: kustomize.toolkit.fluxcd.io/v1 kind: Kustomization metadata: diff --git a/charts/t8s-cluster/templates/workload-cluster/cni-cilium.yaml b/charts/t8s-cluster/templates/workload-cluster/cni-cilium.yaml index 7804c6f65..73c56c596 100644 --- a/charts/t8s-cluster/templates/workload-cluster/cni-cilium.yaml +++ b/charts/t8s-cluster/templates/workload-cluster/cni-cilium.yaml @@ -1,4 +1,4 @@ -{{- if eq .Values.cni "cilium" }} +{{- if eq (include "t8s-cluster.cni" .) "cilium" }} apiVersion: helm.toolkit.fluxcd.io/v2 kind: HelmRelease metadata: diff --git a/charts/t8s-cluster/templates/workload-cluster/pre-install/uninstall-cni.yaml b/charts/t8s-cluster/templates/workload-cluster/pre-install/uninstall-cni.yaml index c7c241d4f..4d2086d2a 100644 --- a/charts/t8s-cluster/templates/workload-cluster/pre-install/uninstall-cni.yaml +++ b/charts/t8s-cluster/templates/workload-cluster/pre-install/uninstall-cni.yaml @@ -1,3 +1,3 @@ -{{- if eq .Values.cni "cilium" -}} +{{- if eq (include "t8s-cluster.cni" .) "cilium" -}} {{ include "t8s-cluster.workload.uninstall-job" (dict "name" "cni" "context" . "clusterResourceSet" "cni") }} {{- end -}} diff --git a/charts/t8s-cluster/values.schema.json b/charts/t8s-cluster/values.schema.json index ba5a5697b..e173b8297 100644 --- a/charts/t8s-cluster/values.schema.json +++ b/charts/t8s-cluster/values.schema.json @@ -222,8 +222,10 @@ }, "cni": { "type": "string", + "description": "The CNI plugin to use. `auto` means to keep the current one or use cilium for a new cluster.", "enum": [ "cilium", + "auto", "calico" ] }, diff --git a/charts/t8s-cluster/values.yaml b/charts/t8s-cluster/values.yaml index be3970985..f8386ddc9 100644 --- a/charts/t8s-cluster/values.yaml +++ b/charts/t8s-cluster/values.yaml @@ -61,6 +61,6 @@ containerRegistryMirror: sshKeyName: null -cni: cilium +cni: auto openstackImageNamePrefix: ""