Skip to content

Commit

Permalink
flavorgen: use append for kubevip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Dec 4, 2023
1 parent a4e818c commit 5decb0e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
16 changes: 11 additions & 5 deletions packaging/flavorgen/flavors/patches.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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)) }}`),
},
},
},
Expand Down
12 changes: 8 additions & 4 deletions templates/clusterclass-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5decb0e

Please sign in to comment.