diff --git a/packaging/flavorgen/flavors/clusterclass_generators.go b/packaging/flavorgen/flavors/clusterclass_generators.go index f1ced4bd34..4c8d79cc47 100644 --- a/packaging/flavorgen/flavors/clusterclass_generators.go +++ b/packaging/flavorgen/flavors/clusterclass_generators.go @@ -108,6 +108,7 @@ func getWorkersClass() clusterv1.WorkersClass { func getClusterClassPatches() []clusterv1.ClusterClassPatch { return []clusterv1.ClusterClassPatch{ + createFilesArrayPatch(), enableSSHPatch(), infraClusterPatch(), kubeVipEnabledPatch(), @@ -223,7 +224,6 @@ func newVSphereClusterTemplate() infrav1.VSphereClusterTemplate { } func newKubeadmControlPlaneTemplate(templateName string) controlplanev1.KubeadmControlPlaneTemplate { - files := []bootstrapv1.File{} return controlplanev1.KubeadmControlPlaneTemplate{ TypeMeta: metav1.TypeMeta{ Kind: util.TypeToKind(&controlplanev1.KubeadmControlPlaneTemplate{}), @@ -236,7 +236,7 @@ func newKubeadmControlPlaneTemplate(templateName string) controlplanev1.KubeadmC Spec: controlplanev1.KubeadmControlPlaneTemplateSpec{ Template: controlplanev1.KubeadmControlPlaneTemplateResource{ Spec: controlplanev1.KubeadmControlPlaneTemplateResourceSpec{ - KubeadmConfigSpec: defaultKubeadmInitSpec(files), + KubeadmConfigSpec: defaultKubeadmInitSpec([]bootstrapv1.File{}), }, }, }, diff --git a/packaging/flavorgen/flavors/patches.go b/packaging/flavorgen/flavors/patches.go index 805231eb45..7b12a8b998 100644 --- a/packaging/flavorgen/flavors/patches.go +++ b/packaging/flavorgen/flavors/patches.go @@ -19,6 +19,7 @@ package flavors import ( "fmt" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/utils/pointer" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1" @@ -29,6 +30,52 @@ import ( "sigs.k8s.io/cluster-api-provider-vsphere/packaging/flavorgen/flavors/util" ) +func createFilesArrayPatch() clusterv1.ClusterClassPatch { + return clusterv1.ClusterClassPatch{ + Name: "createFilesArray", + Definitions: []clusterv1.PatchDefinition{ + { + Selector: clusterv1.PatchSelector{ + APIVersion: controlplanev1.GroupVersion.String(), + Kind: util.TypeToKind(&controlplanev1.KubeadmControlPlaneTemplate{}), + MatchResources: clusterv1.PatchSelectorMatch{ + ControlPlane: true, + }, + }, + JSONPatches: []clusterv1.JSONPatch{ + { + Op: "add", + Path: "/spec/template/spec/kubeadmConfigSpec/files", + Value: &apiextensionsv1.JSON{ + Raw: []byte("[]"), + }, + }, + }, + }, + { + Selector: clusterv1.PatchSelector{ + APIVersion: controlplanev1.GroupVersion.String(), + Kind: util.TypeToKind(&bootstrapv1.KubeadmConfigTemplate{}), + MatchResources: clusterv1.PatchSelectorMatch{ + MachineDeploymentClass: &clusterv1.PatchSelectorMatchMachineDeploymentClass{ + Names: []string{fmt.Sprintf("%s-worker", env.ClusterClassNameVar)}, + }, + }, + }, + JSONPatches: []clusterv1.JSONPatch{ + { + Op: "add", + Path: "/spec/template/spec/files", + Value: &apiextensionsv1.JSON{ + Raw: []byte("[]"), + }, + }, + }, + }, + }, + } +} + func enableSSHPatch() clusterv1.ClusterClassPatch { return clusterv1.ClusterClassPatch{ Name: "enableSSHIntoNodes", diff --git a/templates/clusterclass-template.yaml b/templates/clusterclass-template.yaml index 7b92296d14..261ba93592 100644 --- a/templates/clusterclass-template.yaml +++ b/templates/clusterclass-template.yaml @@ -32,6 +32,28 @@ spec: name: '${CLUSTER_CLASS_NAME}' namespace: '${NAMESPACE}' patches: + - definitions: + - jsonPatches: + - op: add + path: /spec/template/spec/kubeadmConfigSpec/files + value: [] + selector: + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: KubeadmControlPlaneTemplate + matchResources: + controlPlane: true + - jsonPatches: + - op: add + path: /spec/template/spec/files + value: [] + selector: + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: KubeadmConfigTemplate + matchResources: + machineDeploymentClass: + names: + - ${CLUSTER_CLASS_NAME}-worker + name: createFilesArray - definitions: - jsonPatches: - op: add diff --git a/test/e2e/data/infrastructure-vsphere/main/clusterclass/patch-create-files-array.yaml b/test/e2e/data/infrastructure-vsphere/main/clusterclass/patch-create-files-array.yaml deleted file mode 100644 index a8002f4784..0000000000 --- a/test/e2e/data/infrastructure-vsphere/main/clusterclass/patch-create-files-array.yaml +++ /dev/null @@ -1,25 +0,0 @@ -- op: add - path: /spec/patches/- - value: - definitions: - - jsonPatches: - - op: add - path: /spec/template/spec/kubeadmConfigSpec/files - value: [] - selector: - apiVersion: controlplane.cluster.x-k8s.io/v1beta1 - kind: KubeadmControlPlaneTemplate - matchResources: - controlPlane: true - - jsonPatches: - - op: add - path: /spec/template/spec/kubeadmConfigSpec/files - value: [] - selector: - apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 - kind: KubeadmConfigTemplate - matchResources: - machineDeploymentClass: - names: - - ${CLUSTER_CLASS_NAME}-worker - name: create-files-array diff --git a/test/e2e/data/infrastructure-vsphere/v1.7/clusterclass/patch-create-files-array.yaml b/test/e2e/data/infrastructure-vsphere/v1.7/clusterclass/patch-create-files-array.yaml deleted file mode 100644 index a8002f4784..0000000000 --- a/test/e2e/data/infrastructure-vsphere/v1.7/clusterclass/patch-create-files-array.yaml +++ /dev/null @@ -1,25 +0,0 @@ -- op: add - path: /spec/patches/- - value: - definitions: - - jsonPatches: - - op: add - path: /spec/template/spec/kubeadmConfigSpec/files - value: [] - selector: - apiVersion: controlplane.cluster.x-k8s.io/v1beta1 - kind: KubeadmControlPlaneTemplate - matchResources: - controlPlane: true - - jsonPatches: - - op: add - path: /spec/template/spec/kubeadmConfigSpec/files - value: [] - selector: - apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 - kind: KubeadmConfigTemplate - matchResources: - machineDeploymentClass: - names: - - ${CLUSTER_CLASS_NAME}-worker - name: create-files-array diff --git a/test/e2e/data/infrastructure-vsphere/v1.8/clusterclass/patch-create-files-array.yaml b/test/e2e/data/infrastructure-vsphere/v1.8/clusterclass/patch-create-files-array.yaml deleted file mode 100644 index a8002f4784..0000000000 --- a/test/e2e/data/infrastructure-vsphere/v1.8/clusterclass/patch-create-files-array.yaml +++ /dev/null @@ -1,25 +0,0 @@ -- op: add - path: /spec/patches/- - value: - definitions: - - jsonPatches: - - op: add - path: /spec/template/spec/kubeadmConfigSpec/files - value: [] - selector: - apiVersion: controlplane.cluster.x-k8s.io/v1beta1 - kind: KubeadmControlPlaneTemplate - matchResources: - controlPlane: true - - jsonPatches: - - op: add - path: /spec/template/spec/kubeadmConfigSpec/files - value: [] - selector: - apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 - kind: KubeadmConfigTemplate - matchResources: - machineDeploymentClass: - names: - - ${CLUSTER_CLASS_NAME}-worker - name: create-files-array