diff --git a/api/addons/v1beta2/clusterresourceset_types.go b/api/addons/v1beta2/clusterresourceset_types.go index 66c0f6aa2ce5..afcd009827f3 100644 --- a/api/addons/v1beta2/clusterresourceset_types.go +++ b/api/addons/v1beta2/clusterresourceset_types.go @@ -204,8 +204,8 @@ type ClusterResourceSet struct { metav1.ObjectMeta `json:"metadata,omitempty"` // spec is the desired state of ClusterResourceSet. - // +optional - Spec ClusterResourceSetSpec `json:"spec,omitempty"` + // +required + Spec ClusterResourceSetSpec `json:"spec,omitempty,omitzero"` // status is the observed state of ClusterResourceSet. // +optional Status ClusterResourceSetStatus `json:"status,omitempty,omitzero"` diff --git a/api/addons/v1beta2/clusterresourcesetbinding_types.go b/api/addons/v1beta2/clusterresourcesetbinding_types.go index 4212b49220ef..43031e40c88b 100644 --- a/api/addons/v1beta2/clusterresourcesetbinding_types.go +++ b/api/addons/v1beta2/clusterresourcesetbinding_types.go @@ -127,8 +127,8 @@ type ClusterResourceSetBinding struct { // +optional metav1.ObjectMeta `json:"metadata,omitempty"` // spec is the desired state of ClusterResourceSetBinding. - // +optional - Spec ClusterResourceSetBindingSpec `json:"spec,omitempty"` + // +required + Spec ClusterResourceSetBindingSpec `json:"spec,omitempty,omitzero"` } // ANCHOR: ClusterResourceSetBindingSpec diff --git a/api/bootstrap/kubeadm/v1beta2/kubeadmconfig_types.go b/api/bootstrap/kubeadm/v1beta2/kubeadmconfig_types.go index cbfadde0bff9..a61053d07034 100644 --- a/api/bootstrap/kubeadm/v1beta2/kubeadmconfig_types.go +++ b/api/bootstrap/kubeadm/v1beta2/kubeadmconfig_types.go @@ -50,6 +50,7 @@ var ( // KubeadmConfigSpec defines the desired state of KubeadmConfig. // Either ClusterConfiguration and InitConfiguration should be defined or the JoinConfiguration should be defined. +// +kubebuilder:validation:MinProperties=1 type KubeadmConfigSpec struct { // clusterConfiguration along with InitConfiguration are the configurations necessary for the init command // +optional @@ -543,7 +544,7 @@ type KubeadmConfig struct { // spec is the desired state of KubeadmConfig. // +optional - Spec KubeadmConfigSpec `json:"spec,omitempty"` + Spec KubeadmConfigSpec `json:"spec,omitempty,omitzero"` // status is the observed state of KubeadmConfig. // +optional Status KubeadmConfigStatus `json:"status,omitempty,omitzero"` diff --git a/api/bootstrap/kubeadm/v1beta2/kubeadmconfigtemplate_types.go b/api/bootstrap/kubeadm/v1beta2/kubeadmconfigtemplate_types.go index 4b1a17489115..d29848acb81a 100644 --- a/api/bootstrap/kubeadm/v1beta2/kubeadmconfigtemplate_types.go +++ b/api/bootstrap/kubeadm/v1beta2/kubeadmconfigtemplate_types.go @@ -30,6 +30,7 @@ type KubeadmConfigTemplateSpec struct { } // KubeadmConfigTemplateResource defines the Template structure. +// +kubebuilder:validation:MinProperties=1 type KubeadmConfigTemplateResource struct { // metadata is the standard object's metadata. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata @@ -38,7 +39,7 @@ type KubeadmConfigTemplateResource struct { // spec is the desired state of KubeadmConfig. // +optional - Spec KubeadmConfigSpec `json:"spec,omitempty"` + Spec KubeadmConfigSpec `json:"spec,omitempty,omitzero"` } // +kubebuilder:object:root=true @@ -56,7 +57,7 @@ type KubeadmConfigTemplate struct { // spec is the desired state of KubeadmConfigTemplate. // +optional - Spec KubeadmConfigTemplateSpec `json:"spec,omitempty"` + Spec KubeadmConfigTemplateSpec `json:"spec,omitempty,omitzero"` } // +kubebuilder:object:root=true diff --git a/api/controlplane/kubeadm/v1beta2/kubeadm_control_plane_types.go b/api/controlplane/kubeadm/v1beta2/kubeadm_control_plane_types.go index 8fafc673624a..763b8e82b4a2 100644 --- a/api/controlplane/kubeadm/v1beta2/kubeadm_control_plane_types.go +++ b/api/controlplane/kubeadm/v1beta2/kubeadm_control_plane_types.go @@ -441,8 +441,8 @@ type KubeadmControlPlaneSpec struct { // kubeadmConfigSpec is a KubeadmConfigSpec // to use for initializing and joining machines to the control plane. - // +required - KubeadmConfigSpec bootstrapv1.KubeadmConfigSpec `json:"kubeadmConfigSpec"` + // +optional + KubeadmConfigSpec bootstrapv1.KubeadmConfigSpec `json:"kubeadmConfigSpec,omitempty,omitzero"` // rolloutBefore is a field to indicate a rollout should be performed // if the specified criteria is met. @@ -807,8 +807,8 @@ type KubeadmControlPlane struct { metav1.ObjectMeta `json:"metadata,omitempty"` // spec is the desired state of KubeadmControlPlane. - // +optional - Spec KubeadmControlPlaneSpec `json:"spec,omitempty"` + // +required + Spec KubeadmControlPlaneSpec `json:"spec,omitempty,omitzero"` // status is the observed state of KubeadmControlPlane. // +optional Status KubeadmControlPlaneStatus `json:"status,omitempty,omitzero"` diff --git a/api/controlplane/kubeadm/v1beta2/kubeadmcontrolplanetemplate_types.go b/api/controlplane/kubeadm/v1beta2/kubeadmcontrolplanetemplate_types.go index 11fa73850f88..b75667e38b07 100644 --- a/api/controlplane/kubeadm/v1beta2/kubeadmcontrolplanetemplate_types.go +++ b/api/controlplane/kubeadm/v1beta2/kubeadmcontrolplanetemplate_types.go @@ -46,7 +46,7 @@ type KubeadmControlPlaneTemplate struct { // spec is the desired state of KubeadmControlPlaneTemplate. // +optional - Spec KubeadmControlPlaneTemplateSpec `json:"spec,omitempty"` + Spec KubeadmControlPlaneTemplateSpec `json:"spec,omitempty,omitzero"` } // +kubebuilder:object:root=true @@ -67,6 +67,7 @@ func init() { } // KubeadmControlPlaneTemplateResource describes the data needed to create a KubeadmControlPlane from a template. +// +kubebuilder:validation:MinProperties=1 type KubeadmControlPlaneTemplateResource struct { // metadata is the standard object's metadata. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata @@ -74,8 +75,8 @@ type KubeadmControlPlaneTemplateResource struct { ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"` // spec is the desired state of KubeadmControlPlaneTemplateResource. - // +required - Spec KubeadmControlPlaneTemplateResourceSpec `json:"spec"` + // +optional + Spec KubeadmControlPlaneTemplateResourceSpec `json:"spec,omitempty,omitzero"` } // KubeadmControlPlaneTemplateResourceSpec defines the desired state of KubeadmControlPlane. @@ -91,8 +92,8 @@ type KubeadmControlPlaneTemplateResourceSpec struct { // kubeadmConfigSpec is a KubeadmConfigSpec // to use for initializing and joining machines to the control plane. - // +required - KubeadmConfigSpec bootstrapv1.KubeadmConfigSpec `json:"kubeadmConfigSpec"` + // +optional + KubeadmConfigSpec bootstrapv1.KubeadmConfigSpec `json:"kubeadmConfigSpec,omitempty,omitzero"` // rolloutBefore is a field to indicate a rollout should be performed // if the specified criteria is met. diff --git a/api/core/v1beta2/cluster_types.go b/api/core/v1beta2/cluster_types.go index abf9af0d858e..f1eac38559a0 100644 --- a/api/core/v1beta2/cluster_types.go +++ b/api/core/v1beta2/cluster_types.go @@ -458,6 +458,7 @@ const ( // ANCHOR: ClusterSpec // ClusterSpec defines the desired state of Cluster. +// +kubebuilder:validation:MinProperties=1 type ClusterSpec struct { // paused can be used to prevent controllers from processing the Cluster and all its associated objects. // +optional @@ -1185,8 +1186,8 @@ type Cluster struct { metav1.ObjectMeta `json:"metadata,omitempty"` // spec is the desired state of Cluster. - // +optional - Spec ClusterSpec `json:"spec,omitempty"` + // +required + Spec ClusterSpec `json:"spec,omitempty,omitzero"` // status is the observed state of Cluster. // +optional Status ClusterStatus `json:"status,omitempty,omitzero"` diff --git a/api/core/v1beta2/clusterclass_types.go b/api/core/v1beta2/clusterclass_types.go index a69033da88fe..33b0942730f0 100644 --- a/api/core/v1beta2/clusterclass_types.go +++ b/api/core/v1beta2/clusterclass_types.go @@ -81,14 +81,15 @@ type ClusterClass struct { metav1.ObjectMeta `json:"metadata,omitempty"` // spec is the desired state of ClusterClass. - // +optional - Spec ClusterClassSpec `json:"spec,omitempty"` + // +required + Spec ClusterClassSpec `json:"spec,omitempty,omitzero"` // status is the observed state of ClusterClass. // +optional Status ClusterClassStatus `json:"status,omitempty,omitzero"` } // ClusterClassSpec describes the desired state of the ClusterClass. +// +kubebuilder:validation:MinProperties=1 type ClusterClassSpec struct { // availabilityGates specifies additional conditions to include when evaluating Cluster Available condition. // diff --git a/api/core/v1beta2/machine_types.go b/api/core/v1beta2/machine_types.go index 9085935cb7fe..92960ab4c1dd 100644 --- a/api/core/v1beta2/machine_types.go +++ b/api/core/v1beta2/machine_types.go @@ -736,8 +736,8 @@ type Machine struct { metav1.ObjectMeta `json:"metadata,omitempty"` // spec is the desired state of Machine. - // +optional - Spec MachineSpec `json:"spec,omitempty"` + // +required + Spec MachineSpec `json:"spec,omitempty,omitzero"` // status is the observed state of Machine. // +optional Status MachineStatus `json:"status,omitempty,omitzero"` diff --git a/api/core/v1beta2/machinedeployment_types.go b/api/core/v1beta2/machinedeployment_types.go index 7aec0f55ab91..69968440475d 100644 --- a/api/core/v1beta2/machinedeployment_types.go +++ b/api/core/v1beta2/machinedeployment_types.go @@ -593,8 +593,8 @@ type MachineDeployment struct { metav1.ObjectMeta `json:"metadata,omitempty"` // spec is the desired state of MachineDeployment. - // +optional - Spec MachineDeploymentSpec `json:"spec,omitempty"` + // +required + Spec MachineDeploymentSpec `json:"spec,omitempty,omitzero"` // status is the observed state of MachineDeployment. // +optional Status MachineDeploymentStatus `json:"status,omitempty,omitzero"` diff --git a/api/core/v1beta2/machinehealthcheck_types.go b/api/core/v1beta2/machinehealthcheck_types.go index 4df19cc0be3a..c45841dc8e23 100644 --- a/api/core/v1beta2/machinehealthcheck_types.go +++ b/api/core/v1beta2/machinehealthcheck_types.go @@ -281,8 +281,8 @@ type MachineHealthCheck struct { metav1.ObjectMeta `json:"metadata,omitempty"` // spec is the specification of machine health check policy - // +optional - Spec MachineHealthCheckSpec `json:"spec,omitempty"` + // +required + Spec MachineHealthCheckSpec `json:"spec,omitempty,omitzero"` // status is the most recently observed status of MachineHealthCheck resource // +optional diff --git a/api/core/v1beta2/machinepool_types.go b/api/core/v1beta2/machinepool_types.go index ef308cd3e6e1..0292d8f6faa3 100644 --- a/api/core/v1beta2/machinepool_types.go +++ b/api/core/v1beta2/machinepool_types.go @@ -344,8 +344,8 @@ type MachinePool struct { metav1.ObjectMeta `json:"metadata,omitempty"` // spec is the desired state of MachinePool. - // +optional - Spec MachinePoolSpec `json:"spec,omitempty"` + // +required + Spec MachinePoolSpec `json:"spec,omitempty,omitzero"` // status is the observed state of MachinePool. // +optional Status MachinePoolStatus `json:"status,omitempty,omitzero"` diff --git a/api/core/v1beta2/machineset_types.go b/api/core/v1beta2/machineset_types.go index 812420661c78..0fe0395ad16d 100644 --- a/api/core/v1beta2/machineset_types.go +++ b/api/core/v1beta2/machineset_types.go @@ -447,8 +447,8 @@ type MachineSet struct { metav1.ObjectMeta `json:"metadata,omitempty"` // spec is the desired state of MachineSet. - // +optional - Spec MachineSetSpec `json:"spec,omitempty"` + // +required + Spec MachineSetSpec `json:"spec,omitempty,omitzero"` // status is the observed state of MachineSet. // +optional Status MachineSetStatus `json:"status,omitempty,omitzero"` diff --git a/api/core/v1beta2/zz_generated.openapi.go b/api/core/v1beta2/zz_generated.openapi.go index 74e6544688cd..d9c6c8a35d88 100644 --- a/api/core/v1beta2/zz_generated.openapi.go +++ b/api/core/v1beta2/zz_generated.openapi.go @@ -247,6 +247,7 @@ func schema_cluster_api_api_core_v1beta2_Cluster(ref common.ReferenceCallback) c }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -326,6 +327,7 @@ func schema_cluster_api_api_core_v1beta2_ClusterClass(ref common.ReferenceCallba }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -2208,6 +2210,7 @@ func schema_cluster_api_api_core_v1beta2_Machine(ref common.ReferenceCallback) c }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -2315,6 +2318,7 @@ func schema_cluster_api_api_core_v1beta2_MachineDeployment(ref common.ReferenceC }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -3275,6 +3279,7 @@ func schema_cluster_api_api_core_v1beta2_MachineHealthCheck(ref common.Reference }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -3858,6 +3863,7 @@ func schema_cluster_api_api_core_v1beta2_MachinePool(ref common.ReferenceCallbac }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ @@ -4576,6 +4582,7 @@ func schema_cluster_api_api_core_v1beta2_MachineSet(ref common.ReferenceCallback }, }, }, + Required: []string{"spec"}, }, }, Dependencies: []string{ diff --git a/api/ipam/v1beta2/ipaddress_types.go b/api/ipam/v1beta2/ipaddress_types.go index b03896e02db4..881b255e0244 100644 --- a/api/ipam/v1beta2/ipaddress_types.go +++ b/api/ipam/v1beta2/ipaddress_types.go @@ -102,8 +102,8 @@ type IPAddress struct { metav1.ObjectMeta `json:"metadata,omitempty"` // spec is the desired state of IPAddress. - // +optional - Spec IPAddressSpec `json:"spec,omitempty"` + // +required + Spec IPAddressSpec `json:"spec,omitempty,omitzero"` } // +kubebuilder:object:root=true diff --git a/api/ipam/v1beta2/ipaddressclaim_types.go b/api/ipam/v1beta2/ipaddressclaim_types.go index d16c903cf60c..2e0097f679fc 100644 --- a/api/ipam/v1beta2/ipaddressclaim_types.go +++ b/api/ipam/v1beta2/ipaddressclaim_types.go @@ -120,8 +120,8 @@ type IPAddressClaim struct { metav1.ObjectMeta `json:"metadata,omitempty"` // spec is the desired state of IPAddressClaim. - // +optional - Spec IPAddressClaimSpec `json:"spec,omitempty"` + // +required + Spec IPAddressClaimSpec `json:"spec,omitempty,omitzero"` // status is the observed state of IPAddressClaim. // +optional Status IPAddressClaimStatus `json:"status,omitempty,omitzero"` diff --git a/api/runtime/v1beta2/extensionconfig_types.go b/api/runtime/v1beta2/extensionconfig_types.go index 23e987ead221..902413ba4ab9 100644 --- a/api/runtime/v1beta2/extensionconfig_types.go +++ b/api/runtime/v1beta2/extensionconfig_types.go @@ -45,6 +45,7 @@ type ExtensionConfigSpec struct { // ClientConfig contains the information to make a client // connection with an Extension server. +// +kubebuilder:validation:MinProperties=1 type ClientConfig struct { // url gives the location of the Extension server, in standard URL form // (`scheme://host:port/path`). @@ -230,8 +231,8 @@ type ExtensionConfig struct { metav1.ObjectMeta `json:"metadata,omitempty"` // spec is the desired state of the ExtensionConfig. - // +optional - Spec ExtensionConfigSpec `json:"spec,omitempty"` + // +required + Spec ExtensionConfigSpec `json:"spec,omitempty,omitzero"` // status is the current state of the ExtensionConfig // +optional diff --git a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml index 9fab9292797b..0a96195321b6 100644 --- a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml +++ b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml @@ -4117,6 +4117,7 @@ spec: type: object spec: description: spec is the desired state of KubeadmConfig. + minProperties: 1 properties: bootCommands: description: |- diff --git a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml index fbaf4a5da989..22535b1c6cc5 100644 --- a/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml +++ b/bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml @@ -3958,6 +3958,7 @@ spec: properties: template: description: template defines the desired state of KubeadmConfigTemplate. + minProperties: 1 properties: metadata: description: |- @@ -3985,6 +3986,7 @@ spec: type: object spec: description: spec is the desired state of KubeadmConfig. + minProperties: 1 properties: bootCommands: description: |- diff --git a/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller_reconciler_test.go b/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller_reconciler_test.go index bed494228029..73bd3b59762d 100644 --- a/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller_reconciler_test.go +++ b/bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller_reconciler_test.go @@ -24,6 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" bootstrapv1 "sigs.k8s.io/cluster-api/api/bootstrap/kubeadm/v1beta2" + clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" "sigs.k8s.io/cluster-api/util/test/builder" ) @@ -35,7 +36,11 @@ func TestKubeadmConfigReconciler(t *testing.T) { ns, err := env.CreateNamespace(ctx, "test-kubeadm-config-reconciler") g.Expect(err).ToNot(HaveOccurred()) - cluster := builder.Cluster(ns.Name, "cluster1").Build() + cluster := builder.Cluster(ns.Name, "cluster1"). + WithClusterNetwork(&clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }). + Build() g.Expect(env.Create(ctx, cluster)).To(Succeed()) machine := newWorkerMachineForCluster(cluster) g.Expect(env.Create(ctx, machine)).To(Succeed()) diff --git a/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesetbindings.yaml b/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesetbindings.yaml index 40447fb72d70..2e3e52c59b55 100644 --- a/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesetbindings.yaml +++ b/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesetbindings.yaml @@ -406,6 +406,8 @@ spec: required: - clusterName type: object + required: + - spec type: object served: true storage: true diff --git a/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml b/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml index e6a10411e29a..c2106cc4b795 100644 --- a/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml +++ b/config/crd/bases/addons.cluster.x-k8s.io_clusterresourcesets.yaml @@ -868,6 +868,8 @@ spec: minimum: 1 type: integer type: object + required: + - spec type: object served: true storage: true diff --git a/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml b/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml index 5cb8736730aa..0eb8e6981e73 100644 --- a/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml +++ b/config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml @@ -2847,6 +2847,7 @@ spec: type: object spec: description: spec is the desired state of ClusterClass. + minProperties: 1 properties: availabilityGates: description: |- @@ -5153,6 +5154,8 @@ spec: maxItems: 1000 type: array type: object + required: + - spec type: object served: true storage: true diff --git a/config/crd/bases/cluster.x-k8s.io_clusters.yaml b/config/crd/bases/cluster.x-k8s.io_clusters.yaml index a61317e39821..b814f9d7a4f0 100644 --- a/config/crd/bases/cluster.x-k8s.io_clusters.yaml +++ b/config/crd/bases/cluster.x-k8s.io_clusters.yaml @@ -2188,6 +2188,7 @@ spec: type: object spec: description: spec is the desired state of Cluster. + minProperties: 1 properties: availabilityGates: description: |- @@ -3564,6 +3565,8 @@ spec: type: integer type: object type: object + required: + - spec type: object served: true storage: true diff --git a/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml b/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml index 9696bc6dd3cb..7e10f55733a0 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinedeployments.yaml @@ -2545,6 +2545,8 @@ spec: format: int32 type: integer type: object + required: + - spec type: object served: true storage: true diff --git a/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml b/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml index 6f33806d1b82..908e4ac06897 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinehealthchecks.yaml @@ -1377,6 +1377,8 @@ spec: maxItems: 10000 type: array type: object + required: + - spec type: object served: true storage: true diff --git a/config/crd/bases/cluster.x-k8s.io_machinepools.yaml b/config/crd/bases/cluster.x-k8s.io_machinepools.yaml index 8981b619d8df..df0b55d8f939 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinepools.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinepools.yaml @@ -2222,6 +2222,8 @@ spec: format: int32 type: integer type: object + required: + - spec type: object served: true storage: true diff --git a/config/crd/bases/cluster.x-k8s.io_machines.yaml b/config/crd/bases/cluster.x-k8s.io_machines.yaml index 9a9d2a99554d..cd3f80f73958 100644 --- a/config/crd/bases/cluster.x-k8s.io_machines.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machines.yaml @@ -2086,6 +2086,8 @@ spec: - Unknown type: string type: object + required: + - spec type: object served: true storage: true diff --git a/config/crd/bases/cluster.x-k8s.io_machinesets.yaml b/config/crd/bases/cluster.x-k8s.io_machinesets.yaml index e42822d98e22..a8aecbc63c54 100644 --- a/config/crd/bases/cluster.x-k8s.io_machinesets.yaml +++ b/config/crd/bases/cluster.x-k8s.io_machinesets.yaml @@ -2221,6 +2221,8 @@ spec: format: int32 type: integer type: object + required: + - spec type: object served: true storage: true diff --git a/config/crd/bases/ipam.cluster.x-k8s.io_ipaddressclaims.yaml b/config/crd/bases/ipam.cluster.x-k8s.io_ipaddressclaims.yaml index 1c7c8d4143d4..ed03b07b3c72 100644 --- a/config/crd/bases/ipam.cluster.x-k8s.io_ipaddressclaims.yaml +++ b/config/crd/bases/ipam.cluster.x-k8s.io_ipaddressclaims.yaml @@ -596,6 +596,8 @@ spec: type: object type: object type: object + required: + - spec type: object served: true storage: true diff --git a/config/crd/bases/ipam.cluster.x-k8s.io_ipaddresses.yaml b/config/crd/bases/ipam.cluster.x-k8s.io_ipaddresses.yaml index ed14120e93e4..9a0edef6e1ba 100644 --- a/config/crd/bases/ipam.cluster.x-k8s.io_ipaddresses.yaml +++ b/config/crd/bases/ipam.cluster.x-k8s.io_ipaddresses.yaml @@ -332,6 +332,8 @@ spec: - poolRef - prefix type: object + required: + - spec type: object served: true storage: true diff --git a/config/crd/bases/runtime.cluster.x-k8s.io_extensionconfigs.yaml b/config/crd/bases/runtime.cluster.x-k8s.io_extensionconfigs.yaml index 0090b0526efe..5119c76dbe2d 100644 --- a/config/crd/bases/runtime.cluster.x-k8s.io_extensionconfigs.yaml +++ b/config/crd/bases/runtime.cluster.x-k8s.io_extensionconfigs.yaml @@ -395,6 +395,7 @@ spec: clientConfig: description: clientConfig defines how to communicate with the Extension server. + minProperties: 1 properties: caBundle: description: caBundle is a PEM encoded CA bundle which will be @@ -709,6 +710,8 @@ spec: - name x-kubernetes-list-type: map type: object + required: + - spec type: object served: true storage: true diff --git a/controllers/clustercache/cluster_accessor_test.go b/controllers/clustercache/cluster_accessor_test.go index dd9eaf64fcdb..228b55b46924 100644 --- a/controllers/clustercache/cluster_accessor_test.go +++ b/controllers/clustercache/cluster_accessor_test.go @@ -51,6 +51,11 @@ func TestConnect(t *testing.T) { Name: "test-cluster", Namespace: metav1.NamespaceDefault, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } clusterKey := client.ObjectKeyFromObject(testCluster) g.Expect(env.CreateAndWait(ctx, testCluster)).To(Succeed()) @@ -147,6 +152,11 @@ func TestDisconnect(t *testing.T) { Name: "test-cluster", Namespace: metav1.NamespaceDefault, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } clusterKey := client.ObjectKeyFromObject(testCluster) g.Expect(env.CreateAndWait(ctx, testCluster)).To(Succeed()) @@ -196,6 +206,11 @@ func TestHealthCheck(t *testing.T) { Name: "test-cluster", Namespace: metav1.NamespaceDefault, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } clusterKey := client.ObjectKeyFromObject(testCluster) @@ -307,6 +322,11 @@ func TestWatch(t *testing.T) { Name: "test-cluster", Namespace: metav1.NamespaceDefault, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } clusterKey := client.ObjectKeyFromObject(testCluster) g.Expect(env.CreateAndWait(ctx, testCluster)).To(Succeed()) diff --git a/controllers/clustercache/cluster_cache_test.go b/controllers/clustercache/cluster_cache_test.go index 672a7b47d05d..161c79d11966 100644 --- a/controllers/clustercache/cluster_cache_test.go +++ b/controllers/clustercache/cluster_cache_test.go @@ -57,6 +57,11 @@ func TestReconcile(t *testing.T) { Name: "test-cluster", Namespace: metav1.NamespaceDefault, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } clusterKey := client.ObjectKeyFromObject(testCluster) g.Expect(env.CreateAndWait(ctx, testCluster)).To(Succeed()) @@ -732,6 +737,11 @@ func createCluster(g Gomega, testCluster testCluster) { Name: testCluster.cluster.Name, Namespace: testCluster.cluster.Namespace, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } g.Expect(env.CreateAndWait(ctx, cluster)).To(Succeed()) diff --git a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml index a2d164f0e52b..72c58c493eb4 100644 --- a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml +++ b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml @@ -5039,6 +5039,7 @@ spec: description: |- kubeadmConfigSpec is a KubeadmConfigSpec to use for initializing and joining machines to the control plane. + minProperties: 1 properties: bootCommands: description: |- @@ -7389,7 +7390,6 @@ spec: minLength: 1 type: string required: - - kubeadmConfigSpec - machineTemplate - version type: object @@ -7656,6 +7656,8 @@ spec: minLength: 1 type: string type: object + required: + - spec type: object served: true storage: true diff --git a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml index 3bd39457caa9..76a3bdbc2c4c 100644 --- a/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml +++ b/controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanetemplates.yaml @@ -3367,6 +3367,7 @@ spec: properties: template: description: template defines the desired state of KubeadmControlPlaneTemplate. + minProperties: 1 properties: metadata: description: |- @@ -3399,6 +3400,7 @@ spec: description: |- kubeadmConfigSpec is a KubeadmConfigSpec to use for initializing and joining machines to the control plane. + minProperties: 1 properties: bootCommands: description: |- @@ -5703,11 +5705,7 @@ spec: - RollingUpdate type: string type: object - required: - - kubeadmConfigSpec type: object - required: - - spec type: object required: - template diff --git a/controlplane/kubeadm/internal/cluster_test.go b/controlplane/kubeadm/internal/cluster_test.go index d89740e46278..73d23bdf1719 100644 --- a/controlplane/kubeadm/internal/cluster_test.go +++ b/controlplane/kubeadm/internal/cluster_test.go @@ -118,6 +118,11 @@ func TestGetWorkloadCluster(t *testing.T) { Name: "my-cluster", Namespace: ns.Name, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } g.Expect(env.CreateAndWait(ctx, cluster)).To(Succeed()) defer func(do client.Object) { diff --git a/controlplane/kubeadm/internal/control_plane.go b/controlplane/kubeadm/internal/control_plane.go index 21be4df59662..ec4854d6c612 100644 --- a/controlplane/kubeadm/internal/control_plane.go +++ b/controlplane/kubeadm/internal/control_plane.go @@ -223,6 +223,9 @@ func getGetFailureDomainIDs(failureDomains []clusterv1.FailureDomain) []string { // InitialControlPlaneConfig returns a new KubeadmConfigSpec that is to be used for an initializing control plane. func (c *ControlPlane) InitialControlPlaneConfig() *bootstrapv1.KubeadmConfigSpec { bootstrapSpec := c.KCP.Spec.KubeadmConfigSpec.DeepCopy() + if bootstrapSpec.InitConfiguration == nil { + bootstrapSpec.InitConfiguration = &bootstrapv1.InitConfiguration{} + } bootstrapSpec.JoinConfiguration = nil return bootstrapSpec } diff --git a/controlplane/kubeadm/internal/controllers/controller_test.go b/controlplane/kubeadm/internal/controllers/controller_test.go index b6873adf7fd0..4041b6b4070d 100644 --- a/controlplane/kubeadm/internal/controllers/controller_test.go +++ b/controlplane/kubeadm/internal/controllers/controller_test.go @@ -1643,7 +1643,17 @@ func TestKubeadmControlPlaneReconciler_syncMachines(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) t.Log("Creating the Cluster") - cluster := &clusterv1.Cluster{ObjectMeta: metav1.ObjectMeta{Namespace: ns.Name, Name: "test-cluster"}} + cluster := &clusterv1.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + Name: "test-cluster", + }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, + } g.Expect(env.Create(ctx, cluster)).To(Succeed()) t.Log("Creating the Cluster Kubeconfig Secret") diff --git a/exp/internal/controllers/machinepool_controller_phases_test.go b/exp/internal/controllers/machinepool_controller_phases_test.go index a870fce3affe..a5643d570da1 100644 --- a/exp/internal/controllers/machinepool_controller_phases_test.go +++ b/exp/internal/controllers/machinepool_controller_phases_test.go @@ -1350,7 +1350,11 @@ func TestReconcileMachinePoolMachines(t *testing.T) { ns, err := env.CreateNamespace(ctx, "test-machinepool-machines") g.Expect(err).ToNot(HaveOccurred()) - cluster := builder.Cluster(ns.Name, clusterName).Build() + cluster := builder.Cluster(ns.Name, clusterName). + WithClusterNetwork(&clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }). + Build() g.Expect(env.CreateAndWait(ctx, cluster)).To(Succeed()) t.Run("Should do nothing if machines already exist", func(*testing.T) { @@ -1719,6 +1723,11 @@ func TestReconcileMachinePoolScaleToFromZero(t *testing.T) { GenerateName: "machinepool-scale-zero-", Namespace: ns.Name, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } g.Expect(env.CreateAndWait(ctx, testCluster)).To(Succeed()) g.Expect(env.CreateKubeconfigSecret(ctx, testCluster)).To(Succeed()) diff --git a/internal/controllers/cluster/cluster_controller_test.go b/internal/controllers/cluster/cluster_controller_test.go index 40508042777e..3bac3e74de01 100644 --- a/internal/controllers/cluster/cluster_controller_test.go +++ b/internal/controllers/cluster/cluster_controller_test.go @@ -64,7 +64,11 @@ func TestClusterReconciler(t *testing.T) { GenerateName: "test1-", Namespace: ns.Name, }, - Spec: clusterv1.ClusterSpec{}, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } // Create the Cluster object and expect the Reconcile and Deployment to be created @@ -115,6 +119,11 @@ func TestClusterReconciler(t *testing.T) { GenerateName: "test2-", Namespace: ns.Name, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } g.Expect(env.Create(ctx, cluster)).To(Succeed()) key := client.ObjectKey{Name: cluster.Name, Namespace: cluster.Namespace} @@ -169,6 +178,11 @@ func TestClusterReconciler(t *testing.T) { GenerateName: "test3-", Namespace: ns.Name, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } g.Expect(env.Create(ctx, cluster)).To(Succeed()) key := client.ObjectKey{Name: cluster.Name, Namespace: cluster.Namespace} @@ -216,6 +230,11 @@ func TestClusterReconciler(t *testing.T) { GenerateName: "test3-", Namespace: ns.Name, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } g.Expect(env.Create(ctx, cluster)).To(Succeed()) key := client.ObjectKey{Name: cluster.Name, Namespace: cluster.Namespace} @@ -264,6 +283,11 @@ func TestClusterReconciler(t *testing.T) { GenerateName: "test4-", Namespace: ns.Name, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } g.Expect(env.Create(ctx, cluster)).To(Succeed()) @@ -319,6 +343,11 @@ func TestClusterReconciler(t *testing.T) { GenerateName: "test5-", Namespace: ns.Name, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } g.Expect(env.Create(ctx, cluster)).To(Succeed()) key := client.ObjectKey{Name: cluster.Name, Namespace: cluster.Namespace} @@ -364,6 +393,11 @@ func TestClusterReconciler(t *testing.T) { GenerateName: "test6-", Namespace: ns.Name, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } g.Expect(env.Create(ctx, cluster)).To(Succeed()) diff --git a/internal/controllers/clusterresourceset/clusterresourceset_controller_test.go b/internal/controllers/clusterresourceset/clusterresourceset_controller_test.go index 31dc733cb566..6176a859480b 100644 --- a/internal/controllers/clusterresourceset/clusterresourceset_controller_test.go +++ b/internal/controllers/clusterresourceset/clusterresourceset_controller_test.go @@ -106,7 +106,17 @@ metadata: g.Expect(err).ToNot(HaveOccurred()) clusterName = fmt.Sprintf("cluster-%s", util.RandomString(6)) - testCluster = &clusterv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: clusterName, Namespace: ns.Name}} + testCluster = &clusterv1.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: clusterName, + Namespace: ns.Name, + }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, + } t.Log("Creating the Cluster") g.Expect(env.CreateAndWait(ctx, testCluster)).To(Succeed()) diff --git a/internal/controllers/machine/machine_controller_noderef_test.go b/internal/controllers/machine/machine_controller_noderef_test.go index a0d2b02087c8..78136823d9a0 100644 --- a/internal/controllers/machine/machine_controller_noderef_test.go +++ b/internal/controllers/machine/machine_controller_noderef_test.go @@ -238,6 +238,11 @@ func TestGetNode(t *testing.T) { GenerateName: "test-get-node-", Namespace: ns.Name, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } g.Expect(env.Create(ctx, testCluster)).To(Succeed()) @@ -381,6 +386,11 @@ func TestNodeLabelSync(t *testing.T) { Name: "test-cluster", Namespace: metav1.NamespaceDefault, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } defaultInfraMachine := &unstructured.Unstructured{ diff --git a/internal/controllers/machine/machine_controller_status_test.go b/internal/controllers/machine/machine_controller_status_test.go index bf785c2e5d95..05d3b036d90c 100644 --- a/internal/controllers/machine/machine_controller_status_test.go +++ b/internal/controllers/machine/machine_controller_status_test.go @@ -1905,6 +1905,11 @@ func TestReconcileMachinePhases(t *testing.T) { Name: "test-cluster", Namespace: metav1.NamespaceDefault, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } defaultMachine := clusterv1.Machine{ diff --git a/internal/controllers/machine/machine_controller_test.go b/internal/controllers/machine/machine_controller_test.go index c932081aa141..cc18c66899b4 100644 --- a/internal/controllers/machine/machine_controller_test.go +++ b/internal/controllers/machine/machine_controller_test.go @@ -104,6 +104,11 @@ func TestWatches(t *testing.T) { GenerateName: "machine-reconcile-", Namespace: ns.Name, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } node := &corev1.Node{ @@ -419,6 +424,11 @@ func TestMachine_Reconcile(t *testing.T) { GenerateName: "machine-reconcile-", Namespace: ns.Name, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } g.Expect(env.Create(ctx, testCluster)).To(Succeed()) @@ -3070,6 +3080,11 @@ func TestNodeToMachine(t *testing.T) { GenerateName: "machine-reconcile-", Namespace: ns.Name, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } targetNode := &corev1.Node{ diff --git a/internal/controllers/machinedeployment/machinedeployment_controller_test.go b/internal/controllers/machinedeployment/machinedeployment_controller_test.go index ef58b616cce0..ec9569090458 100644 --- a/internal/controllers/machinedeployment/machinedeployment_controller_test.go +++ b/internal/controllers/machinedeployment/machinedeployment_controller_test.go @@ -55,7 +55,17 @@ func TestMachineDeploymentReconciler(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) t.Log("Creating the Cluster") - cluster := &clusterv1.Cluster{ObjectMeta: metav1.ObjectMeta{Namespace: ns.Name, Name: "test-cluster"}} + cluster := &clusterv1.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + Name: "test-cluster", + }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, + } g.Expect(env.Create(ctx, cluster)).To(Succeed()) t.Log("Creating the Cluster Kubeconfig Secret") @@ -493,7 +503,17 @@ func TestMachineDeploymentReconciler_CleanUpManagedFieldsForSSAAdoption(t *testi g.Expect(err).ToNot(HaveOccurred()) t.Log("Creating the Cluster") - cluster := &clusterv1.Cluster{ObjectMeta: metav1.ObjectMeta{Namespace: ns.Name, Name: "test-cluster"}} + cluster := &clusterv1.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + Name: "test-cluster", + }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, + } g.Expect(env.Create(ctx, cluster)).To(Succeed()) t.Log("Creating the Cluster Kubeconfig Secret") diff --git a/internal/controllers/machinehealthcheck/machinehealthcheck_controller_test.go b/internal/controllers/machinehealthcheck/machinehealthcheck_controller_test.go index e305500ae825..df309d6e416a 100644 --- a/internal/controllers/machinehealthcheck/machinehealthcheck_controller_test.go +++ b/internal/controllers/machinehealthcheck/machinehealthcheck_controller_test.go @@ -2443,6 +2443,11 @@ func createCluster(g *WithT, namespaceName string) *clusterv1.Cluster { GenerateName: "test-cluster-", Namespace: namespaceName, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } g.Expect(env.CreateAndWait(ctx, cluster)).To(Succeed()) diff --git a/internal/controllers/machineset/machineset_controller_test.go b/internal/controllers/machineset/machineset_controller_test.go index 141ea08a8892..161a1ebf9d04 100644 --- a/internal/controllers/machineset/machineset_controller_test.go +++ b/internal/controllers/machineset/machineset_controller_test.go @@ -65,7 +65,17 @@ func TestMachineSetReconciler(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) t.Log("Creating the Cluster") - cluster := &clusterv1.Cluster{ObjectMeta: metav1.ObjectMeta{Namespace: ns.Name, Name: testClusterName}} + cluster := &clusterv1.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + Name: testClusterName, + }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, + } g.Expect(env.Create(ctx, cluster)).To(Succeed()) t.Log("Creating the Cluster Kubeconfig Secret") @@ -1079,7 +1089,17 @@ func TestMachineSetReconciler_syncMachines(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) t.Log("Creating the Cluster") - cluster := &clusterv1.Cluster{ObjectMeta: metav1.ObjectMeta{Namespace: ns.Name, Name: testClusterName}} + cluster := &clusterv1.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: ns.Name, + Name: testClusterName, + }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, + } g.Expect(env.Create(ctx, cluster)).To(Succeed()) t.Log("Creating the Cluster Kubeconfig Secret") diff --git a/internal/controllers/topology/cluster/reconcile_state_test.go b/internal/controllers/topology/cluster/reconcile_state_test.go index 7a7bc9f5d1fa..a793ca943c94 100644 --- a/internal/controllers/topology/cluster/reconcile_state_test.go +++ b/internal/controllers/topology/cluster/reconcile_state_test.go @@ -1092,6 +1092,9 @@ func TestReconcile_callAfterClusterUpgrade(t *testing.T) { func TestReconcileCluster(t *testing.T) { cluster1 := builder.Cluster(metav1.NamespaceDefault, "cluster1"). + WithClusterNetwork(&clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }). Build() cluster1WithReferences := builder.Cluster(metav1.NamespaceDefault, "cluster1"). WithInfrastructureCluster(builder.TestInfrastructureCluster(metav1.NamespaceDefault, "infrastructure-cluster1"). @@ -3451,7 +3454,13 @@ func TestReconcileState(t *testing.T) { t.Run("Cluster get reconciled with infrastructure Ref only when reconcileInfrastructureCluster pass and reconcileControlPlane fails ", func(t *testing.T) { g := NewWithT(t) - currentCluster := builder.Cluster(metav1.NamespaceDefault, "cluster1").Build() + currentCluster := builder.Cluster(metav1.NamespaceDefault, "cluster1"). + WithClusterNetwork( + &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + ). + Build() infrastructureCluster := builder.TestInfrastructureCluster(metav1.NamespaceDefault, "infrastructure-cluster1").Build() controlPlane := builder.TestControlPlane(metav1.NamespaceDefault, "controlplane-cluster1").Build() @@ -3501,7 +3510,13 @@ func TestReconcileState(t *testing.T) { t.Run("Cluster get reconciled with both infrastructure Ref and control plane ref when both reconcileInfrastructureCluster and reconcileControlPlane pass", func(t *testing.T) { g := NewWithT(t) - currentCluster := builder.Cluster(metav1.NamespaceDefault, "cluster1").Build() + currentCluster := builder.Cluster(metav1.NamespaceDefault, "cluster1"). + WithClusterNetwork( + &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + ). + Build() infrastructureCluster := builder.TestInfrastructureCluster(metav1.NamespaceDefault, "infrastructure-cluster1").Build() controlPlane := builder.TestControlPlane(metav1.NamespaceDefault, "controlplane-cluster1").Build() diff --git a/util/patch/patch_test.go b/util/patch/patch_test.go index 3c63b6aa1a9d..dffbd138301f 100644 --- a/util/patch/patch_test.go +++ b/util/patch/patch_test.go @@ -178,6 +178,11 @@ func TestPatchHelper(t *testing.T) { GenerateName: "test-", Namespace: ns.Name, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } t.Run("should mark it ready", func(t *testing.T) { @@ -521,6 +526,11 @@ func TestPatchHelper(t *testing.T) { GenerateName: "test-", Namespace: ns.Name, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } t.Run("add a finalizer", func(t *testing.T) { @@ -951,6 +961,11 @@ func TestPatchHelper(t *testing.T) { GenerateName: "test-", Namespace: ns.Name, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, } machineSet := &clusterv1.MachineSet{ @@ -996,6 +1011,11 @@ func TestPatchHelper(t *testing.T) { Namespace: ns.Name, Finalizers: []string{"block-deletion"}, }, + Spec: clusterv1.ClusterSpec{ + ClusterNetwork: &clusterv1.ClusterNetwork{ + ServiceDomain: "service.domain", + }, + }, Status: clusterv1.ClusterStatus{}, } key := client.ObjectKey{Name: cluster.GetName(), Namespace: cluster.GetNamespace()}