From 9bf39c466990a7c2a77825ca1481c1ea7c62fac4 Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Mon, 21 Jul 2025 19:07:13 +0200 Subject: [PATCH] Rename ClusterClass MachineInfrastructure --- api/core/v1beta1/conversion.go | 12 ++- api/core/v1beta1/zz_generated.conversion.go | 28 ++---- api/core/v1beta2/clusterclass_types.go | 11 ++- api/core/v1beta2/zz_generated.deepcopy.go | 38 ++++---- api/core/v1beta2/zz_generated.openapi.go | 56 ++++++------ cmd/clusterctl/client/cluster/objectgraph.go | 4 +- cmd/clusterctl/client/describe.go | 2 +- cmd/clusterctl/client/tree/discovery.go | 4 +- cmd/clusterctl/client/tree/discovery_test.go | 4 +- cmd/clusterctl/client/tree/doc.go | 2 +- cmd/clusterctl/cmd/describe_cluster.go | 4 +- .../cluster.x-k8s.io_clusterclasses.yaml | 87 +++++++++---------- .../cluster-class/write-clusterclass.md | 2 +- exp/topology/desiredstate/desired_state.go | 2 +- .../desiredstate/desired_state_test.go | 8 +- exp/topology/scope/blueprint.go | 4 +- internal/api/core/v1alpha4/conversion.go | 12 ++- .../core/v1alpha4/zz_generated.conversion.go | 28 ++---- .../clusterclass/clusterclass_controller.go | 4 +- .../clusterclass_controller_test.go | 6 +- .../controllers/topology/cluster/blueprint.go | 6 +- .../cluster/cluster_controller_test.go | 2 +- .../topology/cluster/current_state.go | 2 +- .../topology/cluster/reconcile_state_test.go | 12 +-- internal/topology/check/compatibility.go | 10 +-- .../upgrade/clusterctl_upgrade_test.go | 4 +- internal/webhooks/cluster.go | 6 +- internal/webhooks/cluster_test.go | 8 +- internal/webhooks/clusterclass.go | 8 +- internal/webhooks/clusterclass_test.go | 4 +- internal/webhooks/patch_validation.go | 4 +- internal/webhooks/test/clusterclass_test.go | 2 +- test/e2e/clusterclass_changes.go | 2 +- test/e2e/clusterclass_rollout.go | 6 +- .../main/clusterclass-in-memory.yaml | 2 +- .../clusterclass-quick-start-runtimesdk.yaml | 2 +- .../main/clusterclass-quick-start.yaml | 2 +- .../handler_integration_test.go | 2 +- .../clusterclass-quick-start-runtimesdk.yaml | 2 +- .../templates/clusterclass-in-memory.yaml | 2 +- .../templates/clusterclass-quick-start.yaml | 2 +- util/test/builder/builders.go | 2 +- 42 files changed, 196 insertions(+), 214 deletions(-) diff --git a/api/core/v1beta1/conversion.go b/api/core/v1beta1/conversion.go index f43526696242..7ddcda16d1ab 100644 --- a/api/core/v1beta1/conversion.go +++ b/api/core/v1beta1/conversion.go @@ -714,6 +714,10 @@ func Convert_v1beta1_ControlPlaneClass_To_v1beta2_ControlPlaneClass(in *ControlP out.Deletion.NodeVolumeDetachTimeoutSeconds = clusterv1.ConvertToSeconds(in.NodeVolumeDetachTimeout) out.Deletion.NodeDeletionTimeoutSeconds = clusterv1.ConvertToSeconds(in.NodeDeletionTimeout) convert_v1beta1_LocalObjectTemplate_To_v1beta2_ClusterClassTemplateReference(&in.LocalObjectTemplate, &out.TemplateRef, s) + if in.MachineInfrastructure != nil && in.MachineInfrastructure.Ref != nil { + out.InfrastructureMachine = &clusterv1.ControlPlaneClassInfrastructureMachineTemplate{} + return Convert_v1beta1_LocalObjectTemplate_To_v1beta2_ControlPlaneClassInfrastructureMachineTemplate(in.MachineInfrastructure, out.InfrastructureMachine, s) + } return nil } @@ -725,6 +729,10 @@ func Convert_v1beta2_ControlPlaneClass_To_v1beta1_ControlPlaneClass(in *clusterv out.NodeVolumeDetachTimeout = clusterv1.ConvertFromSeconds(in.Deletion.NodeVolumeDetachTimeoutSeconds) out.NodeDeletionTimeout = clusterv1.ConvertFromSeconds(in.Deletion.NodeDeletionTimeoutSeconds) Convert_v1beta2_ClusterClassTemplateReference_To_v1beta1_LocalObjectTemplate(&in.TemplateRef, &out.LocalObjectTemplate, s) + if in.InfrastructureMachine != nil && !reflect.DeepEqual(in.InfrastructureMachine.TemplateRef, clusterv1.ControlPlaneClassInfrastructureMachineTemplate{}) { + out.MachineInfrastructure = &LocalObjectTemplate{} + return Convert_v1beta2_ControlPlaneClassInfrastructureMachineTemplate_To_v1beta1_LocalObjectTemplate(in.InfrastructureMachine, out.MachineInfrastructure, s) + } return nil } @@ -1672,7 +1680,7 @@ func Convert_v1beta2_MachineNodeReference_To_v1_ObjectReference(in *clusterv1.Ma return nil } -func Convert_v1beta1_LocalObjectTemplate_To_v1beta2_ControlPlaneClassMachineInfrastructureTemplate(in *LocalObjectTemplate, out *clusterv1.ControlPlaneClassMachineInfrastructureTemplate, s apimachineryconversion.Scope) error { +func Convert_v1beta1_LocalObjectTemplate_To_v1beta2_ControlPlaneClassInfrastructureMachineTemplate(in *LocalObjectTemplate, out *clusterv1.ControlPlaneClassInfrastructureMachineTemplate, s apimachineryconversion.Scope) error { convert_v1beta1_LocalObjectTemplate_To_v1beta2_ClusterClassTemplateReference(in, &out.TemplateRef, s) return nil } @@ -1709,7 +1717,7 @@ func convert_v1beta1_LocalObjectTemplate_To_v1beta2_ClusterClassTemplateReferenc } } -func Convert_v1beta2_ControlPlaneClassMachineInfrastructureTemplate_To_v1beta1_LocalObjectTemplate(in *clusterv1.ControlPlaneClassMachineInfrastructureTemplate, out *LocalObjectTemplate, s apimachineryconversion.Scope) error { +func Convert_v1beta2_ControlPlaneClassInfrastructureMachineTemplate_To_v1beta1_LocalObjectTemplate(in *clusterv1.ControlPlaneClassInfrastructureMachineTemplate, out *LocalObjectTemplate, s apimachineryconversion.Scope) error { Convert_v1beta2_ClusterClassTemplateReference_To_v1beta1_LocalObjectTemplate(&in.TemplateRef, out, s) return nil } diff --git a/api/core/v1beta1/zz_generated.conversion.go b/api/core/v1beta1/zz_generated.conversion.go index 003c38efaea4..77172fbf1a33 100644 --- a/api/core/v1beta1/zz_generated.conversion.go +++ b/api/core/v1beta1/zz_generated.conversion.go @@ -700,8 +700,8 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddConversionFunc((*LocalObjectTemplate)(nil), (*v1beta2.ControlPlaneClassMachineInfrastructureTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta1_LocalObjectTemplate_To_v1beta2_ControlPlaneClassMachineInfrastructureTemplate(a.(*LocalObjectTemplate), b.(*v1beta2.ControlPlaneClassMachineInfrastructureTemplate), scope) + if err := s.AddConversionFunc((*LocalObjectTemplate)(nil), (*v1beta2.ControlPlaneClassInfrastructureMachineTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta1_LocalObjectTemplate_To_v1beta2_ControlPlaneClassInfrastructureMachineTemplate(a.(*LocalObjectTemplate), b.(*v1beta2.ControlPlaneClassInfrastructureMachineTemplate), scope) }); err != nil { return err } @@ -865,8 +865,8 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddConversionFunc((*v1beta2.ControlPlaneClassMachineInfrastructureTemplate)(nil), (*LocalObjectTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_ControlPlaneClassMachineInfrastructureTemplate_To_v1beta1_LocalObjectTemplate(a.(*v1beta2.ControlPlaneClassMachineInfrastructureTemplate), b.(*LocalObjectTemplate), scope) + if err := s.AddConversionFunc((*v1beta2.ControlPlaneClassInfrastructureMachineTemplate)(nil), (*LocalObjectTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_ControlPlaneClassInfrastructureMachineTemplate_To_v1beta1_LocalObjectTemplate(a.(*v1beta2.ControlPlaneClassInfrastructureMachineTemplate), b.(*LocalObjectTemplate), scope) }); err != nil { return err } @@ -1759,15 +1759,7 @@ func autoConvert_v1beta1_ControlPlaneClass_To_v1beta2_ControlPlaneClass(in *Cont return err } // WARNING: in.LocalObjectTemplate requires manual conversion: does not exist in peer-type - if in.MachineInfrastructure != nil { - in, out := &in.MachineInfrastructure, &out.MachineInfrastructure - *out = new(v1beta2.ControlPlaneClassMachineInfrastructureTemplate) - if err := Convert_v1beta1_LocalObjectTemplate_To_v1beta2_ControlPlaneClassMachineInfrastructureTemplate(*in, *out, s); err != nil { - return err - } - } else { - out.MachineInfrastructure = nil - } + // WARNING: in.MachineInfrastructure requires manual conversion: does not exist in peer-type if in.MachineHealthCheck != nil { in, out := &in.MachineHealthCheck, &out.MachineHealthCheck *out = new(v1beta2.MachineHealthCheckClass) @@ -1798,15 +1790,7 @@ func autoConvert_v1beta2_ControlPlaneClass_To_v1beta1_ControlPlaneClass(in *v1be return err } // WARNING: in.TemplateRef requires manual conversion: does not exist in peer-type - if in.MachineInfrastructure != nil { - in, out := &in.MachineInfrastructure, &out.MachineInfrastructure - *out = new(LocalObjectTemplate) - if err := Convert_v1beta2_ControlPlaneClassMachineInfrastructureTemplate_To_v1beta1_LocalObjectTemplate(*in, *out, s); err != nil { - return err - } - } else { - out.MachineInfrastructure = nil - } + // WARNING: in.InfrastructureMachine requires manual conversion: does not exist in peer-type if in.MachineHealthCheck != nil { in, out := &in.MachineHealthCheck, &out.MachineHealthCheck *out = new(MachineHealthCheckClass) diff --git a/api/core/v1beta2/clusterclass_types.go b/api/core/v1beta2/clusterclass_types.go index 5243e9611fd1..2e407d221ba0 100644 --- a/api/core/v1beta2/clusterclass_types.go +++ b/api/core/v1beta2/clusterclass_types.go @@ -160,14 +160,13 @@ type ControlPlaneClass struct { // +required TemplateRef ClusterClassTemplateReference `json:"templateRef,omitempty,omitzero"` - // machineInfrastructure defines the metadata and infrastructure information - // for control plane machines. + // infrastructureMachine defines infrastructure for control plane machines. // // This field is supported if and only if the control plane provider template // referenced above is Machine based and supports setting replicas. // // +optional - MachineInfrastructure *ControlPlaneClassMachineInfrastructureTemplate `json:"machineInfrastructure,omitempty"` + InfrastructureMachine *ControlPlaneClassInfrastructureMachineTemplate `json:"infrastructureMachine,omitempty"` // machineHealthCheck defines a MachineHealthCheck for this ControlPlaneClass. // This field is supported if and only if the ControlPlane provider template @@ -1171,9 +1170,9 @@ type ExternalPatchDefinition struct { Settings map[string]string `json:"settings,omitempty"` } -// ControlPlaneClassMachineInfrastructureTemplate defines the template for a MachineInfrastructure of a ControlPlane. -type ControlPlaneClassMachineInfrastructureTemplate struct { - // templateRef is a required reference to the template for a MachineInfrastructure of a ControlPlane. +// ControlPlaneClassInfrastructureMachineTemplate defines the template for a InfrastructureMachine of a ControlPlane. +type ControlPlaneClassInfrastructureMachineTemplate struct { + // templateRef is a required reference to the template for a InfrastructureMachine of a ControlPlane. // +required TemplateRef ClusterClassTemplateReference `json:"templateRef,omitempty,omitzero"` } diff --git a/api/core/v1beta2/zz_generated.deepcopy.go b/api/core/v1beta2/zz_generated.deepcopy.go index 89132145520f..95451a7701be 100644 --- a/api/core/v1beta2/zz_generated.deepcopy.go +++ b/api/core/v1beta2/zz_generated.deepcopy.go @@ -756,9 +756,9 @@ func (in *ControlPlaneClass) DeepCopyInto(out *ControlPlaneClass) { *out = *in in.Metadata.DeepCopyInto(&out.Metadata) out.TemplateRef = in.TemplateRef - if in.MachineInfrastructure != nil { - in, out := &in.MachineInfrastructure, &out.MachineInfrastructure - *out = new(ControlPlaneClassMachineInfrastructureTemplate) + if in.InfrastructureMachine != nil { + in, out := &in.InfrastructureMachine, &out.InfrastructureMachine + *out = new(ControlPlaneClassInfrastructureMachineTemplate) **out = **in } if in.MachineHealthCheck != nil { @@ -789,6 +789,22 @@ func (in *ControlPlaneClass) DeepCopy() *ControlPlaneClass { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ControlPlaneClassInfrastructureMachineTemplate) DeepCopyInto(out *ControlPlaneClassInfrastructureMachineTemplate) { + *out = *in + out.TemplateRef = in.TemplateRef +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControlPlaneClassInfrastructureMachineTemplate. +func (in *ControlPlaneClassInfrastructureMachineTemplate) DeepCopy() *ControlPlaneClassInfrastructureMachineTemplate { + if in == nil { + return nil + } + out := new(ControlPlaneClassInfrastructureMachineTemplate) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ControlPlaneClassMachineDeletionSpec) DeepCopyInto(out *ControlPlaneClassMachineDeletionSpec) { *out = *in @@ -819,22 +835,6 @@ func (in *ControlPlaneClassMachineDeletionSpec) DeepCopy() *ControlPlaneClassMac return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ControlPlaneClassMachineInfrastructureTemplate) DeepCopyInto(out *ControlPlaneClassMachineInfrastructureTemplate) { - *out = *in - out.TemplateRef = in.TemplateRef -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControlPlaneClassMachineInfrastructureTemplate. -func (in *ControlPlaneClassMachineInfrastructureTemplate) DeepCopy() *ControlPlaneClassMachineInfrastructureTemplate { - if in == nil { - return nil - } - out := new(ControlPlaneClassMachineInfrastructureTemplate) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ControlPlaneClassNamingStrategy) DeepCopyInto(out *ControlPlaneClassNamingStrategy) { *out = *in diff --git a/api/core/v1beta2/zz_generated.openapi.go b/api/core/v1beta2/zz_generated.openapi.go index 3b1d54fded4a..b54b823be8a3 100644 --- a/api/core/v1beta2/zz_generated.openapi.go +++ b/api/core/v1beta2/zz_generated.openapi.go @@ -57,8 +57,8 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "sigs.k8s.io/cluster-api/api/core/v1beta2.Condition": schema_cluster_api_api_core_v1beta2_Condition(ref), "sigs.k8s.io/cluster-api/api/core/v1beta2.ContractVersionedObjectReference": schema_cluster_api_api_core_v1beta2_ContractVersionedObjectReference(ref), "sigs.k8s.io/cluster-api/api/core/v1beta2.ControlPlaneClass": schema_cluster_api_api_core_v1beta2_ControlPlaneClass(ref), + "sigs.k8s.io/cluster-api/api/core/v1beta2.ControlPlaneClassInfrastructureMachineTemplate": schema_cluster_api_api_core_v1beta2_ControlPlaneClassInfrastructureMachineTemplate(ref), "sigs.k8s.io/cluster-api/api/core/v1beta2.ControlPlaneClassMachineDeletionSpec": schema_cluster_api_api_core_v1beta2_ControlPlaneClassMachineDeletionSpec(ref), - "sigs.k8s.io/cluster-api/api/core/v1beta2.ControlPlaneClassMachineInfrastructureTemplate": schema_cluster_api_api_core_v1beta2_ControlPlaneClassMachineInfrastructureTemplate(ref), "sigs.k8s.io/cluster-api/api/core/v1beta2.ControlPlaneClassNamingStrategy": schema_cluster_api_api_core_v1beta2_ControlPlaneClassNamingStrategy(ref), "sigs.k8s.io/cluster-api/api/core/v1beta2.ControlPlaneTopology": schema_cluster_api_api_core_v1beta2_ControlPlaneTopology(ref), "sigs.k8s.io/cluster-api/api/core/v1beta2.ControlPlaneTopologyMachineDeletionSpec": schema_cluster_api_api_core_v1beta2_ControlPlaneTopologyMachineDeletionSpec(ref), @@ -1480,10 +1480,10 @@ func schema_cluster_api_api_core_v1beta2_ControlPlaneClass(ref common.ReferenceC Ref: ref("sigs.k8s.io/cluster-api/api/core/v1beta2.ClusterClassTemplateReference"), }, }, - "machineInfrastructure": { + "infrastructureMachine": { SchemaProps: spec.SchemaProps{ - Description: "machineInfrastructure defines the metadata and infrastructure information for control plane machines.\n\nThis field is supported if and only if the control plane provider template referenced above is Machine based and supports setting replicas.", - Ref: ref("sigs.k8s.io/cluster-api/api/core/v1beta2.ControlPlaneClassMachineInfrastructureTemplate"), + Description: "infrastructureMachine defines infrastructure for control plane machines.\n\nThis field is supported if and only if the control plane provider template referenced above is Machine based and supports setting replicas.", + Ref: ref("sigs.k8s.io/cluster-api/api/core/v1beta2.ControlPlaneClassInfrastructureMachineTemplate"), }, }, "machineHealthCheck": { @@ -1532,7 +1532,30 @@ func schema_cluster_api_api_core_v1beta2_ControlPlaneClass(ref common.ReferenceC }, }, Dependencies: []string{ - "sigs.k8s.io/cluster-api/api/core/v1beta2.ClusterClassTemplateReference", "sigs.k8s.io/cluster-api/api/core/v1beta2.ControlPlaneClassMachineDeletionSpec", "sigs.k8s.io/cluster-api/api/core/v1beta2.ControlPlaneClassMachineInfrastructureTemplate", "sigs.k8s.io/cluster-api/api/core/v1beta2.ControlPlaneClassNamingStrategy", "sigs.k8s.io/cluster-api/api/core/v1beta2.MachineHealthCheckClass", "sigs.k8s.io/cluster-api/api/core/v1beta2.MachineReadinessGate", "sigs.k8s.io/cluster-api/api/core/v1beta2.ObjectMeta"}, + "sigs.k8s.io/cluster-api/api/core/v1beta2.ClusterClassTemplateReference", "sigs.k8s.io/cluster-api/api/core/v1beta2.ControlPlaneClassInfrastructureMachineTemplate", "sigs.k8s.io/cluster-api/api/core/v1beta2.ControlPlaneClassMachineDeletionSpec", "sigs.k8s.io/cluster-api/api/core/v1beta2.ControlPlaneClassNamingStrategy", "sigs.k8s.io/cluster-api/api/core/v1beta2.MachineHealthCheckClass", "sigs.k8s.io/cluster-api/api/core/v1beta2.MachineReadinessGate", "sigs.k8s.io/cluster-api/api/core/v1beta2.ObjectMeta"}, + } +} + +func schema_cluster_api_api_core_v1beta2_ControlPlaneClassInfrastructureMachineTemplate(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ControlPlaneClassInfrastructureMachineTemplate defines the template for a InfrastructureMachine of a ControlPlane.", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "templateRef": { + SchemaProps: spec.SchemaProps{ + Description: "templateRef is a required reference to the template for a InfrastructureMachine of a ControlPlane.", + Default: map[string]interface{}{}, + Ref: ref("sigs.k8s.io/cluster-api/api/core/v1beta2.ClusterClassTemplateReference"), + }, + }, + }, + Required: []string{"templateRef"}, + }, + }, + Dependencies: []string{ + "sigs.k8s.io/cluster-api/api/core/v1beta2.ClusterClassTemplateReference"}, } } @@ -1570,29 +1593,6 @@ func schema_cluster_api_api_core_v1beta2_ControlPlaneClassMachineDeletionSpec(re } } -func schema_cluster_api_api_core_v1beta2_ControlPlaneClassMachineInfrastructureTemplate(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "ControlPlaneClassMachineInfrastructureTemplate defines the template for a MachineInfrastructure of a ControlPlane.", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "templateRef": { - SchemaProps: spec.SchemaProps{ - Description: "templateRef is a required reference to the template for a MachineInfrastructure of a ControlPlane.", - Default: map[string]interface{}{}, - Ref: ref("sigs.k8s.io/cluster-api/api/core/v1beta2.ClusterClassTemplateReference"), - }, - }, - }, - Required: []string{"templateRef"}, - }, - }, - Dependencies: []string{ - "sigs.k8s.io/cluster-api/api/core/v1beta2.ClusterClassTemplateReference"}, - } -} - func schema_cluster_api_api_core_v1beta2_ControlPlaneClassNamingStrategy(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/cmd/clusterctl/client/cluster/objectgraph.go b/cmd/clusterctl/client/cluster/objectgraph.go index 22efc6c9d010..375ffbc43772 100644 --- a/cmd/clusterctl/client/cluster/objectgraph.go +++ b/cmd/clusterctl/client/cluster/objectgraph.go @@ -526,8 +526,8 @@ func (o *objectGraph) Discovery(ctx context.Context, namespace string) error { _, err = o.fetchRef(ctx, discoveryBackoff, cc.Spec.ControlPlane.TemplateRef.ToObjectReference(cc.Namespace)) errs = append(errs, err) - if cc.Spec.ControlPlane.MachineInfrastructure != nil { - _, err = o.fetchRef(ctx, discoveryBackoff, cc.Spec.ControlPlane.MachineInfrastructure.TemplateRef.ToObjectReference(cc.Namespace)) + if cc.Spec.ControlPlane.InfrastructureMachine != nil { + _, err = o.fetchRef(ctx, discoveryBackoff, cc.Spec.ControlPlane.InfrastructureMachine.TemplateRef.ToObjectReference(cc.Namespace)) errs = append(errs, err) } diff --git a/cmd/clusterctl/client/describe.go b/cmd/clusterctl/client/describe.go index 03c77a287088..69ec5ec34c31 100644 --- a/cmd/clusterctl/client/describe.go +++ b/cmd/clusterctl/client/describe.go @@ -50,7 +50,7 @@ type DescribeClusterOptions struct { // AddTemplateVirtualNode instructs the discovery process to group template under a virtual node. AddTemplateVirtualNode bool - // Echo displays MachineInfrastructure or BootstrapConfig objects if the object's ready condition is true + // Echo displays InfrastructureMachine or BootstrapConfig objects if the object's ready condition is true // or it has the same Status, Severity and Reason of the parent's object ready condition (it is an echo) Echo bool diff --git a/cmd/clusterctl/client/tree/discovery.go b/cmd/clusterctl/client/tree/discovery.go index d980fca9f606..c378d08d5c0c 100644 --- a/cmd/clusterctl/client/tree/discovery.go +++ b/cmd/clusterctl/client/tree/discovery.go @@ -50,7 +50,7 @@ type DiscoverOptions struct { // AddTemplateVirtualNode instructs the discovery process to group template under a virtual node. AddTemplateVirtualNode bool - // Echo displays MachineInfrastructure or BootstrapConfig objects if the object's ready condition is true + // Echo displays InfrastructureMachine or BootstrapConfig objects if the object's ready condition is true Echo bool // Grouping groups machine objects in case the ready conditions @@ -128,7 +128,7 @@ func Discovery(ctx context.Context, c client.Client, namespace, name string, opt if visible { if (m.Spec.InfrastructureRef != clusterv1.ContractVersionedObjectReference{}) { if machineInfra, err := external.GetObjectFromContractVersionedRef(ctx, c, &m.Spec.InfrastructureRef, m.Namespace); err == nil { - tree.Add(m, machineInfra, ObjectMetaName("MachineInfrastructure"), NoEcho(true)) + tree.Add(m, machineInfra, ObjectMetaName("InfrastructureMachine"), NoEcho(true)) } } diff --git a/cmd/clusterctl/client/tree/discovery_test.go b/cmd/clusterctl/client/tree/discovery_test.go index 25600870bfe6..171b8ed0dbd7 100644 --- a/cmd/clusterctl/client/tree/discovery_test.go +++ b/cmd/clusterctl/client/tree/discovery_test.go @@ -373,13 +373,13 @@ func Test_Discovery(t *testing.T) { }, // infra machines and boostrap should have meta names clusterv1.GroupVersionInfrastructure.String() + ", Kind=GenericInfrastructureMachine, ns1/cp1": func(g *WithT, obj client.Object) { - g.Expect(GetMetaName(obj)).To(Equal("MachineInfrastructure")) + g.Expect(GetMetaName(obj)).To(Equal("InfrastructureMachine")) }, clusterv1.GroupVersionBootstrap.String() + ", Kind=GenericBootstrapConfig, ns1/cp1": func(g *WithT, obj client.Object) { g.Expect(GetMetaName(obj)).To(Equal("BootstrapConfig")) }, clusterv1.GroupVersionInfrastructure.String() + ", Kind=GenericInfrastructureMachine, ns1/m1": func(g *WithT, obj client.Object) { - g.Expect(GetMetaName(obj)).To(Equal("MachineInfrastructure")) + g.Expect(GetMetaName(obj)).To(Equal("InfrastructureMachine")) }, clusterv1.GroupVersionBootstrap.String() + ", Kind=GenericBootstrapConfig, ns1/m1": func(g *WithT, obj client.Object) { g.Expect(GetMetaName(obj)).To(Equal("BootstrapConfig")) diff --git a/cmd/clusterctl/client/tree/doc.go b/cmd/clusterctl/client/tree/doc.go index 4337ab51f087..356d688f6f4c 100644 --- a/cmd/clusterctl/client/tree/doc.go +++ b/cmd/clusterctl/client/tree/doc.go @@ -29,7 +29,7 @@ surface problems, if any; in practice: e.g. secrets or templates. - It is possible to add "meta names" to object, thus making hierarchical tree more consistent for the users, - e.g. use MachineInfrastructure instead of using all the different infrastructure machine kinds (AWSMachine, VSphereMachine etc.). + e.g. use InfrastructureMachine instead of using all the different infrastructure machine kinds (AWSMachine, VSphereMachine etc.). - It is possible to add "virtual nodes", thus allowing to make the hierarchical tree more meaningful for the users, e.g. adding a Workers object to group all the MachineDeployments. diff --git a/cmd/clusterctl/cmd/describe_cluster.go b/cmd/clusterctl/cmd/describe_cluster.go index 626339d6bdc7..113d1f643fd1 100644 --- a/cmd/clusterctl/cmd/describe_cluster.go +++ b/cmd/clusterctl/cmd/describe_cluster.go @@ -69,7 +69,7 @@ var describeClusterClusterCmd = &cobra.Command{ # e.g. un-group all the machines with Ready=true instead of showing a single group node. clusterctl describe cluster test-1 --grouping=false - # Describe the cluster named test-1 showing the MachineInfrastructure and BootstrapConfig objects + # Describe the cluster named test-1 showing the InfrastructureMachine and BootstrapConfig objects # also when their status is the same as the status of the corresponding machine object. clusterctl describe cluster test-1 --echo`), @@ -102,7 +102,7 @@ func init() { "Show infrastructure and bootstrap config templates associated with the cluster.") describeClusterClusterCmd.Flags().BoolVar(&dc.echo, "echo", false, ""+ - "Show MachineInfrastructure and BootstrapConfig when ready condition is true or it has the Status, Severity and Reason of the machine's object.") + "Show InfrastructureMachine and BootstrapConfig when ready condition is true or it has the Status, Severity and Reason of the machine's object.") describeClusterClusterCmd.Flags().BoolVar(&dc.grouping, "grouping", true, "Groups machines when ready condition has the same Status, Severity and Reason.") describeClusterClusterCmd.Flags().BoolVar(&dc.disableGrouping, "disable-grouping", false, diff --git a/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml b/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml index 22c406789ea5..71b5a74dba40 100644 --- a/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml +++ b/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml @@ -2924,6 +2924,49 @@ spec: minimum: 0 type: integer type: object + infrastructureMachine: + description: |- + infrastructureMachine defines infrastructure for control plane machines. + + This field is supported if and only if the control plane provider template + referenced above is Machine based and supports setting replicas. + properties: + templateRef: + description: templateRef is a required reference to the template + for a InfrastructureMachine of a ControlPlane. + properties: + apiVersion: + description: |- + apiVersion of the template. + apiVersion must be fully qualified domain name followed by / and a version. + maxLength: 317 + minLength: 1 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*\/[a-z]([-a-z0-9]*[a-z0-9])?$ + type: string + kind: + description: |- + kind of the template. + kind must consist of alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character. + maxLength: 63 + minLength: 1 + pattern: ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ + type: string + name: + description: |- + name of the template. + name must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character. + maxLength: 253 + minLength: 1 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ + type: string + required: + - apiVersion + - kind + - name + type: object + required: + - templateRef + type: object machineHealthCheck: description: |- machineHealthCheck defines a MachineHealthCheck for this ControlPlaneClass. @@ -3047,50 +3090,6 @@ spec: pattern: ^\[[0-9]+-[0-9]+\]$ type: string type: object - machineInfrastructure: - description: |- - machineInfrastructure defines the metadata and infrastructure information - for control plane machines. - - This field is supported if and only if the control plane provider template - referenced above is Machine based and supports setting replicas. - properties: - templateRef: - description: templateRef is a required reference to the template - for a MachineInfrastructure of a ControlPlane. - properties: - apiVersion: - description: |- - apiVersion of the template. - apiVersion must be fully qualified domain name followed by / and a version. - maxLength: 317 - minLength: 1 - pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*\/[a-z]([-a-z0-9]*[a-z0-9])?$ - type: string - kind: - description: |- - kind of the template. - kind must consist of alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character. - maxLength: 63 - minLength: 1 - pattern: ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ - type: string - name: - description: |- - name of the template. - name must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character. - maxLength: 253 - minLength: 1 - pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ - type: string - required: - - apiVersion - - kind - - name - type: object - required: - - templateRef - type: object metadata: description: |- metadata is the metadata applied to the ControlPlane and the Machines of the ControlPlane diff --git a/docs/book/src/tasks/experimental-features/cluster-class/write-clusterclass.md b/docs/book/src/tasks/experimental-features/cluster-class/write-clusterclass.md index 2961b0794cb8..3d3664499fb7 100644 --- a/docs/book/src/tasks/experimental-features/cluster-class/write-clusterclass.md +++ b/docs/book/src/tasks/experimental-features/cluster-class/write-clusterclass.md @@ -41,7 +41,7 @@ spec: kind: KubeadmControlPlaneTemplate name: docker-clusterclass-v0.1.0 namespace: default - machineInfrastructure: + infrastructureMachine: ref: kind: DockerMachineTemplate apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 diff --git a/exp/topology/desiredstate/desired_state.go b/exp/topology/desiredstate/desired_state.go index d07b18f6da50..e660d251b5a5 100644 --- a/exp/topology/desiredstate/desired_state.go +++ b/exp/topology/desiredstate/desired_state.go @@ -230,7 +230,7 @@ func computeInfrastructureCluster(_ context.Context, s *scope.Scope) (*unstructu // that should be referenced by the ControlPlane object. func (g *generator) computeControlPlaneInfrastructureMachineTemplate(ctx context.Context, s *scope.Scope) (*unstructured.Unstructured, error) { template := s.Blueprint.ControlPlane.InfrastructureMachineTemplate - templateClonedFromRef := s.Blueprint.ClusterClass.Spec.ControlPlane.MachineInfrastructure.TemplateRef.ToObjectReference(s.Blueprint.ClusterClass.Namespace) + templateClonedFromRef := s.Blueprint.ClusterClass.Spec.ControlPlane.InfrastructureMachine.TemplateRef.ToObjectReference(s.Blueprint.ClusterClass.Namespace) cluster := s.Current.Cluster // Check if the current control plane object has a machineTemplate.infrastructureRef already defined. diff --git a/exp/topology/desiredstate/desired_state_test.go b/exp/topology/desiredstate/desired_state_test.go index 991523b57f50..4ba3ad3e3c5f 100644 --- a/exp/topology/desiredstate/desired_state_test.go +++ b/exp/topology/desiredstate/desired_state_test.go @@ -233,7 +233,7 @@ func TestComputeControlPlaneInfrastructureMachineTemplate(t *testing.T) { assertTemplateToTemplate(g, assertTemplateInput{ cluster: scope.Current.Cluster, - templateRef: blueprint.ClusterClass.Spec.ControlPlane.MachineInfrastructure.TemplateRef, + templateRef: blueprint.ClusterClass.Spec.ControlPlane.InfrastructureMachine.TemplateRef, template: blueprint.ControlPlane.InfrastructureMachineTemplate, currentObjectName: "", obj: obj, @@ -259,7 +259,7 @@ func TestComputeControlPlaneInfrastructureMachineTemplate(t *testing.T) { assertTemplateToTemplate(g, assertTemplateInput{ cluster: scope.Current.Cluster, - templateRef: blueprint.ClusterClass.Spec.ControlPlane.MachineInfrastructure.TemplateRef, + templateRef: blueprint.ClusterClass.Spec.ControlPlane.InfrastructureMachine.TemplateRef, template: blueprint.ControlPlane.InfrastructureMachineTemplate, currentObjectName: "", obj: obj, @@ -304,7 +304,7 @@ func TestComputeControlPlaneInfrastructureMachineTemplate(t *testing.T) { assertTemplateToTemplate(g, assertTemplateInput{ cluster: s.Current.Cluster, - templateRef: blueprint.ClusterClass.Spec.ControlPlane.MachineInfrastructure.TemplateRef, + templateRef: blueprint.ClusterClass.Spec.ControlPlane.InfrastructureMachine.TemplateRef, template: blueprint.ControlPlane.InfrastructureMachineTemplate, currentObjectName: contract.ObjToRef(currentInfrastructureMachineTemplate).Name, obj: obj, @@ -345,7 +345,7 @@ func TestComputeControlPlaneInfrastructureMachineTemplate(t *testing.T) { assertTemplateToTemplate(g, assertTemplateInput{ cluster: s.Current.Cluster, - templateRef: blueprint.ClusterClass.Spec.ControlPlane.MachineInfrastructure.TemplateRef, + templateRef: blueprint.ClusterClass.Spec.ControlPlane.InfrastructureMachine.TemplateRef, template: blueprint.ControlPlane.InfrastructureMachineTemplate, currentObjectName: contract.ObjToRef(currentInfrastructureMachineTemplate).Name, obj: obj, diff --git a/exp/topology/scope/blueprint.go b/exp/topology/scope/blueprint.go index 402ae827af62..36f7ff4622a0 100644 --- a/exp/topology/scope/blueprint.go +++ b/exp/topology/scope/blueprint.go @@ -93,7 +93,7 @@ type MachinePoolBlueprint struct { // HasControlPlaneInfrastructureMachine checks whether the clusterClass mandates the controlPlane has infrastructureMachines. func (b *ClusterBlueprint) HasControlPlaneInfrastructureMachine() bool { - return b.ClusterClass.Spec.ControlPlane.MachineInfrastructure != nil + return b.ClusterClass.Spec.ControlPlane.InfrastructureMachine != nil } // IsControlPlaneMachineHealthCheckEnabled returns true if a MachineHealthCheck should be created for the control plane. @@ -123,7 +123,7 @@ func (b *ClusterBlueprint) ControlPlaneMachineHealthCheckClass() *clusterv1.Mach return b.ControlPlane.MachineHealthCheck } -// HasControlPlaneMachineHealthCheck returns true if the ControlPlaneClass has both MachineInfrastructure and a MachineHealthCheck defined. +// HasControlPlaneMachineHealthCheck returns true if the ControlPlaneClass has both InfrastructureMachine and a MachineHealthCheck defined. func (b *ClusterBlueprint) HasControlPlaneMachineHealthCheck() bool { return b.HasControlPlaneInfrastructureMachine() && b.ClusterClass.Spec.ControlPlane.MachineHealthCheck != nil } diff --git a/internal/api/core/v1alpha4/conversion.go b/internal/api/core/v1alpha4/conversion.go index a301d1d680de..9976fa5705c6 100644 --- a/internal/api/core/v1alpha4/conversion.go +++ b/internal/api/core/v1alpha4/conversion.go @@ -765,6 +765,10 @@ func Convert_v1alpha4_ControlPlaneClass_To_v1beta2_ControlPlaneClass(in *Control } convert_v1alpha4_LocalObjectTemplate_To_v1beta2_ClusterClassTemplateReference(&in.LocalObjectTemplate, &out.TemplateRef, s) + if in.MachineInfrastructure != nil && in.MachineInfrastructure.Ref != nil { + out.InfrastructureMachine = &clusterv1.ControlPlaneClassInfrastructureMachineTemplate{} + return Convert_v1alpha4_LocalObjectTemplate_To_v1beta2_ControlPlaneClassInfrastructureMachineTemplate(in.MachineInfrastructure, out.InfrastructureMachine, s) + } return nil } @@ -956,6 +960,10 @@ func Convert_v1beta2_ControlPlaneClass_To_v1alpha4_ControlPlaneClass(in *cluster } Convert_v1beta2_ClusterClassTemplateReference_To_v1alpha4_LocalObjectTemplate(&in.TemplateRef, &out.LocalObjectTemplate, s) + if in.InfrastructureMachine != nil && !reflect.DeepEqual(in.InfrastructureMachine.TemplateRef, clusterv1.ControlPlaneClassInfrastructureMachineTemplate{}) { + out.MachineInfrastructure = &LocalObjectTemplate{} + return Convert_v1beta2_ControlPlaneClassInfrastructureMachineTemplate_To_v1alpha4_LocalObjectTemplate(in.InfrastructureMachine, out.MachineInfrastructure, s) + } return nil } @@ -1188,7 +1196,7 @@ func Convert_v1alpha4_MachineSpec_To_v1beta2_MachineSpec(in *MachineSpec, out *c return nil } -func Convert_v1alpha4_LocalObjectTemplate_To_v1beta2_ControlPlaneClassMachineInfrastructureTemplate(in *LocalObjectTemplate, out *clusterv1.ControlPlaneClassMachineInfrastructureTemplate, s apimachineryconversion.Scope) error { +func Convert_v1alpha4_LocalObjectTemplate_To_v1beta2_ControlPlaneClassInfrastructureMachineTemplate(in *LocalObjectTemplate, out *clusterv1.ControlPlaneClassInfrastructureMachineTemplate, s apimachineryconversion.Scope) error { convert_v1alpha4_LocalObjectTemplate_To_v1beta2_ClusterClassTemplateReference(in, &out.TemplateRef, s) return nil } @@ -1215,7 +1223,7 @@ func convert_v1alpha4_LocalObjectTemplate_To_v1beta2_ClusterClassTemplateReferen } } -func Convert_v1beta2_ControlPlaneClassMachineInfrastructureTemplate_To_v1alpha4_LocalObjectTemplate(in *clusterv1.ControlPlaneClassMachineInfrastructureTemplate, out *LocalObjectTemplate, s apimachineryconversion.Scope) error { +func Convert_v1beta2_ControlPlaneClassInfrastructureMachineTemplate_To_v1alpha4_LocalObjectTemplate(in *clusterv1.ControlPlaneClassInfrastructureMachineTemplate, out *LocalObjectTemplate, s apimachineryconversion.Scope) error { Convert_v1beta2_ClusterClassTemplateReference_To_v1alpha4_LocalObjectTemplate(&in.TemplateRef, out, s) return nil } diff --git a/internal/api/core/v1alpha4/zz_generated.conversion.go b/internal/api/core/v1alpha4/zz_generated.conversion.go index ac30c3e2ed2f..896c9f8218e1 100644 --- a/internal/api/core/v1alpha4/zz_generated.conversion.go +++ b/internal/api/core/v1alpha4/zz_generated.conversion.go @@ -310,8 +310,8 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddConversionFunc((*LocalObjectTemplate)(nil), (*v1beta2.ControlPlaneClassMachineInfrastructureTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1alpha4_LocalObjectTemplate_To_v1beta2_ControlPlaneClassMachineInfrastructureTemplate(a.(*LocalObjectTemplate), b.(*v1beta2.ControlPlaneClassMachineInfrastructureTemplate), scope) + if err := s.AddConversionFunc((*LocalObjectTemplate)(nil), (*v1beta2.ControlPlaneClassInfrastructureMachineTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha4_LocalObjectTemplate_To_v1beta2_ControlPlaneClassInfrastructureMachineTemplate(a.(*LocalObjectTemplate), b.(*v1beta2.ControlPlaneClassInfrastructureMachineTemplate), scope) }); err != nil { return err } @@ -420,8 +420,8 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } - if err := s.AddConversionFunc((*v1beta2.ControlPlaneClassMachineInfrastructureTemplate)(nil), (*LocalObjectTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { - return Convert_v1beta2_ControlPlaneClassMachineInfrastructureTemplate_To_v1alpha4_LocalObjectTemplate(a.(*v1beta2.ControlPlaneClassMachineInfrastructureTemplate), b.(*LocalObjectTemplate), scope) + if err := s.AddConversionFunc((*v1beta2.ControlPlaneClassInfrastructureMachineTemplate)(nil), (*LocalObjectTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1beta2_ControlPlaneClassInfrastructureMachineTemplate_To_v1alpha4_LocalObjectTemplate(a.(*v1beta2.ControlPlaneClassInfrastructureMachineTemplate), b.(*LocalObjectTemplate), scope) }); err != nil { return err } @@ -941,15 +941,7 @@ func autoConvert_v1alpha4_ControlPlaneClass_To_v1beta2_ControlPlaneClass(in *Con return err } // WARNING: in.LocalObjectTemplate requires manual conversion: does not exist in peer-type - if in.MachineInfrastructure != nil { - in, out := &in.MachineInfrastructure, &out.MachineInfrastructure - *out = new(v1beta2.ControlPlaneClassMachineInfrastructureTemplate) - if err := Convert_v1alpha4_LocalObjectTemplate_To_v1beta2_ControlPlaneClassMachineInfrastructureTemplate(*in, *out, s); err != nil { - return err - } - } else { - out.MachineInfrastructure = nil - } + // WARNING: in.MachineInfrastructure requires manual conversion: does not exist in peer-type return nil } @@ -958,15 +950,7 @@ func autoConvert_v1beta2_ControlPlaneClass_To_v1alpha4_ControlPlaneClass(in *v1b return err } // WARNING: in.TemplateRef requires manual conversion: does not exist in peer-type - if in.MachineInfrastructure != nil { - in, out := &in.MachineInfrastructure, &out.MachineInfrastructure - *out = new(LocalObjectTemplate) - if err := Convert_v1beta2_ControlPlaneClassMachineInfrastructureTemplate_To_v1alpha4_LocalObjectTemplate(*in, *out, s); err != nil { - return err - } - } else { - out.MachineInfrastructure = nil - } + // WARNING: in.InfrastructureMachine requires manual conversion: does not exist in peer-type // WARNING: in.MachineHealthCheck requires manual conversion: does not exist in peer-type // WARNING: in.NamingStrategy requires manual conversion: does not exist in peer-type // WARNING: in.Deletion requires manual conversion: does not exist in peer-type diff --git a/internal/controllers/clusterclass/clusterclass_controller.go b/internal/controllers/clusterclass/clusterclass_controller.go index 8672cefa0ce5..25ae9d0671f0 100644 --- a/internal/controllers/clusterclass/clusterclass_controller.go +++ b/internal/controllers/clusterclass/clusterclass_controller.go @@ -218,8 +218,8 @@ func (r *Reconciler) reconcileExternalReferences(ctx context.Context, s *scope) clusterClass.Spec.Infrastructure.TemplateRef, clusterClass.Spec.ControlPlane.TemplateRef, } - if clusterClass.Spec.ControlPlane.MachineInfrastructure != nil { - refs = append(refs, clusterClass.Spec.ControlPlane.MachineInfrastructure.TemplateRef) + if clusterClass.Spec.ControlPlane.InfrastructureMachine != nil { + refs = append(refs, clusterClass.Spec.ControlPlane.InfrastructureMachine.TemplateRef) } for _, mdClass := range clusterClass.Spec.Workers.MachineDeployments { refs = append(refs, mdClass.Bootstrap.TemplateRef, mdClass.Infrastructure.TemplateRef) diff --git a/internal/controllers/clusterclass/clusterclass_controller_test.go b/internal/controllers/clusterclass/clusterclass_controller_test.go index d3cf1956e3df..cc2b492137ad 100644 --- a/internal/controllers/clusterclass/clusterclass_controller_test.go +++ b/internal/controllers/clusterclass/clusterclass_controller_test.go @@ -257,11 +257,11 @@ func assertControlPlaneTemplate(ctx context.Context, actualClusterClass *cluster } // If the control plane has machine infra assert that the infra machine template has the correct owner reference. - if actualClusterClass.Spec.ControlPlane.MachineInfrastructure != nil { + if actualClusterClass.Spec.ControlPlane.InfrastructureMachine != nil { actualInfrastructureMachineTemplate := builder.InfrastructureMachineTemplate("", "").Build() actualInfrastructureMachineTemplateKey := client.ObjectKey{ Namespace: ns.Name, - Name: actualClusterClass.Spec.ControlPlane.MachineInfrastructure.TemplateRef.Name, + Name: actualClusterClass.Spec.ControlPlane.InfrastructureMachine.TemplateRef.Name, } if err := env.Get(ctx, actualInfrastructureMachineTemplateKey, actualInfrastructureMachineTemplate); err != nil { return err @@ -271,7 +271,7 @@ func assertControlPlaneTemplate(ctx context.Context, actualClusterClass *cluster } // Assert the ClusterClass has the expected APIVersion and Kind to the infrastructure machine template - if err := referenceExistsWithCorrectKindAndAPIVersion(actualClusterClass.Spec.ControlPlane.MachineInfrastructure.TemplateRef, + if err := referenceExistsWithCorrectKindAndAPIVersion(actualClusterClass.Spec.ControlPlane.InfrastructureMachine.TemplateRef, builder.GenericInfrastructureMachineTemplateKind, builder.InfrastructureGroupVersion); err != nil { return err diff --git a/internal/controllers/topology/cluster/blueprint.go b/internal/controllers/topology/cluster/blueprint.go index 5a00369eeded..a5e115829e7d 100644 --- a/internal/controllers/topology/cluster/blueprint.go +++ b/internal/controllers/topology/cluster/blueprint.go @@ -53,13 +53,13 @@ func (r *Reconciler) getBlueprint(ctx context.Context, cluster *clusterv1.Cluste // If the clusterClass mandates the controlPlane has infrastructureMachines, read it. if blueprint.HasControlPlaneInfrastructureMachine() { - blueprint.ControlPlane.InfrastructureMachineTemplate, err = r.getReference(ctx, blueprint.ClusterClass.Spec.ControlPlane.MachineInfrastructure.TemplateRef.ToObjectReference(clusterClass.Namespace)) + blueprint.ControlPlane.InfrastructureMachineTemplate, err = r.getReference(ctx, blueprint.ClusterClass.Spec.ControlPlane.InfrastructureMachine.TemplateRef.ToObjectReference(clusterClass.Namespace)) if err != nil { - return nil, errors.Wrapf(err, "failed to get control plane's machine template for ClusterClass %s", klog.KObj(blueprint.ClusterClass)) + return nil, errors.Wrapf(err, "failed to get control plane's infrastructure machine template for ClusterClass %s", klog.KObj(blueprint.ClusterClass)) } } - // If the clusterClass defines a valid MachineHealthCheck (including a defined MachineInfrastructure) set the blueprint MachineHealthCheck. + // If the clusterClass defines a valid MachineHealthCheck (including a defined InfrastructureMachine) set the blueprint MachineHealthCheck. if blueprint.HasControlPlaneMachineHealthCheck() { blueprint.ControlPlane.MachineHealthCheck = blueprint.ClusterClass.Spec.ControlPlane.MachineHealthCheck } diff --git a/internal/controllers/topology/cluster/cluster_controller_test.go b/internal/controllers/topology/cluster/cluster_controller_test.go index e43609c1ca37..48b72c9b213e 100644 --- a/internal/controllers/topology/cluster/cluster_controller_test.go +++ b/internal/controllers/topology/cluster/cluster_controller_test.go @@ -1044,7 +1044,7 @@ func assertControlPlaneReconcile(cluster *clusterv1.Cluster) error { return err } // Check for the ControlPlaneInfrastructure if it's referenced in the clusterClass. - if clusterClass.Spec.ControlPlane.MachineInfrastructure != nil { + if clusterClass.Spec.ControlPlane.InfrastructureMachine != nil { cpInfra, err := contract.ControlPlane().MachineTemplate().InfrastructureRef().Get(cp) if err != nil { return err diff --git a/internal/controllers/topology/cluster/current_state.go b/internal/controllers/topology/cluster/current_state.go index 63b897ec7c37..236c2877e1ab 100644 --- a/internal/controllers/topology/cluster/current_state.go +++ b/internal/controllers/topology/cluster/current_state.go @@ -101,7 +101,7 @@ func (r *Reconciler) getCurrentInfrastructureClusterState(ctx context.Context, b } // getCurrentControlPlaneState returns information on the ControlPlane being used by the Cluster. If a reference is not found, -// an error is thrown. If the ControlPlane requires MachineInfrastructure according to its ClusterClass an error will be +// an error is thrown. If the ControlPlane requires InfrastructureMachine according to its ClusterClass an error will be // thrown if the ControlPlane has no MachineTemplates. func (r *Reconciler) getCurrentControlPlaneState(ctx context.Context, blueprintControlPlane *scope.ControlPlaneBlueprint, blueprintHasControlPlaneInfrastructureMachine bool, cluster *clusterv1.Cluster) (*scope.ControlPlaneState, error) { var err error diff --git a/internal/controllers/topology/cluster/reconcile_state_test.go b/internal/controllers/topology/cluster/reconcile_state_test.go index b4e58e47e3d2..3a8451f35b26 100644 --- a/internal/controllers/topology/cluster/reconcile_state_test.go +++ b/internal/controllers/topology/cluster/reconcile_state_test.go @@ -1608,7 +1608,7 @@ func testReconcileControlPlane(t *testing.T, controlPlaneContractVersion string) ClusterClass: &clusterv1.ClusterClass{}, } if tt.class.InfrastructureMachineTemplate != nil { - s.Blueprint.ClusterClass.Spec.ControlPlane.MachineInfrastructure = &clusterv1.ControlPlaneClassMachineInfrastructureTemplate{ + s.Blueprint.ClusterClass.Spec.ControlPlane.InfrastructureMachine = &clusterv1.ControlPlaneClassInfrastructureMachineTemplate{ TemplateRef: objToClusterClassTemplateRef(tt.class.InfrastructureMachineTemplate), } } @@ -1801,7 +1801,7 @@ func TestReconcileControlPlaneCleanup(t *testing.T) { ClusterClass: &clusterv1.ClusterClass{ Spec: clusterv1.ClusterClassSpec{ ControlPlane: clusterv1.ControlPlaneClass{ - MachineInfrastructure: &clusterv1.ControlPlaneClassMachineInfrastructureTemplate{ + InfrastructureMachine: &clusterv1.ControlPlaneClassInfrastructureMachineTemplate{ TemplateRef: objToClusterClassTemplateRef(infrastructureMachineTemplate), }, }, @@ -1885,16 +1885,16 @@ func TestReconcileControlPlaneMachineHealthCheck(t *testing.T) { Build(), }, { - name: "Should not create ControlPlane MachineHealthCheck when no MachineInfrastructure is defined", + name: "Should not create ControlPlane MachineHealthCheck when no InfrastructureMachine is defined", class: ccWithoutControlPlaneInfrastructure, current: &scope.ControlPlaneState{ Object: controlPlane1.DeepCopy(), - // Note this creation would be blocked by the validation Webhook. MHC with no MachineInfrastructure is not allowed. + // Note this creation would be blocked by the validation Webhook. MHC with no InfrastructureMachine is not allowed. MachineHealthCheck: mhcBuilder.Build(), }, desired: &scope.ControlPlaneState{ Object: controlPlane1.DeepCopy(), - // ControlPlane does not have defined MachineInfrastructure. + // ControlPlane does not have defined InfrastructureMachine. // InfrastructureMachineTemplate: infrastructureMachineTemplate.DeepCopy(), }, want: nil, @@ -1957,7 +1957,7 @@ func TestReconcileControlPlaneMachineHealthCheck(t *testing.T) { ClusterClass: &clusterv1.ClusterClass{}, } if tt.class.InfrastructureMachineTemplate != nil { - s.Blueprint.ClusterClass.Spec.ControlPlane.MachineInfrastructure = &clusterv1.ControlPlaneClassMachineInfrastructureTemplate{ + s.Blueprint.ClusterClass.Spec.ControlPlane.InfrastructureMachine = &clusterv1.ControlPlaneClassInfrastructureMachineTemplate{ TemplateRef: objToClusterClassTemplateRef(tt.class.InfrastructureMachineTemplate), } } diff --git a/internal/topology/check/compatibility.go b/internal/topology/check/compatibility.go index f391b5bdd7cb..e531b80b29cb 100644 --- a/internal/topology/check/compatibility.go +++ b/internal/topology/check/compatibility.go @@ -180,9 +180,9 @@ func ClusterClassesAreCompatible(current, desired *clusterv1.ClusterClass) field // Validate control plane changes desired a compatible way. allErrs = append(allErrs, ClusterClassTemplateAreCompatible(current.Spec.ControlPlane.TemplateRef, desired.Spec.ControlPlane.TemplateRef, field.NewPath("spec", "controlPlane"))...) - if desired.Spec.ControlPlane.MachineInfrastructure != nil && current.Spec.ControlPlane.MachineInfrastructure != nil { - allErrs = append(allErrs, ClusterClassTemplateAreCompatible(current.Spec.ControlPlane.MachineInfrastructure.TemplateRef, desired.Spec.ControlPlane.MachineInfrastructure.TemplateRef, - field.NewPath("spec", "controlPlane", "machineInfrastructure"))...) + if desired.Spec.ControlPlane.InfrastructureMachine != nil && current.Spec.ControlPlane.InfrastructureMachine != nil { + allErrs = append(allErrs, ClusterClassTemplateAreCompatible(current.Spec.ControlPlane.InfrastructureMachine.TemplateRef, desired.Spec.ControlPlane.InfrastructureMachine.TemplateRef, + field.NewPath("spec", "controlPlane", "infrastructureMachine"))...) } // Validate changes to MachineDeployments. @@ -404,8 +404,8 @@ func ClusterClassTemplatesAreValid(clusterClass *clusterv1.ClusterClass) field.E allErrs = append(allErrs, ClusterClassTemplateIsValid(clusterClass.Spec.Infrastructure.TemplateRef, field.NewPath("spec", "infrastructure"))...) allErrs = append(allErrs, ClusterClassTemplateIsValid(clusterClass.Spec.ControlPlane.TemplateRef, field.NewPath("spec", "controlPlane"))...) - if clusterClass.Spec.ControlPlane.MachineInfrastructure != nil { - allErrs = append(allErrs, ClusterClassTemplateIsValid(clusterClass.Spec.ControlPlane.MachineInfrastructure.TemplateRef, field.NewPath("spec", "controlPlane", "machineInfrastructure"))...) + if clusterClass.Spec.ControlPlane.InfrastructureMachine != nil { + allErrs = append(allErrs, ClusterClassTemplateIsValid(clusterClass.Spec.ControlPlane.InfrastructureMachine.TemplateRef, field.NewPath("spec", "controlPlane", "infrastructureMachine"))...) } for i := range clusterClass.Spec.Workers.MachineDeployments { diff --git a/internal/topology/upgrade/clusterctl_upgrade_test.go b/internal/topology/upgrade/clusterctl_upgrade_test.go index bed89c81518d..12834be5a8be 100644 --- a/internal/topology/upgrade/clusterctl_upgrade_test.go +++ b/internal/topology/upgrade/clusterctl_upgrade_test.go @@ -383,7 +383,7 @@ func createT1ClusterClass(g *WithT, ns *corev1.Namespace, ct1 client.Client) *cl Name: controlPlaneTemplate.Name, APIVersion: testt1v1beta1.GroupVersion.String(), }, - MachineInfrastructure: &clusterv1.ControlPlaneClassMachineInfrastructureTemplate{ + InfrastructureMachine: &clusterv1.ControlPlaneClassInfrastructureMachineTemplate{ TemplateRef: clusterv1.ClusterClassTemplateReference{ Kind: "TestResourceTemplate", Name: infrastructureMachineTemplate1.Name, @@ -576,7 +576,7 @@ func createT2ClusterClass(g *WithT, ns *corev1.Namespace, ct2 client.Client) *cl Name: controlPlaneTemplate.Name, APIVersion: testt2v1beta2.GroupVersion.String(), }, - MachineInfrastructure: &clusterv1.ControlPlaneClassMachineInfrastructureTemplate{ + InfrastructureMachine: &clusterv1.ControlPlaneClassInfrastructureMachineTemplate{ TemplateRef: clusterv1.ClusterClassTemplateReference{ Kind: "TestResourceTemplate", Name: infrastructureMachineTemplate1.Name, diff --git a/internal/webhooks/cluster.go b/internal/webhooks/cluster.go index ddd984f28ba2..7485ef7cd3cc 100644 --- a/internal/webhooks/cluster.go +++ b/internal/webhooks/cluster.go @@ -641,11 +641,11 @@ func validateMachineHealthChecks(cluster *clusterv1.Cluster, clusterClass *clust // Validate ControlPlane MachineHealthCheck if defined. if !cluster.Spec.Topology.ControlPlane.MachineHealthCheck.IsZero() { - // Ensure ControlPlane does not define a MachineHealthCheck if the ClusterClass does not define MachineInfrastructure. - if clusterClass.Spec.ControlPlane.MachineInfrastructure == nil { + // Ensure ControlPlane does not define a MachineHealthCheck if the ClusterClass does not define InfrastructureMachine. + if clusterClass.Spec.ControlPlane.InfrastructureMachine == nil { allErrs = append(allErrs, field.Forbidden( fldPath, - "can be set only if spec.controlPlane.machineInfrastructure is set in ClusterClass", + "can be set only if spec.controlPlane.infrastructureMachine is set in ClusterClass", )) } allErrs = append(allErrs, validateMachineHealthCheckClass(fldPath, cluster.Namespace, diff --git a/internal/webhooks/cluster_test.go b/internal/webhooks/cluster_test.go index 7ec27b2a2662..f9428ddc9138 100644 --- a/internal/webhooks/cluster_test.go +++ b/internal/webhooks/cluster_test.go @@ -2667,7 +2667,7 @@ func TestClusterTopologyValidationForTopologyClassChange(t *testing.T) { wantErr: true, }, { - name: "Accept cluster.topology.class change with a compatible controlPlane.MachineInfrastructure ref change", + name: "Accept cluster.topology.class change with a compatible controlPlane.infrastructureMachine ref change", firstClass: builder.ClusterClass(metav1.NamespaceDefault, "class1"). WithInfrastructureClusterTemplate(refToUnstructured(ref)). WithControlPlaneTemplate(refToUnstructured(ref)). @@ -2681,7 +2681,7 @@ func TestClusterTopologyValidationForTopologyClassChange(t *testing.T) { wantErr: false, }, { - name: "Accept cluster.topology.class change with a compatible controlPlane.MachineInfrastructure ref change", + name: "Accept cluster.topology.class change with a compatible controlPlane.infrastructureMachine ref change", firstClass: builder.ClusterClass(metav1.NamespaceDefault, "class1"). WithInfrastructureClusterTemplate(refToUnstructured(ref)). WithControlPlaneTemplate(refToUnstructured(ref)). @@ -2695,7 +2695,7 @@ func TestClusterTopologyValidationForTopologyClassChange(t *testing.T) { wantErr: false, }, { - name: "Reject cluster.topology.class change with an incompatible controlPlane.MachineInfrastructure Kind ref change", + name: "Reject cluster.topology.class change with an incompatible controlPlane.infrastructureMachine Kind ref change", firstClass: builder.ClusterClass(metav1.NamespaceDefault, "class1"). WithInfrastructureClusterTemplate(refToUnstructured(ref)). WithControlPlaneTemplate(refToUnstructured(ref)). @@ -2709,7 +2709,7 @@ func TestClusterTopologyValidationForTopologyClassChange(t *testing.T) { wantErr: true, }, { - name: "Reject cluster.topology.class change with an incompatible controlPlane.MachineInfrastructure APIVersion ref change", + name: "Reject cluster.topology.class change with an incompatible controlPlane.infrastructureMachine APIVersion ref change", firstClass: builder.ClusterClass(metav1.NamespaceDefault, "class1"). WithInfrastructureClusterTemplate(refToUnstructured(ref)). WithControlPlaneTemplate(refToUnstructured(ref)). diff --git a/internal/webhooks/clusterclass.go b/internal/webhooks/clusterclass.go index bf9685cfb59e..60f37add3f15 100644 --- a/internal/webhooks/clusterclass.go +++ b/internal/webhooks/clusterclass.go @@ -367,11 +367,11 @@ func validateMachineHealthCheckClasses(clusterClass *clusterv1.ClusterClass) fie allErrs = append(allErrs, validateMachineHealthCheckClass(fldPath, clusterClass.Namespace, clusterClass.Spec.ControlPlane.MachineHealthCheck)...) - // Ensure ControlPlane does not define a MachineHealthCheck if it does not define MachineInfrastructure. - if clusterClass.Spec.ControlPlane.MachineInfrastructure == nil { + // Ensure ControlPlane does not define a MachineHealthCheck if it does not define InfrastructureMachine. + if clusterClass.Spec.ControlPlane.InfrastructureMachine == nil { allErrs = append(allErrs, field.Forbidden( - fldPath.Child("machineInfrastructure"), - "can be set only if spec.controlPlane.machineInfrastructure is set", + fldPath.Child("infrastructureMachine"), + "can be set only if spec.controlPlane.infrastructureMachine is set", )) } } diff --git a/internal/webhooks/clusterclass_test.go b/internal/webhooks/clusterclass_test.go index 6d1af42472de..c94d29466718 100644 --- a/internal/webhooks/clusterclass_test.go +++ b/internal/webhooks/clusterclass_test.go @@ -680,7 +680,7 @@ func TestClusterClassValidation(t *testing.T) { expectErr: true, }, { - name: "create pass if valid machineHealthCheck defined for ControlPlane with MachineInfrastructure set", + name: "create pass if valid machineHealthCheck defined for ControlPlane with InfrastructureMachine set", in: builder.ClusterClass(metav1.NamespaceDefault, "class1"). WithInfrastructureClusterTemplate( builder.InfrastructureClusterTemplate(metav1.NamespaceDefault, "infra1").Build()). @@ -703,7 +703,7 @@ func TestClusterClassValidation(t *testing.T) { Build(), }, { - name: "create fail if MachineHealthCheck defined for ControlPlane with MachineInfrastructure unset", + name: "create fail if MachineHealthCheck defined for ControlPlane with InfrastructureMachine unset", in: builder.ClusterClass(metav1.NamespaceDefault, "class1"). WithInfrastructureClusterTemplate( builder.InfrastructureClusterTemplate(metav1.NamespaceDefault, "infra1").Build()). diff --git a/internal/webhooks/patch_validation.go b/internal/webhooks/patch_validation.go index d25daa53d875..2f7a5c2a4465 100644 --- a/internal/webhooks/patch_validation.go +++ b/internal/webhooks/patch_validation.go @@ -192,8 +192,8 @@ func validateSelectors(selector clusterv1.PatchSelector, class *clusterv1.Cluste if selectorMatchTemplate(selector, class.Spec.ControlPlane.TemplateRef) { match = true } - if class.Spec.ControlPlane.MachineInfrastructure != nil && - selectorMatchTemplate(selector, class.Spec.ControlPlane.MachineInfrastructure.TemplateRef) { + if class.Spec.ControlPlane.InfrastructureMachine != nil && + selectorMatchTemplate(selector, class.Spec.ControlPlane.InfrastructureMachine.TemplateRef) { match = true } if !match { diff --git a/internal/webhooks/test/clusterclass_test.go b/internal/webhooks/test/clusterclass_test.go index beb9304ba3d9..4c4c2ea1a9fd 100644 --- a/internal/webhooks/test/clusterclass_test.go +++ b/internal/webhooks/test/clusterclass_test.go @@ -531,7 +531,7 @@ func TestClusterClassWebhook_Delete_MultipleExistingClusters(t *testing.T) { // createTemplates builds and then creates all required ClusterClass templates in the envtest API server. func createTemplates(ns *corev1.Namespace) (func() error, error) { - // Templates for MachineInfrastructure, ClusterInfrastructure, ControlPlane and Bootstrap. + // Templates for InfrastructureMachine, ClusterInfrastructure, ControlPlane and Bootstrap. infrastructureMachineTemplate1 := builder.TestInfrastructureMachineTemplate(ns.Name, infrastructureMachineTemplateName1).Build() infrastructureMachineTemplate2 := builder.TestInfrastructureMachineTemplate(ns.Name, infrastructureMachineTemplateName2).Build() infrastructureClusterTemplate1 := builder.TestInfrastructureClusterTemplate(ns.Name, infrastructureClusterTemplateName1).Build() diff --git a/test/e2e/clusterclass_changes.go b/test/e2e/clusterclass_changes.go index 3297b748e608..444e882f508f 100644 --- a/test/e2e/clusterclass_changes.go +++ b/test/e2e/clusterclass_changes.go @@ -793,7 +793,7 @@ func rebaseClusterClassAndWait(ctx context.Context, input rebaseClusterClassAndW newClusterClass.Spec.Workers.MachinePools[i] = mpClass } - cloneTemplateAndUpdateRef(ctx, mgmtClient, &newClusterClass.Spec.ControlPlane.MachineInfrastructure.TemplateRef, input.ClusterClass.Namespace, input.ClusterClassNamespace) + cloneTemplateAndUpdateRef(ctx, mgmtClient, &newClusterClass.Spec.ControlPlane.InfrastructureMachine.TemplateRef, input.ClusterClass.Namespace, input.ClusterClassNamespace) cloneTemplateAndUpdateRef(ctx, mgmtClient, &newClusterClass.Spec.ControlPlane.TemplateRef, input.ClusterClass.Namespace, input.ClusterClassNamespace) cloneTemplateAndUpdateRef(ctx, mgmtClient, &newClusterClass.Spec.Infrastructure.TemplateRef, input.ClusterClass.Namespace, input.ClusterClassNamespace) diff --git a/test/e2e/clusterclass_rollout.go b/test/e2e/clusterclass_rollout.go index 455c26d80086..fb921800165e 100644 --- a/test/e2e/clusterclass_rollout.go +++ b/test/e2e/clusterclass_rollout.go @@ -432,8 +432,8 @@ func assertControlPlane(g Gomega, clusterClassObjects clusterClassObjects, clust expectMapsToBeEquivalent(g, clusterObjects.ControlPlaneInfrastructureMachineTemplate.GetAnnotations(), union( map[string]string{ - clusterv1.TemplateClonedFromGroupKindAnnotation: clusterClass.Spec.ControlPlane.MachineInfrastructure.TemplateRef.GroupVersionKind().GroupKind().String(), - clusterv1.TemplateClonedFromNameAnnotation: clusterClass.Spec.ControlPlane.MachineInfrastructure.TemplateRef.Name, + clusterv1.TemplateClonedFromGroupKindAnnotation: clusterClass.Spec.ControlPlane.InfrastructureMachine.TemplateRef.GroupVersionKind().GroupKind().String(), + clusterv1.TemplateClonedFromNameAnnotation: clusterClass.Spec.ControlPlane.InfrastructureMachine.TemplateRef.Name, }, clusterClassObjects.ControlPlaneInfrastructureMachineTemplate.GetAnnotations(), ), @@ -1064,7 +1064,7 @@ func getClusterClassObjects(ctx context.Context, g Gomega, clusterProxy framewor res.ControlPlaneTemplate, err = external.Get(ctx, mgmtClient, clusterClass.Spec.ControlPlane.TemplateRef.ToObjectReference(clusterClass.Namespace)) g.Expect(err).ToNot(HaveOccurred()) - res.ControlPlaneInfrastructureMachineTemplate, err = external.Get(ctx, mgmtClient, clusterClass.Spec.ControlPlane.MachineInfrastructure.TemplateRef.ToObjectReference(clusterClass.Namespace)) + res.ControlPlaneInfrastructureMachineTemplate, err = external.Get(ctx, mgmtClient, clusterClass.Spec.ControlPlane.InfrastructureMachine.TemplateRef.ToObjectReference(clusterClass.Namespace)) g.Expect(err).ToNot(HaveOccurred()) for _, mdClass := range clusterClass.Spec.Workers.MachineDeployments { diff --git a/test/e2e/data/infrastructure-docker/main/clusterclass-in-memory.yaml b/test/e2e/data/infrastructure-docker/main/clusterclass-in-memory.yaml index 180664874e13..e1b7a408b35d 100644 --- a/test/e2e/data/infrastructure-docker/main/clusterclass-in-memory.yaml +++ b/test/e2e/data/infrastructure-docker/main/clusterclass-in-memory.yaml @@ -78,7 +78,7 @@ metadata: name: in-memory spec: controlPlane: - machineInfrastructure: + infrastructureMachine: templateRef: apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 kind: DevMachineTemplate diff --git a/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start-runtimesdk.yaml b/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start-runtimesdk.yaml index 2c77cc7d4f5a..4ce48757593d 100644 --- a/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start-runtimesdk.yaml +++ b/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start-runtimesdk.yaml @@ -8,7 +8,7 @@ spec: apiVersion: controlplane.cluster.x-k8s.io/v1beta2 kind: KubeadmControlPlaneTemplate name: quick-start-control-plane - machineInfrastructure: + infrastructureMachine: templateRef: apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 kind: DockerMachineTemplate diff --git a/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start.yaml b/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start.yaml index 3eeae8d983d6..a9dae504bfae 100644 --- a/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start.yaml +++ b/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start.yaml @@ -13,7 +13,7 @@ spec: apiVersion: controlplane.cluster.x-k8s.io/v1beta2 kind: KubeadmControlPlaneTemplate name: quick-start-control-plane - machineInfrastructure: + infrastructureMachine: templateRef: apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 kind: DockerMachineTemplate diff --git a/test/extension/handlers/topologymutation/handler_integration_test.go b/test/extension/handlers/topologymutation/handler_integration_test.go index 47f886030781..87510b1770a4 100644 --- a/test/extension/handlers/topologymutation/handler_integration_test.go +++ b/test/extension/handlers/topologymutation/handler_integration_test.go @@ -279,7 +279,7 @@ func getScope(cluster *clusterv1.Cluster, clusterClassFile string) (*scope.Scope // ControlPlane s.Blueprint.ControlPlane.Template = mustFind(findObject[*unstructured.Unstructured](parsedObjects, s.Blueprint.ClusterClass.Spec.ControlPlane.TemplateRef)) if s.Blueprint.HasControlPlaneInfrastructureMachine() { - s.Blueprint.ControlPlane.InfrastructureMachineTemplate = mustFind(findObject[*unstructured.Unstructured](parsedObjects, s.Blueprint.ClusterClass.Spec.ControlPlane.MachineInfrastructure.TemplateRef)) + s.Blueprint.ControlPlane.InfrastructureMachineTemplate = mustFind(findObject[*unstructured.Unstructured](parsedObjects, s.Blueprint.ClusterClass.Spec.ControlPlane.InfrastructureMachine.TemplateRef)) } if s.Blueprint.HasControlPlaneMachineHealthCheck() { s.Blueprint.ControlPlane.MachineHealthCheck = s.Blueprint.ClusterClass.Spec.ControlPlane.MachineHealthCheck diff --git a/test/extension/handlers/topologymutation/testdata/clusterclass-quick-start-runtimesdk.yaml b/test/extension/handlers/topologymutation/testdata/clusterclass-quick-start-runtimesdk.yaml index 04c84731a163..d43c49dc558d 100644 --- a/test/extension/handlers/topologymutation/testdata/clusterclass-quick-start-runtimesdk.yaml +++ b/test/extension/handlers/topologymutation/testdata/clusterclass-quick-start-runtimesdk.yaml @@ -8,7 +8,7 @@ spec: apiVersion: controlplane.cluster.x-k8s.io/v1beta2 kind: KubeadmControlPlaneTemplate name: quick-start-control-plane - machineInfrastructure: + infrastructureMachine: templateRef: kind: DockerMachineTemplate apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 diff --git a/test/infrastructure/docker/templates/clusterclass-in-memory.yaml b/test/infrastructure/docker/templates/clusterclass-in-memory.yaml index d0bb3f35e0be..e89d9ae35c8d 100644 --- a/test/infrastructure/docker/templates/clusterclass-in-memory.yaml +++ b/test/infrastructure/docker/templates/clusterclass-in-memory.yaml @@ -108,7 +108,7 @@ metadata: name: in-memory spec: controlPlane: - machineInfrastructure: + infrastructureMachine: templateRef: apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 kind: DevMachineTemplate diff --git a/test/infrastructure/docker/templates/clusterclass-quick-start.yaml b/test/infrastructure/docker/templates/clusterclass-quick-start.yaml index 3a287efdeb37..bd59665674d4 100644 --- a/test/infrastructure/docker/templates/clusterclass-quick-start.yaml +++ b/test/infrastructure/docker/templates/clusterclass-quick-start.yaml @@ -8,7 +8,7 @@ spec: apiVersion: controlplane.cluster.x-k8s.io/v1beta2 kind: KubeadmControlPlaneTemplate name: quick-start-control-plane - machineInfrastructure: + infrastructureMachine: templateRef: kind: DockerMachineTemplate apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 diff --git a/util/test/builder/builders.go b/util/test/builder/builders.go index e8d20bff8eb2..4ea251a1a4e7 100644 --- a/util/test/builder/builders.go +++ b/util/test/builder/builders.go @@ -525,7 +525,7 @@ func (c *ClusterClassBuilder) Build() *clusterv1.ClusterClass { obj.Spec.ControlPlane.Deletion.NodeDeletionTimeoutSeconds = c.controlPlaneNodeDeletionTimeout } if c.controlPlaneInfrastructureMachineTemplate != nil { - obj.Spec.ControlPlane.MachineInfrastructure = &clusterv1.ControlPlaneClassMachineInfrastructureTemplate{ + obj.Spec.ControlPlane.InfrastructureMachine = &clusterv1.ControlPlaneClassInfrastructureMachineTemplate{ TemplateRef: objToClusterClassTemplateRef(c.controlPlaneInfrastructureMachineTemplate), } }