From 5decb0e8f54b3ff96a702ef2faca5d02148eb98a Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Mon, 4 Dec 2023 13:13:52 +0100 Subject: [PATCH] flavorgen: use append for kubevip --- packaging/flavorgen/flavors/patches.go | 16 +++++++++++----- templates/clusterclass-template.yaml | 12 ++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/packaging/flavorgen/flavors/patches.go b/packaging/flavorgen/flavors/patches.go index 05751e9ea7..805231eb45 100644 --- a/packaging/flavorgen/flavors/patches.go +++ b/packaging/flavorgen/flavors/patches.go @@ -126,7 +126,7 @@ func infraClusterPatch() clusterv1.ClusterClassPatch { func kubeVipEnabledPatch() clusterv1.ClusterClassPatch { return clusterv1.ClusterClassPatch{ - Name: "kubeVipEnabled", + Name: "kubeVipPodManifest", Definitions: []clusterv1.PatchDefinition{ { Selector: clusterv1.PatchSelector{ @@ -138,13 +138,19 @@ func kubeVipEnabledPatch() clusterv1.ClusterClassPatch { }, JSONPatches: []clusterv1.JSONPatch{ { - // TODO(schlotterc): change to append Op: "add", Path: "/spec/template/spec/kubeadmConfigSpec/files", ValueFrom: &clusterv1.JSONPatchValue{ - Template: pointer.String(`- owner: root:root - path: "/etc/kubernetes/manifests/kube-vip.yaml" - content: {{ printf "%q" (regexReplaceAll "(name: address\n +value:).*" .kubeVipPodManifest (printf "$1 %s" .controlPlaneIpAddr)) }}`), + Template: pointer.String(`[]`), + }, + }, + { + Op: "add", + Path: "/spec/template/spec/kubeadmConfigSpec/files/-", + ValueFrom: &clusterv1.JSONPatchValue{ + Template: pointer.String(`owner: root:root +path: "/etc/kubernetes/manifests/kube-vip.yaml" +content: {{ printf "%q" (regexReplaceAll "(name: address\n +value:).*" .kubeVipPodManifest (printf "$1 %s" .controlPlaneIpAddr)) }}`), }, }, }, diff --git a/templates/clusterclass-template.yaml b/templates/clusterclass-template.yaml index 1d3835f77a..7b92296d14 100644 --- a/templates/clusterclass-template.yaml +++ b/templates/clusterclass-template.yaml @@ -97,17 +97,21 @@ spec: - jsonPatches: - op: add path: /spec/template/spec/kubeadmConfigSpec/files + valueFrom: + template: '[]' + - op: add + path: /spec/template/spec/kubeadmConfigSpec/files/- valueFrom: template: |- - - owner: root:root - path: "/etc/kubernetes/manifests/kube-vip.yaml" - content: {{ printf "%q" (regexReplaceAll "(name: address\n +value:).*" .kubeVipPodManifest (printf "$1 %s" .controlPlaneIpAddr)) }} + owner: root:root + path: "/etc/kubernetes/manifests/kube-vip.yaml" + content: {{ printf "%q" (regexReplaceAll "(name: address\n +value:).*" .kubeVipPodManifest (printf "$1 %s" .controlPlaneIpAddr)) }} selector: apiVersion: controlplane.cluster.x-k8s.io/v1beta1 kind: KubeadmControlPlaneTemplate matchResources: controlPlane: true - name: kubeVipEnabled + name: kubeVipPodManifest variables: - name: sshKey required: false