From 5aafd56d48650c3b3ea190ed6e52b1d6da0341c5 Mon Sep 17 00:00:00 2001 From: Alima Azamat Date: Fri, 30 May 2025 10:21:19 -0700 Subject: [PATCH] Moved AzureASOManaged API to v1beta1 --- api/v1alpha1/azureasomanagedcluster_types.go | 1 + .../azureasomanagedclustertemplate_types.go | 1 + .../azureasomanagedcontrolplane_types.go | 1 + ...ureasomanagedcontrolplanetemplate_types.go | 1 + .../azureasomanagedmachinepool_types.go | 1 + ...zureasomanagedmachinepooltemplate_types.go | 1 + api/v1beta1/azureasomanagedcluster_types.go | 103 +++ .../azureasomanagedcluster_webhook.go | 10 +- .../azureasomanagedclustertemplate_types.go | 63 ++ .../azureasomanagedcontrolplane_types.go | 91 +++ .../azureasomanagedcontrolplane_webhook.go | 10 +- ...ureasomanagedcontrolplanetemplate_types.go | 68 ++ .../azureasomanagedmachinepool_types.go | 86 +++ .../azureasomanagedmachinepool_webhook.go | 10 +- ...zureasomanagedmachinepooltemplate_types.go | 67 ++ api/v1beta1/zz_generated.deepcopy.go | 659 ++++++++++++++++++ ...ster.x-k8s.io_azureasomanagedclusters.yaml | 102 ++- ...8s.io_azureasomanagedclustertemplates.yaml | 56 +- ...x-k8s.io_azureasomanagedcontrolplanes.yaml | 115 ++- ..._azureasomanagedcontrolplanetemplates.yaml | 61 +- ....x-k8s.io_azureasomanagedmachinepools.yaml | 97 ++- ...o_azureasomanagedmachinepooltemplates.yaml | 61 +- ...picontract_in_azureasomanagedclusters.yaml | 2 +- ...ct_in_azureasomanagedclustertemplates.yaml | 2 +- ...tract_in_azureasomanagedcontrolplanes.yaml | 2 +- ..._azureasomanagedcontrolplanetemplates.yaml | 2 +- ...ntract_in_azureasomanagedmachinepools.yaml | 2 +- ...n_azureasomanagedmachinepooltemplates.yaml | 2 +- config/webhook/manifests.yaml | 12 +- controllers/agentpooladopt_controller.go | 20 +- controllers/agentpooladopt_controller_test.go | 12 +- .../azureasomanagedcluster_controller.go | 40 +- .../azureasomanagedcluster_controller_test.go | 54 +- .../azureasomanagedcontrolplane_controller.go | 36 +- ...easomanagedcontrolplane_controller_test.go | 90 +-- .../azureasomanagedmachinepool_controller.go | 26 +- ...reasomanagedmachinepool_controller_test.go | 74 +- controllers/managedclusteradopt_controller.go | 24 +- .../managedclusteradopt_controller_test.go | 8 +- controllers/resource_reconciler.go | 18 +- controllers/resource_reconciler_test.go | 42 +- docs/book/src/managed/asomanagedcluster.md | 57 +- feature/feature.go | 2 +- main.go | 8 +- pkg/mutators/azureasomanagedcontrolplane.go | 8 +- .../azureasomanagedcontrolplane_test.go | 62 +- pkg/mutators/azureasomanagedmachinepool.go | 8 +- .../azureasomanagedmachinepool_test.go | 32 +- ...cluster-template-aks-aso-clusterclass.yaml | 24 +- templates/cluster-template-aks-aso.yaml | 16 +- .../azure-managed-cluster-template.yaml | 2 +- .../azure-managed-controlplane-template.yaml | 2 +- .../azure-managed-machinepool-template.yaml | 4 +- .../aks-aso-clusterclass/clusterclass.yaml | 16 +- .../flavors/aks-aso/cluster-template.yaml | 16 +- .../ci/cluster-template-prow-aks-aso.yaml | 20 +- .../ci/prow-aks-aso/patches/aks-pool2.yaml | 4 +- test/e2e/aks.go | 3 +- test/e2e/aks_machinepools.go | 5 +- test/e2e/azure_clusterproxy.go | 2 - test/e2e/azure_logcollector.go | 9 +- 61 files changed, 2051 insertions(+), 382 deletions(-) create mode 100644 api/v1beta1/azureasomanagedcluster_types.go rename api/{v1alpha1 => v1beta1}/azureasomanagedcluster_webhook.go (83%) create mode 100644 api/v1beta1/azureasomanagedclustertemplate_types.go create mode 100644 api/v1beta1/azureasomanagedcontrolplane_types.go rename api/{v1alpha1 => v1beta1}/azureasomanagedcontrolplane_webhook.go (82%) create mode 100644 api/v1beta1/azureasomanagedcontrolplanetemplate_types.go create mode 100644 api/v1beta1/azureasomanagedmachinepool_types.go rename api/{v1alpha1 => v1beta1}/azureasomanagedmachinepool_webhook.go (83%) create mode 100644 api/v1beta1/azureasomanagedmachinepooltemplate_types.go diff --git a/api/v1alpha1/azureasomanagedcluster_types.go b/api/v1alpha1/azureasomanagedcluster_types.go index 026f4237a85..b0a5f15139b 100644 --- a/api/v1alpha1/azureasomanagedcluster_types.go +++ b/api/v1alpha1/azureasomanagedcluster_types.go @@ -68,6 +68,7 @@ type StatusResource struct { //+kubebuilder:object:root=true //+kubebuilder:subresource:status +//+kubebuilder:deprecatedversion:warning="infrastructure.cluster.x-k8s.io/v1alpha1 AzureASOManagedCluster is deprecated. infrastructure.cluster.x-k8s.io/v1beta1 is equivalent and should be used instead." // AzureASOManagedCluster is the Schema for the azureasomanagedclusters API. type AzureASOManagedCluster struct { diff --git a/api/v1alpha1/azureasomanagedclustertemplate_types.go b/api/v1alpha1/azureasomanagedclustertemplate_types.go index 92bbf6c0a79..46a6bd3420f 100644 --- a/api/v1alpha1/azureasomanagedclustertemplate_types.go +++ b/api/v1alpha1/azureasomanagedclustertemplate_types.go @@ -39,6 +39,7 @@ type AzureASOManagedClusterTemplateResourceSpec struct { } //+kubebuilder:object:root=true +//+kubebuilder:deprecatedversion:warning="infrastructure.cluster.x-k8s.io/v1alpha1 AzureASOManagedClusterTemplate is deprecated. infrastructure.cluster.x-k8s.io/v1beta1 is equivalent and should be used instead." // AzureASOManagedClusterTemplate is the Schema for the azureasomanagedclustertemplates API. type AzureASOManagedClusterTemplate struct { diff --git a/api/v1alpha1/azureasomanagedcontrolplane_types.go b/api/v1alpha1/azureasomanagedcontrolplane_types.go index 7ea30afa1e9..41d75a89fa0 100644 --- a/api/v1alpha1/azureasomanagedcontrolplane_types.go +++ b/api/v1alpha1/azureasomanagedcontrolplane_types.go @@ -56,6 +56,7 @@ type AzureASOManagedControlPlaneStatus struct { //+kubebuilder:object:root=true //+kubebuilder:subresource:status +//+kubebuilder:deprecatedversion:warning="infrastructure.cluster.x-k8s.io/v1alpha1 AzureASOManagedControlPlane is deprecated. infrastructure.cluster.x-k8s.io/v1beta1 is equivalent and should be used instead." // AzureASOManagedControlPlane is the Schema for the azureasomanagedcontrolplanes API. type AzureASOManagedControlPlane struct { diff --git a/api/v1alpha1/azureasomanagedcontrolplanetemplate_types.go b/api/v1alpha1/azureasomanagedcontrolplanetemplate_types.go index 057a541abb6..5edb6ecff9e 100644 --- a/api/v1alpha1/azureasomanagedcontrolplanetemplate_types.go +++ b/api/v1alpha1/azureasomanagedcontrolplanetemplate_types.go @@ -44,6 +44,7 @@ type AzureASOManagedControlPlaneTemplateResourceSpec struct { } //+kubebuilder:object:root=true +//+kubebuilder:deprecatedversion:warning="infrastructure.cluster.x-k8s.io/v1alpha1 AzureASOManagedControlPlaneTemplate is deprecated. infrastructure.cluster.x-k8s.io/v1beta1 is equivalent and should be used instead." // AzureASOManagedControlPlaneTemplate is the Schema for the azureasomanagedcontrolplanetemplates API. type AzureASOManagedControlPlaneTemplate struct { diff --git a/api/v1alpha1/azureasomanagedmachinepool_types.go b/api/v1alpha1/azureasomanagedmachinepool_types.go index f082e12da07..ea3316e9cfc 100644 --- a/api/v1alpha1/azureasomanagedmachinepool_types.go +++ b/api/v1alpha1/azureasomanagedmachinepool_types.go @@ -51,6 +51,7 @@ type AzureASOManagedMachinePoolStatus struct { //+kubebuilder:object:root=true //+kubebuilder:subresource:status +//+kubebuilder:deprecatedversion:warning="infrastructure.cluster.x-k8s.io/v1alpha1 AzureASOManagedMachinePool is deprecated. infrastructure.cluster.x-k8s.io/v1beta1 is equivalent and should be used instead." // AzureASOManagedMachinePool is the Schema for the azureasomanagedmachinepools API. type AzureASOManagedMachinePool struct { diff --git a/api/v1alpha1/azureasomanagedmachinepooltemplate_types.go b/api/v1alpha1/azureasomanagedmachinepooltemplate_types.go index df2f9e439df..fa760f25038 100644 --- a/api/v1alpha1/azureasomanagedmachinepooltemplate_types.go +++ b/api/v1alpha1/azureasomanagedmachinepooltemplate_types.go @@ -43,6 +43,7 @@ type AzureASOManagedMachinePoolTemplateResourceSpec struct { } //+kubebuilder:object:root=true +//+kubebuilder:deprecatedversion:warning="infrastructure.cluster.x-k8s.io/v1alpha1 AzureASOManagedMachinePoolTemplate is deprecated. infrastructure.cluster.x-k8s.io/v1beta1 is equivalent and should be used instead." // AzureASOManagedMachinePoolTemplate is the Schema for the azureasomanagedmachinepooltemplates API. type AzureASOManagedMachinePoolTemplate struct { diff --git a/api/v1beta1/azureasomanagedcluster_types.go b/api/v1beta1/azureasomanagedcluster_types.go new file mode 100644 index 00000000000..3063586ab57 --- /dev/null +++ b/api/v1beta1/azureasomanagedcluster_types.go @@ -0,0 +1,103 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" +) + +const ( + // AzureASOManagedClusterKind is the kind for AzureASOManagedCluster. + AzureASOManagedClusterKind = "AzureASOManagedCluster" + + // AzureASOManagedControlPlaneFinalizer is the finalizer added to AzureASOManagedControlPlanes. + AzureASOManagedControlPlaneFinalizer = "azureasomanagedcontrolplane.infrastructure.cluster.x-k8s.io" +) + +// AzureASOManagedClusterSpec defines the desired state of AzureASOManagedCluster. +type AzureASOManagedClusterSpec struct { + AzureASOManagedClusterTemplateResourceSpec `json:",inline"` + + // ControlPlaneEndpoint is the location of the API server within the control plane. CAPZ manages this field + // and it should not be set by the user. It fulfills Cluster API's cluster infrastructure provider contract. + // Because this field is programmatically set by CAPZ after resource creation, we define it as +optional + // in the API schema to permit resource admission. + //+optional + ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"` +} + +// AzureASOManagedClusterStatus defines the observed state of AzureASOManagedCluster. +type AzureASOManagedClusterStatus struct { + // Ready represents whether or not the cluster has been provisioned and is ready. It fulfills Cluster + // API's cluster infrastructure provider contract. + //+optional + Ready bool `json:"ready"` + + //+optional + Resources []ResourceStatus `json:"resources,omitempty"` +} + +// ResourceStatus represents the status of a resource. +type ResourceStatus struct { + Resource StatusResource `json:"resource"` + Ready bool `json:"ready"` +} + +// StatusResource is a handle to a resource. +type StatusResource struct { + Group string `json:"group"` + Version string `json:"version"` + Kind string `json:"kind"` + Name string `json:"name"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion + +// AzureASOManagedCluster is the Schema for the azureasomanagedclusters API. +type AzureASOManagedCluster struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec AzureASOManagedClusterSpec `json:"spec,omitempty"` + Status AzureASOManagedClusterStatus `json:"status,omitempty"` +} + +// GetResourceStatuses returns the status of resources. +func (a *AzureASOManagedCluster) GetResourceStatuses() []ResourceStatus { + return a.Status.Resources +} + +// SetResourceStatuses sets the status of resources. +func (a *AzureASOManagedCluster) SetResourceStatuses(r []ResourceStatus) { + a.Status.Resources = r +} + +//+kubebuilder:object:root=true + +// AzureASOManagedClusterList contains a list of AzureASOManagedCluster. +type AzureASOManagedClusterList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []AzureASOManagedCluster `json:"items"` +} + +func init() { + SchemeBuilder.Register(&AzureASOManagedCluster{}, &AzureASOManagedClusterList{}) +} diff --git a/api/v1alpha1/azureasomanagedcluster_webhook.go b/api/v1beta1/azureasomanagedcluster_webhook.go similarity index 83% rename from api/v1alpha1/azureasomanagedcluster_webhook.go rename to api/v1beta1/azureasomanagedcluster_webhook.go index 713cc0fd90c..b51413608a1 100644 --- a/api/v1alpha1/azureasomanagedcluster_webhook.go +++ b/api/v1beta1/azureasomanagedcluster_webhook.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1beta1 import ( "context" @@ -31,10 +31,10 @@ import ( // SetupAzureASOManagedClusterWebhookWithManager sets up and registers the webhook with the manager. func SetupAzureASOManagedClusterWebhookWithManager(mgr ctrl.Manager) error { - w := &azureASOManagedClusterWebhook{} + azureASOManagedClusterWebhook := &azureASOManagedClusterWebhook{} return ctrl.NewWebhookManagedBy(mgr). For(&AzureASOManagedCluster{}). - WithValidator(w). + WithValidator(azureASOManagedClusterWebhook). Complete() } @@ -42,7 +42,7 @@ func SetupAzureASOManagedClusterWebhookWithManager(mgr ctrl.Manager) error { type azureASOManagedClusterWebhook struct { } -// +kubebuilder:webhook:verbs=create,path=/validate-infrastructure-cluster-x-k8s-io-v1alpha1-azureasomanagedcluster,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azureasomanagedclusters,versions=v1alpha1,name=validation.azureasomanagedcluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azureasomanagedcluster,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azureasomanagedclusters,versions=v1beta1,name=validation.azureasomanagedcluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. func (ampw *azureASOManagedClusterWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) { diff --git a/api/v1beta1/azureasomanagedclustertemplate_types.go b/api/v1beta1/azureasomanagedclustertemplate_types.go new file mode 100644 index 00000000000..cc47db0261d --- /dev/null +++ b/api/v1beta1/azureasomanagedclustertemplate_types.go @@ -0,0 +1,63 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// AzureASOManagedClusterTemplateSpec defines the desired state of AzureASOManagedClusterTemplate. +type AzureASOManagedClusterTemplateSpec struct { + Template AzureASOManagedClusterTemplateResource `json:"template"` +} + +// AzureASOManagedClusterTemplateResource defines the templated resource. +type AzureASOManagedClusterTemplateResource struct { + Spec AzureASOManagedClusterTemplateResourceSpec `json:"spec,omitempty"` +} + +// AzureASOManagedClusterTemplateResourceSpec defines the desired state of the templated resource. +type AzureASOManagedClusterTemplateResourceSpec struct { + // Resources are embedded ASO resources to be managed by this resource. + //+optional + Resources []runtime.RawExtension `json:"resources,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:storageversion + +// AzureASOManagedClusterTemplate is the Schema for the azureasomanagedclustertemplates API. +type AzureASOManagedClusterTemplate struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec AzureASOManagedClusterTemplateSpec `json:"spec,omitempty"` +} + +//+kubebuilder:object:root=true + +// AzureASOManagedClusterTemplateList contains a list of AzureASOManagedClusterTemplate. +type AzureASOManagedClusterTemplateList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []AzureASOManagedClusterTemplate `json:"items"` +} + +func init() { + SchemeBuilder.Register(&AzureASOManagedClusterTemplate{}, &AzureASOManagedClusterTemplateList{}) +} diff --git a/api/v1beta1/azureasomanagedcontrolplane_types.go b/api/v1beta1/azureasomanagedcontrolplane_types.go new file mode 100644 index 00000000000..c32c98f83c0 --- /dev/null +++ b/api/v1beta1/azureasomanagedcontrolplane_types.go @@ -0,0 +1,91 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" +) + +// AzureASOManagedControlPlaneKind is the kind for AzureASOManagedControlPlane. +const AzureASOManagedControlPlaneKind = "AzureASOManagedControlPlane" + +// AzureASOManagedControlPlaneSpec defines the desired state of AzureASOManagedControlPlane. +type AzureASOManagedControlPlaneSpec struct { + AzureASOManagedControlPlaneTemplateResourceSpec `json:",inline"` +} + +// AzureASOManagedControlPlaneStatus defines the observed state of AzureASOManagedControlPlane. +type AzureASOManagedControlPlaneStatus struct { + // Initialized represents whether or not the API server has been provisioned. It fulfills Cluster API's + // control plane provider contract. For AKS, this is equivalent to `ready`. + //+optional + Initialized bool `json:"initialized"` + + // Ready represents whether or not the API server is ready to receive requests. It fulfills Cluster API's + // control plane provider contract. For AKS, this is equivalent to `initialized`. + //+optional + Ready bool `json:"ready"` + + // Version is the observed Kubernetes version of the control plane. It fulfills Cluster API's control + // plane provider contract. + //+optional + Version string `json:"version,omitempty"` + + //+optional + Resources []ResourceStatus `json:"resources,omitempty"` + + // ControlPlaneEndpoint represents the endpoint for the cluster's API server. + //+optional + ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion + +// AzureASOManagedControlPlane is the Schema for the azureasomanagedcontrolplanes API. +type AzureASOManagedControlPlane struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec AzureASOManagedControlPlaneSpec `json:"spec,omitempty"` + Status AzureASOManagedControlPlaneStatus `json:"status,omitempty"` +} + +// GetResourceStatuses returns the status of resources. +func (a *AzureASOManagedControlPlane) GetResourceStatuses() []ResourceStatus { + return a.Status.Resources +} + +// SetResourceStatuses sets the status of resources. +func (a *AzureASOManagedControlPlane) SetResourceStatuses(r []ResourceStatus) { + a.Status.Resources = r +} + +//+kubebuilder:object:root=true + +// AzureASOManagedControlPlaneList contains a list of AzureASOManagedControlPlane. +type AzureASOManagedControlPlaneList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []AzureASOManagedControlPlane `json:"items"` +} + +func init() { + SchemeBuilder.Register(&AzureASOManagedControlPlane{}, &AzureASOManagedControlPlaneList{}) +} diff --git a/api/v1alpha1/azureasomanagedcontrolplane_webhook.go b/api/v1beta1/azureasomanagedcontrolplane_webhook.go similarity index 82% rename from api/v1alpha1/azureasomanagedcontrolplane_webhook.go rename to api/v1beta1/azureasomanagedcontrolplane_webhook.go index 78e0ba5ee68..261e0c2e8b8 100644 --- a/api/v1alpha1/azureasomanagedcontrolplane_webhook.go +++ b/api/v1beta1/azureasomanagedcontrolplane_webhook.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1beta1 import ( "context" @@ -31,10 +31,10 @@ import ( // SetupAzureASOManagedControlPlaneWebhookWithManager sets up and registers the webhook with the manager. func SetupAzureASOManagedControlPlaneWebhookWithManager(mgr ctrl.Manager) error { - w := &azureASOManagedControlPlaneWebhook{} + azureASOManagedControlPlaneWebhook := &azureASOManagedControlPlaneWebhook{} return ctrl.NewWebhookManagedBy(mgr). For(&AzureASOManagedControlPlane{}). - WithValidator(w). + WithValidator(azureASOManagedControlPlaneWebhook). Complete() } @@ -42,7 +42,7 @@ func SetupAzureASOManagedControlPlaneWebhookWithManager(mgr ctrl.Manager) error type azureASOManagedControlPlaneWebhook struct { } -// +kubebuilder:webhook:verbs=create,path=/validate-infrastructure-cluster-x-k8s-io-v1alpha1-azureasomanagedcontrolplane,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azureasomanagedcontrolplanes,versions=v1alpha1,name=validation.azureasomanagedcontrolplane.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azureasomanagedcontrolplane,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azureasomanagedcontrolplanes,versions=v1beta1,name=validation.azureasomanagedcontrolplane.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. func (ampw *azureASOManagedControlPlaneWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) { diff --git a/api/v1beta1/azureasomanagedcontrolplanetemplate_types.go b/api/v1beta1/azureasomanagedcontrolplanetemplate_types.go new file mode 100644 index 00000000000..6fce8124e5c --- /dev/null +++ b/api/v1beta1/azureasomanagedcontrolplanetemplate_types.go @@ -0,0 +1,68 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// AzureASOManagedControlPlaneTemplateSpec defines the desired state of AzureASOManagedControlPlane. +type AzureASOManagedControlPlaneTemplateSpec struct { + Template AzureASOManagedControlPlaneResource `json:"template"` +} + +// AzureASOManagedControlPlaneResource defines the templated resource. +type AzureASOManagedControlPlaneResource struct { + Spec AzureASOManagedControlPlaneTemplateResourceSpec `json:"spec,omitempty"` +} + +// AzureASOManagedControlPlaneTemplateResourceSpec defines the desired state of the templated resource. +type AzureASOManagedControlPlaneTemplateResourceSpec struct { + // Version is the Kubernetes version of the control plane. It fulfills Cluster API's control plane + // provider contract. + //+optional + Version string `json:"version,omitempty"` + + // Resources are embedded ASO resources to be managed by this resource. + //+optional + Resources []runtime.RawExtension `json:"resources,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:storageversion + +// AzureASOManagedControlPlaneTemplate is the Schema for the azureasomanagedcontrolplanetemplates API. +type AzureASOManagedControlPlaneTemplate struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec AzureASOManagedControlPlaneTemplateSpec `json:"spec,omitempty"` +} + +//+kubebuilder:object:root=true + +// AzureASOManagedControlPlaneTemplateList contains a list of AzureASOManagedControlPlaneTemplate. +type AzureASOManagedControlPlaneTemplateList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []AzureASOManagedControlPlaneTemplate `json:"items"` +} + +func init() { + SchemeBuilder.Register(&AzureASOManagedControlPlaneTemplate{}, &AzureASOManagedControlPlaneTemplateList{}) +} diff --git a/api/v1beta1/azureasomanagedmachinepool_types.go b/api/v1beta1/azureasomanagedmachinepool_types.go new file mode 100644 index 00000000000..160933a1280 --- /dev/null +++ b/api/v1beta1/azureasomanagedmachinepool_types.go @@ -0,0 +1,86 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + // AzureASOManagedMachinePoolKind is the kind for AzureASOManagedMachinePool. + AzureASOManagedMachinePoolKind = "AzureASOManagedMachinePool" + + // ReplicasManagedByAKS is the value of the CAPI replica manager annotation that maps to the AKS built-in autoscaler. + ReplicasManagedByAKS = "aks" +) + +// AzureASOManagedMachinePoolSpec defines the desired state of AzureASOManagedMachinePool. +type AzureASOManagedMachinePoolSpec struct { + AzureASOManagedMachinePoolTemplateResourceSpec `json:",inline"` +} + +// AzureASOManagedMachinePoolStatus defines the observed state of AzureASOManagedMachinePool. +type AzureASOManagedMachinePoolStatus struct { + // Replicas is the current number of provisioned replicas. It fulfills Cluster API's machine pool + // infrastructure provider contract. + //+optional + Replicas int32 `json:"replicas"` + + // Ready represents whether or not the infrastructure is ready to be used. It fulfills Cluster API's + // machine pool infrastructure provider contract. + //+optional + Ready bool `json:"ready"` + + //+optional + Resources []ResourceStatus `json:"resources,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion + +// AzureASOManagedMachinePool is the Schema for the azureasomanagedmachinepools API. +type AzureASOManagedMachinePool struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec AzureASOManagedMachinePoolSpec `json:"spec,omitempty"` + Status AzureASOManagedMachinePoolStatus `json:"status,omitempty"` +} + +// GetResourceStatuses returns the status of resources. +func (a *AzureASOManagedMachinePool) GetResourceStatuses() []ResourceStatus { + return a.Status.Resources +} + +// SetResourceStatuses sets the status of resources. +func (a *AzureASOManagedMachinePool) SetResourceStatuses(r []ResourceStatus) { + a.Status.Resources = r +} + +//+kubebuilder:object:root=true + +// AzureASOManagedMachinePoolList contains a list of AzureASOManagedMachinePool. +type AzureASOManagedMachinePoolList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []AzureASOManagedMachinePool `json:"items"` +} + +func init() { + SchemeBuilder.Register(&AzureASOManagedMachinePool{}, &AzureASOManagedMachinePoolList{}) +} diff --git a/api/v1alpha1/azureasomanagedmachinepool_webhook.go b/api/v1beta1/azureasomanagedmachinepool_webhook.go similarity index 83% rename from api/v1alpha1/azureasomanagedmachinepool_webhook.go rename to api/v1beta1/azureasomanagedmachinepool_webhook.go index aadf57431b2..821f4fc5533 100644 --- a/api/v1alpha1/azureasomanagedmachinepool_webhook.go +++ b/api/v1beta1/azureasomanagedmachinepool_webhook.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The Kubernetes Authors. +Copyright 2025 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1beta1 import ( "context" @@ -31,10 +31,10 @@ import ( // SetupAzureASOManagedMachinePoolWebhookWithManager sets up and registers the webhook with the manager. func SetupAzureASOManagedMachinePoolWebhookWithManager(mgr ctrl.Manager) error { - w := &azureASOManagedMachinePoolWebhook{} + azureASOManagedMachinePoolWebhook := &azureASOManagedMachinePoolWebhook{} return ctrl.NewWebhookManagedBy(mgr). For(&AzureASOManagedMachinePool{}). - WithValidator(w). + WithValidator(azureASOManagedMachinePoolWebhook). Complete() } @@ -42,7 +42,7 @@ func SetupAzureASOManagedMachinePoolWebhookWithManager(mgr ctrl.Manager) error { type azureASOManagedMachinePoolWebhook struct { } -// +kubebuilder:webhook:verbs=create,path=/validate-infrastructure-cluster-x-k8s-io-v1alpha1-azureasomanagedmachinepool,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azureasomanagedmachinepools,versions=v1alpha1,name=validation.azureasomanagedmachinepool.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 +// +kubebuilder:webhook:verbs=create,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azureasomanagedmachinepool,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azureasomanagedmachinepools,versions=v1beta1,name=validation.azureasomanagedmachinepool.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1 // ValidateCreate implements webhook.Validator so a webhook will be registered for the type. func (ampw *azureASOManagedMachinePoolWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) { diff --git a/api/v1beta1/azureasomanagedmachinepooltemplate_types.go b/api/v1beta1/azureasomanagedmachinepooltemplate_types.go new file mode 100644 index 00000000000..a33b0764ddd --- /dev/null +++ b/api/v1beta1/azureasomanagedmachinepooltemplate_types.go @@ -0,0 +1,67 @@ +/* +Copyright 2025 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// AzureASOManagedMachinePoolTemplateSpec defines the desired state of AzureASOManagedMachinePoolTemplate. +type AzureASOManagedMachinePoolTemplateSpec struct { + Template AzureASOManagedControlPlaneResource `json:"template"` +} + +// AzureASOManagedMachinePoolResource defines the templated resource. +type AzureASOManagedMachinePoolResource struct { + Spec AzureASOManagedMachinePoolTemplateResourceSpec `json:"spec,omitempty"` +} + +// AzureASOManagedMachinePoolTemplateResourceSpec defines the desired state of the templated resource. +type AzureASOManagedMachinePoolTemplateResourceSpec struct { + // ProviderIDList is the list of cloud provider IDs for the instances. It fulfills Cluster API's machine + // pool infrastructure provider contract. + ProviderIDList []string `json:"providerIDList,omitempty"` + + // Resources are embedded ASO resources to be managed by this resource. + //+optional + Resources []runtime.RawExtension `json:"resources,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:storageversion + +// AzureASOManagedMachinePoolTemplate is the Schema for the azureasomanagedmachinepooltemplates API. +type AzureASOManagedMachinePoolTemplate struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec AzureASOManagedMachinePoolTemplateSpec `json:"spec,omitempty"` +} + +//+kubebuilder:object:root=true + +// AzureASOManagedMachinePoolTemplateList contains a list of AzureASOManagedMachinePoolTemplate. +type AzureASOManagedMachinePoolTemplateList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []AzureASOManagedMachinePoolTemplate `json:"items"` +} + +func init() { + SchemeBuilder.Register(&AzureASOManagedMachinePoolTemplate{}, &AzureASOManagedMachinePoolTemplateList{}) +} diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index d9378dab409..eaa79ca7ebc 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -347,6 +347,634 @@ func (in *AutoScalerProfile) DeepCopy() *AutoScalerProfile { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedCluster) DeepCopyInto(out *AzureASOManagedCluster) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedCluster. +func (in *AzureASOManagedCluster) DeepCopy() *AzureASOManagedCluster { + if in == nil { + return nil + } + out := new(AzureASOManagedCluster) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AzureASOManagedCluster) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedClusterList) DeepCopyInto(out *AzureASOManagedClusterList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]AzureASOManagedCluster, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedClusterList. +func (in *AzureASOManagedClusterList) DeepCopy() *AzureASOManagedClusterList { + if in == nil { + return nil + } + out := new(AzureASOManagedClusterList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AzureASOManagedClusterList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedClusterSpec) DeepCopyInto(out *AzureASOManagedClusterSpec) { + *out = *in + in.AzureASOManagedClusterTemplateResourceSpec.DeepCopyInto(&out.AzureASOManagedClusterTemplateResourceSpec) + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedClusterSpec. +func (in *AzureASOManagedClusterSpec) DeepCopy() *AzureASOManagedClusterSpec { + if in == nil { + return nil + } + out := new(AzureASOManagedClusterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedClusterStatus) DeepCopyInto(out *AzureASOManagedClusterStatus) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]ResourceStatus, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedClusterStatus. +func (in *AzureASOManagedClusterStatus) DeepCopy() *AzureASOManagedClusterStatus { + if in == nil { + return nil + } + out := new(AzureASOManagedClusterStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedClusterTemplate) DeepCopyInto(out *AzureASOManagedClusterTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedClusterTemplate. +func (in *AzureASOManagedClusterTemplate) DeepCopy() *AzureASOManagedClusterTemplate { + if in == nil { + return nil + } + out := new(AzureASOManagedClusterTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AzureASOManagedClusterTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedClusterTemplateList) DeepCopyInto(out *AzureASOManagedClusterTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]AzureASOManagedClusterTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedClusterTemplateList. +func (in *AzureASOManagedClusterTemplateList) DeepCopy() *AzureASOManagedClusterTemplateList { + if in == nil { + return nil + } + out := new(AzureASOManagedClusterTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AzureASOManagedClusterTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedClusterTemplateResource) DeepCopyInto(out *AzureASOManagedClusterTemplateResource) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedClusterTemplateResource. +func (in *AzureASOManagedClusterTemplateResource) DeepCopy() *AzureASOManagedClusterTemplateResource { + if in == nil { + return nil + } + out := new(AzureASOManagedClusterTemplateResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedClusterTemplateResourceSpec) DeepCopyInto(out *AzureASOManagedClusterTemplateResourceSpec) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]runtime.RawExtension, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedClusterTemplateResourceSpec. +func (in *AzureASOManagedClusterTemplateResourceSpec) DeepCopy() *AzureASOManagedClusterTemplateResourceSpec { + if in == nil { + return nil + } + out := new(AzureASOManagedClusterTemplateResourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedClusterTemplateSpec) DeepCopyInto(out *AzureASOManagedClusterTemplateSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedClusterTemplateSpec. +func (in *AzureASOManagedClusterTemplateSpec) DeepCopy() *AzureASOManagedClusterTemplateSpec { + if in == nil { + return nil + } + out := new(AzureASOManagedClusterTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedControlPlane) DeepCopyInto(out *AzureASOManagedControlPlane) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedControlPlane. +func (in *AzureASOManagedControlPlane) DeepCopy() *AzureASOManagedControlPlane { + if in == nil { + return nil + } + out := new(AzureASOManagedControlPlane) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AzureASOManagedControlPlane) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedControlPlaneList) DeepCopyInto(out *AzureASOManagedControlPlaneList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]AzureASOManagedControlPlane, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedControlPlaneList. +func (in *AzureASOManagedControlPlaneList) DeepCopy() *AzureASOManagedControlPlaneList { + if in == nil { + return nil + } + out := new(AzureASOManagedControlPlaneList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AzureASOManagedControlPlaneList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedControlPlaneResource) DeepCopyInto(out *AzureASOManagedControlPlaneResource) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedControlPlaneResource. +func (in *AzureASOManagedControlPlaneResource) DeepCopy() *AzureASOManagedControlPlaneResource { + if in == nil { + return nil + } + out := new(AzureASOManagedControlPlaneResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedControlPlaneSpec) DeepCopyInto(out *AzureASOManagedControlPlaneSpec) { + *out = *in + in.AzureASOManagedControlPlaneTemplateResourceSpec.DeepCopyInto(&out.AzureASOManagedControlPlaneTemplateResourceSpec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedControlPlaneSpec. +func (in *AzureASOManagedControlPlaneSpec) DeepCopy() *AzureASOManagedControlPlaneSpec { + if in == nil { + return nil + } + out := new(AzureASOManagedControlPlaneSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedControlPlaneStatus) DeepCopyInto(out *AzureASOManagedControlPlaneStatus) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]ResourceStatus, len(*in)) + copy(*out, *in) + } + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedControlPlaneStatus. +func (in *AzureASOManagedControlPlaneStatus) DeepCopy() *AzureASOManagedControlPlaneStatus { + if in == nil { + return nil + } + out := new(AzureASOManagedControlPlaneStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedControlPlaneTemplate) DeepCopyInto(out *AzureASOManagedControlPlaneTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedControlPlaneTemplate. +func (in *AzureASOManagedControlPlaneTemplate) DeepCopy() *AzureASOManagedControlPlaneTemplate { + if in == nil { + return nil + } + out := new(AzureASOManagedControlPlaneTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AzureASOManagedControlPlaneTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedControlPlaneTemplateList) DeepCopyInto(out *AzureASOManagedControlPlaneTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]AzureASOManagedControlPlaneTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedControlPlaneTemplateList. +func (in *AzureASOManagedControlPlaneTemplateList) DeepCopy() *AzureASOManagedControlPlaneTemplateList { + if in == nil { + return nil + } + out := new(AzureASOManagedControlPlaneTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AzureASOManagedControlPlaneTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedControlPlaneTemplateResourceSpec) DeepCopyInto(out *AzureASOManagedControlPlaneTemplateResourceSpec) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]runtime.RawExtension, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedControlPlaneTemplateResourceSpec. +func (in *AzureASOManagedControlPlaneTemplateResourceSpec) DeepCopy() *AzureASOManagedControlPlaneTemplateResourceSpec { + if in == nil { + return nil + } + out := new(AzureASOManagedControlPlaneTemplateResourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedControlPlaneTemplateSpec) DeepCopyInto(out *AzureASOManagedControlPlaneTemplateSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedControlPlaneTemplateSpec. +func (in *AzureASOManagedControlPlaneTemplateSpec) DeepCopy() *AzureASOManagedControlPlaneTemplateSpec { + if in == nil { + return nil + } + out := new(AzureASOManagedControlPlaneTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedMachinePool) DeepCopyInto(out *AzureASOManagedMachinePool) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedMachinePool. +func (in *AzureASOManagedMachinePool) DeepCopy() *AzureASOManagedMachinePool { + if in == nil { + return nil + } + out := new(AzureASOManagedMachinePool) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AzureASOManagedMachinePool) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedMachinePoolList) DeepCopyInto(out *AzureASOManagedMachinePoolList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]AzureASOManagedMachinePool, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedMachinePoolList. +func (in *AzureASOManagedMachinePoolList) DeepCopy() *AzureASOManagedMachinePoolList { + if in == nil { + return nil + } + out := new(AzureASOManagedMachinePoolList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AzureASOManagedMachinePoolList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedMachinePoolResource) DeepCopyInto(out *AzureASOManagedMachinePoolResource) { + *out = *in + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedMachinePoolResource. +func (in *AzureASOManagedMachinePoolResource) DeepCopy() *AzureASOManagedMachinePoolResource { + if in == nil { + return nil + } + out := new(AzureASOManagedMachinePoolResource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedMachinePoolSpec) DeepCopyInto(out *AzureASOManagedMachinePoolSpec) { + *out = *in + in.AzureASOManagedMachinePoolTemplateResourceSpec.DeepCopyInto(&out.AzureASOManagedMachinePoolTemplateResourceSpec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedMachinePoolSpec. +func (in *AzureASOManagedMachinePoolSpec) DeepCopy() *AzureASOManagedMachinePoolSpec { + if in == nil { + return nil + } + out := new(AzureASOManagedMachinePoolSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedMachinePoolStatus) DeepCopyInto(out *AzureASOManagedMachinePoolStatus) { + *out = *in + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]ResourceStatus, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedMachinePoolStatus. +func (in *AzureASOManagedMachinePoolStatus) DeepCopy() *AzureASOManagedMachinePoolStatus { + if in == nil { + return nil + } + out := new(AzureASOManagedMachinePoolStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedMachinePoolTemplate) DeepCopyInto(out *AzureASOManagedMachinePoolTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedMachinePoolTemplate. +func (in *AzureASOManagedMachinePoolTemplate) DeepCopy() *AzureASOManagedMachinePoolTemplate { + if in == nil { + return nil + } + out := new(AzureASOManagedMachinePoolTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AzureASOManagedMachinePoolTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedMachinePoolTemplateList) DeepCopyInto(out *AzureASOManagedMachinePoolTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]AzureASOManagedMachinePoolTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedMachinePoolTemplateList. +func (in *AzureASOManagedMachinePoolTemplateList) DeepCopy() *AzureASOManagedMachinePoolTemplateList { + if in == nil { + return nil + } + out := new(AzureASOManagedMachinePoolTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AzureASOManagedMachinePoolTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedMachinePoolTemplateResourceSpec) DeepCopyInto(out *AzureASOManagedMachinePoolTemplateResourceSpec) { + *out = *in + if in.ProviderIDList != nil { + in, out := &in.ProviderIDList, &out.ProviderIDList + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = make([]runtime.RawExtension, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedMachinePoolTemplateResourceSpec. +func (in *AzureASOManagedMachinePoolTemplateResourceSpec) DeepCopy() *AzureASOManagedMachinePoolTemplateResourceSpec { + if in == nil { + return nil + } + out := new(AzureASOManagedMachinePoolTemplateResourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AzureASOManagedMachinePoolTemplateSpec) DeepCopyInto(out *AzureASOManagedMachinePoolTemplateSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureASOManagedMachinePoolTemplateSpec. +func (in *AzureASOManagedMachinePoolTemplateSpec) DeepCopy() *AzureASOManagedMachinePoolTemplateSpec { + if in == nil { + return nil + } + out := new(AzureASOManagedMachinePoolTemplateSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AzureBastion) DeepCopyInto(out *AzureBastion) { *out = *in @@ -3413,6 +4041,22 @@ func (in *RateLimitSpec) DeepCopy() *RateLimitSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceStatus) DeepCopyInto(out *ResourceStatus) { + *out = *in + out.Resource = in.Resource +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceStatus. +func (in *ResourceStatus) DeepCopy() *ResourceStatus { + if in == nil { + return nil + } + out := new(ResourceStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RouteTable) DeepCopyInto(out *RouteTable) { *out = *in @@ -3631,6 +4275,21 @@ func (in *SpotVMOptions) DeepCopy() *SpotVMOptions { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StatusResource) DeepCopyInto(out *StatusResource) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StatusResource. +func (in *StatusResource) DeepCopy() *StatusResource { + if in == nil { + return nil + } + out := new(StatusResource) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SubnetClassSpec) DeepCopyInto(out *SubnetClassSpec) { *out = *in diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedclusters.yaml index 804838ea1fb..57450a38cdd 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedclusters.yaml @@ -14,7 +14,107 @@ spec: singular: azureasomanagedcluster scope: Namespaced versions: - - name: v1alpha1 + - deprecated: true + deprecationWarning: infrastructure.cluster.x-k8s.io/v1alpha1 AzureASOManagedCluster + is deprecated. infrastructure.cluster.x-k8s.io/v1beta1 is equivalent and should + be used instead. + name: v1alpha1 + schema: + openAPIV3Schema: + description: AzureASOManagedCluster is the Schema for the azureasomanagedclusters + API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: AzureASOManagedClusterSpec defines the desired state of AzureASOManagedCluster. + properties: + controlPlaneEndpoint: + description: |- + ControlPlaneEndpoint is the location of the API server within the control plane. CAPZ manages this field + and it should not be set by the user. It fulfills Cluster API's cluster infrastructure provider contract. + Because this field is programmatically set by CAPZ after resource creation, we define it as +optional + in the API schema to permit resource admission. + properties: + host: + description: host is the hostname on which the API server is serving. + maxLength: 512 + type: string + port: + description: port is the port on which the API server is serving. + format: int32 + type: integer + required: + - host + - port + type: object + resources: + description: Resources are embedded ASO resources to be managed by + this resource. + items: + type: object + x-kubernetes-preserve-unknown-fields: true + type: array + type: object + status: + description: AzureASOManagedClusterStatus defines the observed state of + AzureASOManagedCluster. + properties: + ready: + description: |- + Ready represents whether or not the cluster has been provisioned and is ready. It fulfills Cluster + API's cluster infrastructure provider contract. + type: boolean + resources: + items: + description: ResourceStatus represents the status of a resource. + properties: + ready: + type: boolean + resource: + description: StatusResource is a handle to a resource. + properties: + group: + type: string + kind: + type: string + name: + type: string + version: + type: string + required: + - group + - kind + - name + - version + type: object + required: + - ready + - resource + type: object + type: array + type: object + type: object + served: true + storage: false + subresources: + status: {} + - name: v1beta1 schema: openAPIV3Schema: description: AzureASOManagedCluster is the Schema for the azureasomanagedclusters diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedclustertemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedclustertemplates.yaml index 29c7bf15251..3094ba8187d 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedclustertemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedclustertemplates.yaml @@ -14,7 +14,61 @@ spec: singular: azureasomanagedclustertemplate scope: Namespaced versions: - - name: v1alpha1 + - deprecated: true + deprecationWarning: infrastructure.cluster.x-k8s.io/v1alpha1 AzureASOManagedClusterTemplate + is deprecated. infrastructure.cluster.x-k8s.io/v1beta1 is equivalent and should + be used instead. + name: v1alpha1 + schema: + openAPIV3Schema: + description: AzureASOManagedClusterTemplate is the Schema for the azureasomanagedclustertemplates + API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: AzureASOManagedClusterTemplateSpec defines the desired state + of AzureASOManagedClusterTemplate. + properties: + template: + description: AzureASOManagedClusterTemplateResource defines the templated + resource. + properties: + spec: + description: AzureASOManagedClusterTemplateResourceSpec defines + the desired state of the templated resource. + properties: + resources: + description: Resources are embedded ASO resources to be managed + by this resource. + items: + type: object + x-kubernetes-preserve-unknown-fields: true + type: array + type: object + type: object + required: + - template + type: object + type: object + served: true + storage: false + - name: v1beta1 schema: openAPIV3Schema: description: AzureASOManagedClusterTemplate is the Schema for the azureasomanagedclustertemplates diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedcontrolplanes.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedcontrolplanes.yaml index b4daa3aef65..9d8b34375f1 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedcontrolplanes.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedcontrolplanes.yaml @@ -14,7 +14,120 @@ spec: singular: azureasomanagedcontrolplane scope: Namespaced versions: - - name: v1alpha1 + - deprecated: true + deprecationWarning: infrastructure.cluster.x-k8s.io/v1alpha1 AzureASOManagedControlPlane + is deprecated. infrastructure.cluster.x-k8s.io/v1beta1 is equivalent and should + be used instead. + name: v1alpha1 + schema: + openAPIV3Schema: + description: AzureASOManagedControlPlane is the Schema for the azureasomanagedcontrolplanes + API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: AzureASOManagedControlPlaneSpec defines the desired state + of AzureASOManagedControlPlane. + properties: + resources: + description: Resources are embedded ASO resources to be managed by + this resource. + items: + type: object + x-kubernetes-preserve-unknown-fields: true + type: array + version: + description: |- + Version is the Kubernetes version of the control plane. It fulfills Cluster API's control plane + provider contract. + type: string + type: object + status: + description: AzureASOManagedControlPlaneStatus defines the observed state + of AzureASOManagedControlPlane. + properties: + controlPlaneEndpoint: + description: ControlPlaneEndpoint represents the endpoint for the + cluster's API server. + properties: + host: + description: host is the hostname on which the API server is serving. + maxLength: 512 + type: string + port: + description: port is the port on which the API server is serving. + format: int32 + type: integer + required: + - host + - port + type: object + initialized: + description: |- + Initialized represents whether or not the API server has been provisioned. It fulfills Cluster API's + control plane provider contract. For AKS, this is equivalent to `ready`. + type: boolean + ready: + description: |- + Ready represents whether or not the API server is ready to receive requests. It fulfills Cluster API's + control plane provider contract. For AKS, this is equivalent to `initialized`. + type: boolean + resources: + items: + description: ResourceStatus represents the status of a resource. + properties: + ready: + type: boolean + resource: + description: StatusResource is a handle to a resource. + properties: + group: + type: string + kind: + type: string + name: + type: string + version: + type: string + required: + - group + - kind + - name + - version + type: object + required: + - ready + - resource + type: object + type: array + version: + description: |- + Version is the observed Kubernetes version of the control plane. It fulfills Cluster API's control + plane provider contract. + type: string + type: object + type: object + served: true + storage: false + subresources: + status: {} + - name: v1beta1 schema: openAPIV3Schema: description: AzureASOManagedControlPlane is the Schema for the azureasomanagedcontrolplanes diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedcontrolplanetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedcontrolplanetemplates.yaml index 8a89ea72fbe..7064b003903 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedcontrolplanetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedcontrolplanetemplates.yaml @@ -14,7 +14,66 @@ spec: singular: azureasomanagedcontrolplanetemplate scope: Namespaced versions: - - name: v1alpha1 + - deprecated: true + deprecationWarning: infrastructure.cluster.x-k8s.io/v1alpha1 AzureASOManagedControlPlaneTemplate + is deprecated. infrastructure.cluster.x-k8s.io/v1beta1 is equivalent and should + be used instead. + name: v1alpha1 + schema: + openAPIV3Schema: + description: AzureASOManagedControlPlaneTemplate is the Schema for the azureasomanagedcontrolplanetemplates + API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: AzureASOManagedControlPlaneTemplateSpec defines the desired + state of AzureASOManagedControlPlane. + properties: + template: + description: AzureASOManagedControlPlaneResource defines the templated + resource. + properties: + spec: + description: AzureASOManagedControlPlaneTemplateResourceSpec defines + the desired state of the templated resource. + properties: + resources: + description: Resources are embedded ASO resources to be managed + by this resource. + items: + type: object + x-kubernetes-preserve-unknown-fields: true + type: array + version: + description: |- + Version is the Kubernetes version of the control plane. It fulfills Cluster API's control plane + provider contract. + type: string + type: object + type: object + required: + - template + type: object + type: object + served: true + storage: false + - name: v1beta1 schema: openAPIV3Schema: description: AzureASOManagedControlPlaneTemplate is the Schema for the azureasomanagedcontrolplanetemplates diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedmachinepools.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedmachinepools.yaml index bd662f7badc..9f6b0f6558c 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedmachinepools.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedmachinepools.yaml @@ -14,7 +14,102 @@ spec: singular: azureasomanagedmachinepool scope: Namespaced versions: - - name: v1alpha1 + - deprecated: true + deprecationWarning: infrastructure.cluster.x-k8s.io/v1alpha1 AzureASOManagedMachinePool + is deprecated. infrastructure.cluster.x-k8s.io/v1beta1 is equivalent and should + be used instead. + name: v1alpha1 + schema: + openAPIV3Schema: + description: AzureASOManagedMachinePool is the Schema for the azureasomanagedmachinepools + API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: AzureASOManagedMachinePoolSpec defines the desired state + of AzureASOManagedMachinePool. + properties: + providerIDList: + description: |- + ProviderIDList is the list of cloud provider IDs for the instances. It fulfills Cluster API's machine + pool infrastructure provider contract. + items: + type: string + type: array + resources: + description: Resources are embedded ASO resources to be managed by + this resource. + items: + type: object + x-kubernetes-preserve-unknown-fields: true + type: array + type: object + status: + description: AzureASOManagedMachinePoolStatus defines the observed state + of AzureASOManagedMachinePool. + properties: + ready: + description: |- + Ready represents whether or not the infrastructure is ready to be used. It fulfills Cluster API's + machine pool infrastructure provider contract. + type: boolean + replicas: + description: |- + Replicas is the current number of provisioned replicas. It fulfills Cluster API's machine pool + infrastructure provider contract. + format: int32 + type: integer + resources: + items: + description: ResourceStatus represents the status of a resource. + properties: + ready: + type: boolean + resource: + description: StatusResource is a handle to a resource. + properties: + group: + type: string + kind: + type: string + name: + type: string + version: + type: string + required: + - group + - kind + - name + - version + type: object + required: + - ready + - resource + type: object + type: array + type: object + type: object + served: true + storage: false + subresources: + status: {} + - name: v1beta1 schema: openAPIV3Schema: description: AzureASOManagedMachinePool is the Schema for the azureasomanagedmachinepools diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedmachinepooltemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedmachinepooltemplates.yaml index 3786cf1f2c7..18875382a0c 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedmachinepooltemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedmachinepooltemplates.yaml @@ -14,7 +14,66 @@ spec: singular: azureasomanagedmachinepooltemplate scope: Namespaced versions: - - name: v1alpha1 + - deprecated: true + deprecationWarning: infrastructure.cluster.x-k8s.io/v1alpha1 AzureASOManagedMachinePoolTemplate + is deprecated. infrastructure.cluster.x-k8s.io/v1beta1 is equivalent and should + be used instead. + name: v1alpha1 + schema: + openAPIV3Schema: + description: AzureASOManagedMachinePoolTemplate is the Schema for the azureasomanagedmachinepooltemplates + API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: AzureASOManagedMachinePoolTemplateSpec defines the desired + state of AzureASOManagedMachinePoolTemplate. + properties: + template: + description: AzureASOManagedControlPlaneResource defines the templated + resource. + properties: + spec: + description: AzureASOManagedControlPlaneTemplateResourceSpec defines + the desired state of the templated resource. + properties: + resources: + description: Resources are embedded ASO resources to be managed + by this resource. + items: + type: object + x-kubernetes-preserve-unknown-fields: true + type: array + version: + description: |- + Version is the Kubernetes version of the control plane. It fulfills Cluster API's control plane + provider contract. + type: string + type: object + type: object + required: + - template + type: object + type: object + served: true + storage: false + - name: v1beta1 schema: openAPIV3Schema: description: AzureASOManagedMachinePoolTemplate is the Schema for the azureasomanagedmachinepooltemplates diff --git a/config/crd/patches/capicontract_in_azureasomanagedclusters.yaml b/config/crd/patches/capicontract_in_azureasomanagedclusters.yaml index 58a3b1cc71b..994c912f82d 100644 --- a/config/crd/patches/capicontract_in_azureasomanagedclusters.yaml +++ b/config/crd/patches/capicontract_in_azureasomanagedclusters.yaml @@ -3,4 +3,4 @@ kind: CustomResourceDefinition metadata: name: azureasomanagedclusters.infrastructure.cluster.x-k8s.io labels: - cluster.x-k8s.io/v1beta1: v1alpha1 + cluster.x-k8s.io/v1beta1: v1beta1 diff --git a/config/crd/patches/capicontract_in_azureasomanagedclustertemplates.yaml b/config/crd/patches/capicontract_in_azureasomanagedclustertemplates.yaml index ba1ebffffd2..bea94cd4249 100644 --- a/config/crd/patches/capicontract_in_azureasomanagedclustertemplates.yaml +++ b/config/crd/patches/capicontract_in_azureasomanagedclustertemplates.yaml @@ -3,4 +3,4 @@ kind: CustomResourceDefinition metadata: name: azureasomanagedclustertemplates.infrastructure.cluster.x-k8s.io labels: - cluster.x-k8s.io/v1beta1: v1alpha1 + cluster.x-k8s.io/v1beta1: v1beta1 diff --git a/config/crd/patches/capicontract_in_azureasomanagedcontrolplanes.yaml b/config/crd/patches/capicontract_in_azureasomanagedcontrolplanes.yaml index f75b5867ee7..2cfadf14db7 100644 --- a/config/crd/patches/capicontract_in_azureasomanagedcontrolplanes.yaml +++ b/config/crd/patches/capicontract_in_azureasomanagedcontrolplanes.yaml @@ -3,4 +3,4 @@ kind: CustomResourceDefinition metadata: name: azureasomanagedcontrolplanes.infrastructure.cluster.x-k8s.io labels: - cluster.x-k8s.io/v1beta1: v1alpha1 + cluster.x-k8s.io/v1beta1: v1beta1 diff --git a/config/crd/patches/capicontract_in_azureasomanagedcontrolplanetemplates.yaml b/config/crd/patches/capicontract_in_azureasomanagedcontrolplanetemplates.yaml index 302a51fe648..997fff05df3 100644 --- a/config/crd/patches/capicontract_in_azureasomanagedcontrolplanetemplates.yaml +++ b/config/crd/patches/capicontract_in_azureasomanagedcontrolplanetemplates.yaml @@ -3,4 +3,4 @@ kind: CustomResourceDefinition metadata: name: azureasomanagedcontrolplanetemplates.infrastructure.cluster.x-k8s.io labels: - cluster.x-k8s.io/v1beta1: v1alpha1 + cluster.x-k8s.io/v1beta1: v1beta1 diff --git a/config/crd/patches/capicontract_in_azureasomanagedmachinepools.yaml b/config/crd/patches/capicontract_in_azureasomanagedmachinepools.yaml index b93f24b0101..4680515d4c5 100644 --- a/config/crd/patches/capicontract_in_azureasomanagedmachinepools.yaml +++ b/config/crd/patches/capicontract_in_azureasomanagedmachinepools.yaml @@ -3,4 +3,4 @@ kind: CustomResourceDefinition metadata: name: azureasomanagedmachinepools.infrastructure.cluster.x-k8s.io labels: - cluster.x-k8s.io/v1beta1: v1alpha1 + cluster.x-k8s.io/v1beta1: v1beta1 diff --git a/config/crd/patches/capicontract_in_azureasomanagedmachinepooltemplates.yaml b/config/crd/patches/capicontract_in_azureasomanagedmachinepooltemplates.yaml index 2682b37dc87..2317eb13aa2 100644 --- a/config/crd/patches/capicontract_in_azureasomanagedmachinepooltemplates.yaml +++ b/config/crd/patches/capicontract_in_azureasomanagedmachinepooltemplates.yaml @@ -3,4 +3,4 @@ kind: CustomResourceDefinition metadata: name: azureasomanagedmachinepooltemplates.infrastructure.cluster.x-k8s.io labels: - cluster.x-k8s.io/v1beta1: v1alpha1 + cluster.x-k8s.io/v1beta1: v1beta1 diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index de5ab8e6417..592311a87e5 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -211,14 +211,14 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-infrastructure-cluster-x-k8s-io-v1alpha1-azureasomanagedcluster + path: /validate-infrastructure-cluster-x-k8s-io-v1beta1-azureasomanagedcluster failurePolicy: Fail name: validation.azureasomanagedcluster.infrastructure.cluster.x-k8s.io rules: - apiGroups: - infrastructure.cluster.x-k8s.io apiVersions: - - v1alpha1 + - v1beta1 operations: - CREATE resources: @@ -231,14 +231,14 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-infrastructure-cluster-x-k8s-io-v1alpha1-azureasomanagedcontrolplane + path: /validate-infrastructure-cluster-x-k8s-io-v1beta1-azureasomanagedcontrolplane failurePolicy: Fail name: validation.azureasomanagedcontrolplane.infrastructure.cluster.x-k8s.io rules: - apiGroups: - infrastructure.cluster.x-k8s.io apiVersions: - - v1alpha1 + - v1beta1 operations: - CREATE resources: @@ -251,14 +251,14 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-infrastructure-cluster-x-k8s-io-v1alpha1-azureasomanagedmachinepool + path: /validate-infrastructure-cluster-x-k8s-io-v1beta1-azureasomanagedmachinepool failurePolicy: Fail name: validation.azureasomanagedmachinepool.infrastructure.cluster.x-k8s.io rules: - apiGroups: - infrastructure.cluster.x-k8s.io apiVersions: - - v1alpha1 + - v1beta1 operations: - CREATE resources: diff --git a/controllers/agentpooladopt_controller.go b/controllers/agentpooladopt_controller.go index 68a523b2ebf..7ec4a824ea0 100644 --- a/controllers/agentpooladopt_controller.go +++ b/controllers/agentpooladopt_controller.go @@ -33,7 +33,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -85,7 +85,7 @@ func (r *AgentPoolAdoptReconciler) Reconcile(ctx context.Context, req ctrl.Reque for _, owner := range agentPool.GetOwnerReferences() { if matchesASOManagedAPIGroup(owner.APIVersion) && - owner.Kind == infrav1alpha.AzureASOManagedMachinePoolKind { + owner.Kind == infrav1.AzureASOManagedMachinePoolKind { return ctrl.Result{}, nil } } @@ -127,7 +127,7 @@ func (r *AgentPoolAdoptReconciler) Reconcile(ctx context.Context, req ctrl.Reque var managedControlPlaneOwner *metav1.OwnerReference for _, owner := range managedCluster.GetOwnerReferences() { if matchesASOManagedAPIGroup(owner.APIVersion) && - owner.Kind == infrav1alpha.AzureASOManagedControlPlaneKind && + owner.Kind == infrav1.AzureASOManagedControlPlaneKind && owner.Name == agentPool.Owner().Name { managedControlPlaneOwner = ptr.To(owner) break @@ -136,7 +136,7 @@ func (r *AgentPoolAdoptReconciler) Reconcile(ctx context.Context, req ctrl.Reque if managedControlPlaneOwner == nil { return ctrl.Result{}, fmt.Errorf("ManagedCluster %s is not owned by any AzureASOManagedControlPlane", managedClusterKey) } - asoManagedControlPlane := &infrav1alpha.AzureASOManagedControlPlane{} + asoManagedControlPlane := &infrav1.AzureASOManagedControlPlane{} managedControlPlaneKey := client.ObjectKey{ Namespace: namespace, Name: managedControlPlaneOwner.Name, @@ -147,13 +147,13 @@ func (r *AgentPoolAdoptReconciler) Reconcile(ctx context.Context, req ctrl.Reque } clusterName := asoManagedControlPlane.Labels[clusterv1.ClusterNameLabel] - asoManagedMachinePool := &infrav1alpha.AzureASOManagedMachinePool{ + asoManagedMachinePool := &infrav1.AzureASOManagedMachinePool{ ObjectMeta: metav1.ObjectMeta{ Namespace: namespace, Name: agentPool.Name, }, - Spec: infrav1alpha.AzureASOManagedMachinePoolSpec{ - AzureASOManagedMachinePoolTemplateResourceSpec: infrav1alpha.AzureASOManagedMachinePoolTemplateResourceSpec{ + Spec: infrav1.AzureASOManagedMachinePoolSpec{ + AzureASOManagedMachinePoolTemplateResourceSpec: infrav1.AzureASOManagedMachinePoolTemplateResourceSpec{ Resources: []runtime.RawExtension{ {Object: agentPool}, }, @@ -176,8 +176,8 @@ func (r *AgentPoolAdoptReconciler) Reconcile(ctx context.Context, req ctrl.Reque }, ClusterName: clusterName, InfrastructureRef: corev1.ObjectReference{ - APIVersion: infrav1alpha.GroupVersion.Identifier(), - Kind: infrav1alpha.AzureASOManagedMachinePoolKind, + APIVersion: infrav1.GroupVersion.Identifier(), + Kind: infrav1.AzureASOManagedMachinePoolKind, Name: asoManagedMachinePool.Name, }, }, @@ -187,7 +187,7 @@ func (r *AgentPoolAdoptReconciler) Reconcile(ctx context.Context, req ctrl.Reque if ptr.Deref(agentPool.Spec.EnableAutoScaling, false) { machinePool.Annotations = map[string]string{ - clusterv1.ReplicasManagedByAnnotation: infrav1alpha.ReplicasManagedByAKS, + clusterv1.ReplicasManagedByAnnotation: infrav1.ReplicasManagedByAKS, } } diff --git a/controllers/agentpooladopt_controller_test.go b/controllers/agentpooladopt_controller_test.go index 1926d081fe2..da5b566549e 100644 --- a/controllers/agentpooladopt_controller_test.go +++ b/controllers/agentpooladopt_controller_test.go @@ -31,7 +31,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) func TestAgentPoolAdoptController(t *testing.T) { @@ -62,14 +62,14 @@ func TestAgentPoolAdoptController(t *testing.T) { Namespace: "fake-ns", OwnerReferences: []metav1.OwnerReference{ { - Kind: infrav1alpha.AzureASOManagedControlPlaneKind, - APIVersion: infrav1alpha.GroupVersion.Identifier(), + Kind: infrav1.AzureASOManagedControlPlaneKind, + APIVersion: infrav1.GroupVersion.Identifier(), Name: "fake-managed-cluster", }, }, }, } - asoManagedControlPlane := &infrav1alpha.AzureASOManagedControlPlane{ + asoManagedControlPlane := &infrav1.AzureASOManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "fake-managed-cluster", Namespace: "fake-ns", @@ -81,7 +81,7 @@ func TestAgentPoolAdoptController(t *testing.T) { err = asocontainerservicev1.AddToScheme(scheme) g.Expect(err).ToNot(HaveOccurred()) - err = infrav1alpha.AddToScheme(scheme) + err = infrav1.AddToScheme(scheme) g.Expect(err).ToNot(HaveOccurred()) client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(agentPool, mc, asoManagedControlPlane).WithStatusSubresource(mc, agentPool, asoManagedControlPlane).Build() aprec := &AgentPoolAdoptReconciler{ @@ -92,7 +92,7 @@ func TestAgentPoolAdoptController(t *testing.T) { mp := &expv1.MachinePool{} err = aprec.Get(ctx, types.NamespacedName{Name: agentPool.Name, Namespace: "fake-ns"}, mp) g.Expect(err).ToNot(HaveOccurred()) - asoMP := &infrav1alpha.AzureASOManagedMachinePool{} + asoMP := &infrav1.AzureASOManagedMachinePool{} err = aprec.Get(ctx, types.NamespacedName{Name: agentPool.Name, Namespace: "fake-ns"}, asoMP) g.Expect(err).ToNot(HaveOccurred()) } diff --git a/controllers/azureasomanagedcluster_controller.go b/controllers/azureasomanagedcluster_controller.go index ca4343299f3..caa41645bd9 100644 --- a/controllers/azureasomanagedcluster_controller.go +++ b/controllers/azureasomanagedcluster_controller.go @@ -40,7 +40,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/pkg/mutators" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -52,7 +52,7 @@ type AzureASOManagedClusterReconciler struct { client.Client WatchFilterValue string - newResourceReconciler func(*infrav1alpha.AzureASOManagedCluster, []*unstructured.Unstructured) resourceReconciler + newResourceReconciler func(*infrav1.AzureASOManagedCluster, []*unstructured.Unstructured) resourceReconciler } type resourceReconciler interface { @@ -72,20 +72,20 @@ type resourceReconciler interface { func (r *AzureASOManagedClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedClusterReconciler.SetupWithManager", - tele.KVP("controller", infrav1alpha.AzureASOManagedClusterKind), + tele.KVP("controller", infrav1.AzureASOManagedClusterKind), ) defer done() c, err := ctrl.NewControllerManagedBy(mgr). WithOptions(options). - For(&infrav1alpha.AzureASOManagedCluster{}). + For(&infrav1.AzureASOManagedCluster{}). WithEventFilter(predicates.ResourceHasFilterLabel(mgr.GetScheme(), log, r.WatchFilterValue)). WithEventFilter(predicates.ResourceIsNotExternallyManaged(mgr.GetScheme(), log)). // Watch clusters for pause/unpause notifications Watches( &clusterv1.Cluster{}, handler.EnqueueRequestsFromMapFunc( - util.ClusterToInfrastructureMapFunc(ctx, infrav1alpha.GroupVersion.WithKind(infrav1alpha.AzureASOManagedClusterKind), mgr.GetClient(), &infrav1alpha.AzureASOManagedCluster{}), + util.ClusterToInfrastructureMapFunc(ctx, infrav1.GroupVersion.WithKind(infrav1.AzureASOManagedClusterKind), mgr.GetClient(), &infrav1.AzureASOManagedCluster{}), ), builder.WithPredicates( predicates.ResourceHasFilterLabel(mgr.GetScheme(), log, r.WatchFilterValue), @@ -93,18 +93,18 @@ func (r *AzureASOManagedClusterReconciler) SetupWithManager(ctx context.Context, ), ). Watches( - &infrav1alpha.AzureASOManagedControlPlane{}, + &infrav1.AzureASOManagedControlPlane{}, handler.EnqueueRequestsFromMapFunc(asoManagedControlPlaneToManagedClusterMap(r.Client)), builder.WithPredicates( predicates.ResourceHasFilterLabel(mgr.GetScheme(), log, r.WatchFilterValue), predicate.Funcs{ CreateFunc: func(ev event.CreateEvent) bool { - controlPlane := ev.Object.(*infrav1alpha.AzureASOManagedControlPlane) + controlPlane := ev.Object.(*infrav1.AzureASOManagedControlPlane) return !controlPlane.Status.ControlPlaneEndpoint.IsZero() }, UpdateFunc: func(ev event.UpdateEvent) bool { - oldControlPlane := ev.ObjectOld.(*infrav1alpha.AzureASOManagedControlPlane) - newControlPlane := ev.ObjectNew.(*infrav1alpha.AzureASOManagedControlPlane) + oldControlPlane := ev.ObjectOld.(*infrav1.AzureASOManagedControlPlane) + newControlPlane := ev.ObjectNew.(*infrav1.AzureASOManagedControlPlane) return oldControlPlane.Status.ControlPlaneEndpoint != newControlPlane.Status.ControlPlaneEndpoint }, @@ -123,7 +123,7 @@ func (r *AzureASOManagedClusterReconciler) SetupWithManager(ctx context.Context, PredicateLogger: &log, } - r.newResourceReconciler = func(asoManagedCluster *infrav1alpha.AzureASOManagedCluster, resources []*unstructured.Unstructured) resourceReconciler { + r.newResourceReconciler = func(asoManagedCluster *infrav1.AzureASOManagedCluster, resources []*unstructured.Unstructured) resourceReconciler { return &ResourceReconciler{ Client: r.Client, resources: resources, @@ -137,7 +137,7 @@ func (r *AzureASOManagedClusterReconciler) SetupWithManager(ctx context.Context, func asoManagedControlPlaneToManagedClusterMap(c client.Client) handler.MapFunc { return func(ctx context.Context, o client.Object) []reconcile.Request { - asoManagedControlPlane := o.(*infrav1alpha.AzureASOManagedControlPlane) + asoManagedControlPlane := o.(*infrav1.AzureASOManagedControlPlane) cluster, err := util.GetOwnerCluster(ctx, c, asoManagedControlPlane.ObjectMeta) if err != nil { @@ -147,7 +147,7 @@ func asoManagedControlPlaneToManagedClusterMap(c client.Client) handler.MapFunc if cluster == nil || cluster.Spec.InfrastructureRef == nil || !matchesASOManagedAPIGroup(cluster.Spec.InfrastructureRef.APIVersion) || - cluster.Spec.InfrastructureRef.Kind != infrav1alpha.AzureASOManagedClusterKind { + cluster.Spec.InfrastructureRef.Kind != infrav1.AzureASOManagedClusterKind { return nil } @@ -164,7 +164,7 @@ func asoManagedControlPlaneToManagedClusterMap(c client.Client) handler.MapFunc func matchesASOManagedAPIGroup(apiVersion string) bool { gv, _ := schema.ParseGroupVersion(apiVersion) - return gv.Group == infrav1alpha.GroupVersion.Group + return gv.Group == infrav1.GroupVersion.Group } //+kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=azureasomanagedclusters,verbs=get;list;watch;create;update;patch;delete @@ -177,11 +177,11 @@ func (r *AzureASOManagedClusterReconciler) Reconcile(ctx context.Context, req ct "controllers.AzureASOManagedClusterReconciler.Reconcile", tele.KVP("namespace", req.Namespace), tele.KVP("name", req.Name), - tele.KVP("kind", infrav1alpha.AzureASOManagedClusterKind), + tele.KVP("kind", infrav1.AzureASOManagedClusterKind), ) defer done() - asoManagedCluster := &infrav1alpha.AzureASOManagedCluster{} + asoManagedCluster := &infrav1.AzureASOManagedCluster{} err := r.Get(ctx, req.NamespacedName, asoManagedCluster) if err != nil { return ctrl.Result{}, client.IgnoreNotFound(err) @@ -218,7 +218,7 @@ func (r *AzureASOManagedClusterReconciler) Reconcile(ctx context.Context, req ct return r.reconcileNormal(ctx, asoManagedCluster, cluster) } -func (r *AzureASOManagedClusterReconciler) reconcileNormal(ctx context.Context, asoManagedCluster *infrav1alpha.AzureASOManagedCluster, cluster *clusterv1.Cluster) (ctrl.Result, error) { +func (r *AzureASOManagedClusterReconciler) reconcileNormal(ctx context.Context, asoManagedCluster *infrav1.AzureASOManagedCluster, cluster *clusterv1.Cluster) (ctrl.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedClusterReconciler.reconcileNormal", ) @@ -231,7 +231,7 @@ func (r *AzureASOManagedClusterReconciler) reconcileNormal(ctx context.Context, } if cluster.Spec.ControlPlaneRef == nil || !matchesASOManagedAPIGroup(cluster.Spec.ControlPlaneRef.APIVersion) || - cluster.Spec.ControlPlaneRef.Kind != infrav1alpha.AzureASOManagedControlPlaneKind { + cluster.Spec.ControlPlaneRef.Kind != infrav1.AzureASOManagedControlPlaneKind { return ctrl.Result{}, reconcile.TerminalError(errInvalidControlPlaneKind) } @@ -256,7 +256,7 @@ func (r *AzureASOManagedClusterReconciler) reconcileNormal(ctx context.Context, } } - asoManagedControlPlane := &infrav1alpha.AzureASOManagedControlPlane{ + asoManagedControlPlane := &infrav1.AzureASOManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Namespace: cluster.Spec.ControlPlaneRef.Namespace, Name: cluster.Spec.ControlPlaneRef.Name, @@ -273,7 +273,7 @@ func (r *AzureASOManagedClusterReconciler) reconcileNormal(ctx context.Context, return ctrl.Result{}, nil } -func (r *AzureASOManagedClusterReconciler) reconcilePaused(ctx context.Context, asoManagedCluster *infrav1alpha.AzureASOManagedCluster) (ctrl.Result, error) { +func (r *AzureASOManagedClusterReconciler) reconcilePaused(ctx context.Context, asoManagedCluster *infrav1.AzureASOManagedCluster) (ctrl.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedClusterReconciler.reconcilePaused") defer done() log.V(4).Info("reconciling pause") @@ -293,7 +293,7 @@ func (r *AzureASOManagedClusterReconciler) reconcilePaused(ctx context.Context, return ctrl.Result{}, nil } -func (r *AzureASOManagedClusterReconciler) reconcileDelete(ctx context.Context, asoManagedCluster *infrav1alpha.AzureASOManagedCluster) (ctrl.Result, error) { +func (r *AzureASOManagedClusterReconciler) reconcileDelete(ctx context.Context, asoManagedCluster *infrav1.AzureASOManagedCluster) (ctrl.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedClusterReconciler.reconcileDelete", ) diff --git a/controllers/azureasomanagedcluster_controller_test.go b/controllers/azureasomanagedcluster_controller_test.go index a1c16e2b9b5..fa82a4de3fb 100644 --- a/controllers/azureasomanagedcluster_controller_test.go +++ b/controllers/azureasomanagedcluster_controller_test.go @@ -34,7 +34,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) type fakeResourceReconciler struct { @@ -70,7 +70,7 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { s := runtime.NewScheme() sb := runtime.NewSchemeBuilder( - infrav1alpha.AddToScheme, + infrav1.AddToScheme, clusterv1.AddToScheme, ) NewGomegaWithT(t).Expect(sb.AddToScheme(s)).To(Succeed()) @@ -78,7 +78,7 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { fakeClientBuilder := func() *fakeclient.ClientBuilder { return fakeclient.NewClientBuilder(). WithScheme(s). - WithStatusSubresource(&infrav1alpha.AzureASOManagedCluster{}) + WithStatusSubresource(&infrav1.AzureASOManagedCluster{}) } t.Run("AzureASOManagedCluster does not exist", func(t *testing.T) { @@ -97,7 +97,7 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { t.Run("Cluster does not exist", func(t *testing.T) { g := NewGomegaWithT(t) - asoManagedCluster := &infrav1alpha.AzureASOManagedCluster{ + asoManagedCluster := &infrav1.AzureASOManagedCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "amc", Namespace: "ns", @@ -131,11 +131,11 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { Spec: clusterv1.ClusterSpec{ ControlPlaneRef: &corev1.ObjectReference{ APIVersion: "infrastructure.cluster.x-k8s.io/v1somethingelse", - Kind: infrav1alpha.AzureASOManagedControlPlaneKind, + Kind: infrav1.AzureASOManagedControlPlaneKind, }, }, } - asoManagedCluster := &infrav1alpha.AzureASOManagedCluster{ + asoManagedCluster := &infrav1.AzureASOManagedCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "amc", Namespace: cluster.Namespace, @@ -173,12 +173,12 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { }, Spec: clusterv1.ClusterSpec{ ControlPlaneRef: &corev1.ObjectReference{ - APIVersion: infrav1alpha.GroupVersion.Identifier(), - Kind: infrav1alpha.AzureASOManagedControlPlaneKind, + APIVersion: infrav1.GroupVersion.Identifier(), + Kind: infrav1.AzureASOManagedControlPlaneKind, }, }, } - asoManagedCluster := &infrav1alpha.AzureASOManagedCluster{ + asoManagedCluster := &infrav1.AzureASOManagedCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "amc", Namespace: cluster.Namespace, @@ -196,7 +196,7 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { clusterctlv1.BlockMoveAnnotation: "true", }, }, - Status: infrav1alpha.AzureASOManagedClusterStatus{ + Status: infrav1.AzureASOManagedClusterStatus{ Ready: true, }, } @@ -205,11 +205,11 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { Build() r := &AzureASOManagedClusterReconciler{ Client: c, - newResourceReconciler: func(asoManagedCluster *infrav1alpha.AzureASOManagedCluster, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(asoManagedCluster *infrav1.AzureASOManagedCluster, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ owner: asoManagedCluster, reconcileFunc: func(ctx context.Context, o client.Object) error { - asoManagedCluster.SetResourceStatuses([]infrav1alpha.ResourceStatus{ + asoManagedCluster.SetResourceStatuses([]infrav1.ResourceStatus{ {Ready: true}, {Ready: false}, {Ready: true}, @@ -237,14 +237,14 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { }, Spec: clusterv1.ClusterSpec{ ControlPlaneRef: &corev1.ObjectReference{ - APIVersion: infrav1alpha.GroupVersion.Identifier(), - Kind: infrav1alpha.AzureASOManagedControlPlaneKind, + APIVersion: infrav1.GroupVersion.Identifier(), + Kind: infrav1.AzureASOManagedControlPlaneKind, Name: "amcp", Namespace: "ns", }, }, } - asoManagedCluster := &infrav1alpha.AzureASOManagedCluster{ + asoManagedCluster := &infrav1.AzureASOManagedCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "amc", Namespace: cluster.Namespace, @@ -262,16 +262,16 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { clusterctlv1.BlockMoveAnnotation: "true", }, }, - Status: infrav1alpha.AzureASOManagedClusterStatus{ + Status: infrav1.AzureASOManagedClusterStatus{ Ready: false, }, } - asoManagedControlPlane := &infrav1alpha.AzureASOManagedControlPlane{ + asoManagedControlPlane := &infrav1.AzureASOManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "amcp", Namespace: cluster.Namespace, }, - Status: infrav1alpha.AzureASOManagedControlPlaneStatus{ + Status: infrav1.AzureASOManagedControlPlaneStatus{ ControlPlaneEndpoint: clusterv1.APIEndpoint{Host: "endpoint"}, }, } @@ -280,7 +280,7 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { Build() r := &AzureASOManagedClusterReconciler{ Client: c, - newResourceReconciler: func(_ *infrav1alpha.AzureASOManagedCluster, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(_ *infrav1.AzureASOManagedCluster, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ reconcileFunc: func(ctx context.Context, o client.Object) error { return nil @@ -309,7 +309,7 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { Paused: true, }, } - asoManagedCluster := &infrav1alpha.AzureASOManagedCluster{ + asoManagedCluster := &infrav1.AzureASOManagedCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "amc", Namespace: cluster.Namespace, @@ -330,7 +330,7 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { Build() r := &AzureASOManagedClusterReconciler{ Client: c, - newResourceReconciler: func(_ *infrav1alpha.AzureASOManagedCluster, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(_ *infrav1.AzureASOManagedCluster, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ pauseFunc: func(_ context.Context, _ client.Object) error { return nil @@ -349,7 +349,7 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { t.Run("successfully reconciles in-progress delete", func(t *testing.T) { g := NewGomegaWithT(t) - asoManagedCluster := &infrav1alpha.AzureASOManagedCluster{ + asoManagedCluster := &infrav1.AzureASOManagedCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "amc", Namespace: "ns", @@ -364,13 +364,13 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { Build() r := &AzureASOManagedClusterReconciler{ Client: c, - newResourceReconciler: func(asoManagedCluster *infrav1alpha.AzureASOManagedCluster, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(asoManagedCluster *infrav1.AzureASOManagedCluster, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ owner: asoManagedCluster, deleteFunc: func(ctx context.Context, o client.Object) error { - asoManagedCluster.SetResourceStatuses([]infrav1alpha.ResourceStatus{ + asoManagedCluster.SetResourceStatuses([]infrav1.ResourceStatus{ { - Resource: infrav1alpha.StatusResource{ + Resource: infrav1.StatusResource{ Name: "still-deleting", }, }, @@ -392,7 +392,7 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { t.Run("successfully reconciles finished delete", func(t *testing.T) { g := NewGomegaWithT(t) - asoManagedCluster := &infrav1alpha.AzureASOManagedCluster{ + asoManagedCluster := &infrav1.AzureASOManagedCluster{ ObjectMeta: metav1.ObjectMeta{ Name: "amc", Namespace: "ns", @@ -407,7 +407,7 @@ func TestAzureASOManagedClusterReconcile(t *testing.T) { Build() r := &AzureASOManagedClusterReconciler{ Client: c, - newResourceReconciler: func(_ *infrav1alpha.AzureASOManagedCluster, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(_ *infrav1.AzureASOManagedCluster, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ deleteFunc: func(ctx context.Context, o client.Object) error { return nil diff --git a/controllers/azureasomanagedcontrolplane_controller.go b/controllers/azureasomanagedcontrolplane_controller.go index fca1b70c8cf..5063ae025d4 100644 --- a/controllers/azureasomanagedcontrolplane_controller.go +++ b/controllers/azureasomanagedcontrolplane_controller.go @@ -45,7 +45,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/pkg/mutators" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -58,20 +58,20 @@ type AzureASOManagedControlPlaneReconciler struct { WatchFilterValue string CredentialCache ASOCredentialCache - newResourceReconciler func(*infrav1alpha.AzureASOManagedControlPlane, []*unstructured.Unstructured) resourceReconciler + newResourceReconciler func(*infrav1.AzureASOManagedControlPlane, []*unstructured.Unstructured) resourceReconciler } // SetupWithManager sets up the controller with the Manager. func (r *AzureASOManagedControlPlaneReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { _, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedControlPlaneReconciler.SetupWithManager", - tele.KVP("controller", infrav1alpha.AzureASOManagedControlPlaneKind), + tele.KVP("controller", infrav1.AzureASOManagedControlPlaneKind), ) defer done() c, err := ctrl.NewControllerManagedBy(mgr). WithOptions(options). - For(&infrav1alpha.AzureASOManagedControlPlane{}). + For(&infrav1.AzureASOManagedControlPlane{}). WithEventFilter(predicates.ResourceHasFilterLabel(mgr.GetScheme(), log, r.WatchFilterValue)). Watches(&clusterv1.Cluster{}, handler.EnqueueRequestsFromMapFunc(clusterToAzureASOManagedControlPlane), @@ -83,7 +83,7 @@ func (r *AzureASOManagedControlPlaneReconciler) SetupWithManager(ctx context.Con // User errors that CAPZ passes through agentPoolProfiles on create must be fixed in the // AzureASOManagedMachinePool, so trigger a reconciliation to consume those fixes. Watches( - &infrav1alpha.AzureASOManagedMachinePool{}, + &infrav1.AzureASOManagedMachinePool{}, handler.EnqueueRequestsFromMapFunc(r.azureASOManagedMachinePoolToAzureASOManagedControlPlane), ). Owns(&corev1.Secret{}). @@ -99,7 +99,7 @@ func (r *AzureASOManagedControlPlaneReconciler) SetupWithManager(ctx context.Con PredicateLogger: &log, } - r.newResourceReconciler = func(asoManagedCluster *infrav1alpha.AzureASOManagedControlPlane, resources []*unstructured.Unstructured) resourceReconciler { + r.newResourceReconciler = func(asoManagedCluster *infrav1.AzureASOManagedControlPlane, resources []*unstructured.Unstructured) resourceReconciler { return &ResourceReconciler{ Client: r.Client, resources: resources, @@ -115,14 +115,14 @@ func clusterToAzureASOManagedControlPlane(_ context.Context, o client.Object) [] controlPlaneRef := o.(*clusterv1.Cluster).Spec.ControlPlaneRef if controlPlaneRef != nil && matchesASOManagedAPIGroup(controlPlaneRef.APIVersion) && - controlPlaneRef.Kind == infrav1alpha.AzureASOManagedControlPlaneKind { + controlPlaneRef.Kind == infrav1.AzureASOManagedControlPlaneKind { return []ctrl.Request{{NamespacedName: client.ObjectKey{Namespace: controlPlaneRef.Namespace, Name: controlPlaneRef.Name}}} } return nil } func (r *AzureASOManagedControlPlaneReconciler) azureASOManagedMachinePoolToAzureASOManagedControlPlane(ctx context.Context, o client.Object) []ctrl.Request { - asoManagedMachinePool := o.(*infrav1alpha.AzureASOManagedMachinePool) + asoManagedMachinePool := o.(*infrav1.AzureASOManagedMachinePool) clusterName := asoManagedMachinePool.Labels[clusterv1.ClusterNameLabel] if clusterName == "" { return nil @@ -144,11 +144,11 @@ func (r *AzureASOManagedControlPlaneReconciler) Reconcile(ctx context.Context, r "controllers.AzureASOManagedControlPlaneReconciler.Reconcile", tele.KVP("namespace", req.Namespace), tele.KVP("name", req.Name), - tele.KVP("kind", infrav1alpha.AzureASOManagedControlPlaneKind), + tele.KVP("kind", infrav1.AzureASOManagedControlPlaneKind), ) defer done() - asoManagedControlPlane := &infrav1alpha.AzureASOManagedControlPlane{} + asoManagedControlPlane := &infrav1.AzureASOManagedControlPlane{} err := r.Get(ctx, req.NamespacedName, asoManagedControlPlane) if err != nil { return ctrl.Result{}, client.IgnoreNotFound(err) @@ -186,7 +186,7 @@ func (r *AzureASOManagedControlPlaneReconciler) Reconcile(ctx context.Context, r return r.reconcileNormal(ctx, asoManagedControlPlane, cluster) } -func (r *AzureASOManagedControlPlaneReconciler) reconcileNormal(ctx context.Context, asoManagedControlPlane *infrav1alpha.AzureASOManagedControlPlane, cluster *clusterv1.Cluster) (ctrl.Result, error) { +func (r *AzureASOManagedControlPlaneReconciler) reconcileNormal(ctx context.Context, asoManagedControlPlane *infrav1.AzureASOManagedControlPlane, cluster *clusterv1.Cluster) (ctrl.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedControlPlaneReconciler.reconcileNormal", ) @@ -199,11 +199,11 @@ func (r *AzureASOManagedControlPlaneReconciler) reconcileNormal(ctx context.Cont } if cluster.Spec.InfrastructureRef == nil || !matchesASOManagedAPIGroup(cluster.Spec.InfrastructureRef.APIVersion) || - cluster.Spec.InfrastructureRef.Kind != infrav1alpha.AzureASOManagedClusterKind { + cluster.Spec.InfrastructureRef.Kind != infrav1.AzureASOManagedClusterKind { return ctrl.Result{}, reconcile.TerminalError(errInvalidClusterKind) } - needsPatch := controllerutil.AddFinalizer(asoManagedControlPlane, infrav1alpha.AzureASOManagedControlPlaneFinalizer) + needsPatch := controllerutil.AddFinalizer(asoManagedControlPlane, infrav1.AzureASOManagedControlPlaneFinalizer) needsPatch = AddBlockMoveAnnotation(asoManagedControlPlane) || needsPatch if needsPatch { return ctrl.Result{Requeue: true}, nil @@ -266,7 +266,7 @@ func (r *AzureASOManagedControlPlaneReconciler) reconcileNormal(ctx context.Cont return result, nil } -func (r *AzureASOManagedControlPlaneReconciler) reconcileKubeconfig(ctx context.Context, asoManagedControlPlane *infrav1alpha.AzureASOManagedControlPlane, cluster *clusterv1.Cluster, managedCluster *asocontainerservicev1.ManagedCluster) (*time.Duration, error) { +func (r *AzureASOManagedControlPlaneReconciler) reconcileKubeconfig(ctx context.Context, asoManagedControlPlane *infrav1.AzureASOManagedControlPlane, cluster *clusterv1.Cluster, managedCluster *asocontainerservicev1.ManagedCluster) (*time.Duration, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedControlPlaneReconciler.reconcileKubeconfig", ) @@ -336,7 +336,7 @@ func (r *AzureASOManagedControlPlaneReconciler) reconcileKubeconfig(ctx context. Name: secret.Name(cluster.Name, secret.Kubeconfig), Namespace: cluster.Namespace, OwnerReferences: []metav1.OwnerReference{ - *metav1.NewControllerRef(asoManagedControlPlane, infrav1alpha.GroupVersion.WithKind(infrav1alpha.AzureASOManagedControlPlaneKind)), + *metav1.NewControllerRef(asoManagedControlPlane, infrav1.GroupVersion.WithKind(infrav1.AzureASOManagedControlPlaneKind)), }, Labels: map[string]string{clusterv1.ClusterNameLabel: cluster.Name}, }, @@ -352,7 +352,7 @@ func (r *AzureASOManagedControlPlaneReconciler) reconcileKubeconfig(ctx context. return tokenExpiresIn, nil } -func (r *AzureASOManagedControlPlaneReconciler) reconcilePaused(ctx context.Context, asoManagedControlPlane *infrav1alpha.AzureASOManagedControlPlane) (ctrl.Result, error) { +func (r *AzureASOManagedControlPlaneReconciler) reconcilePaused(ctx context.Context, asoManagedControlPlane *infrav1.AzureASOManagedControlPlane) (ctrl.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedControlPlaneReconciler.reconcilePaused") defer done() log.V(4).Info("reconciling pause") @@ -372,7 +372,7 @@ func (r *AzureASOManagedControlPlaneReconciler) reconcilePaused(ctx context.Cont return ctrl.Result{}, nil } -func (r *AzureASOManagedControlPlaneReconciler) reconcileDelete(ctx context.Context, asoManagedControlPlane *infrav1alpha.AzureASOManagedControlPlane) (ctrl.Result, error) { +func (r *AzureASOManagedControlPlaneReconciler) reconcileDelete(ctx context.Context, asoManagedControlPlane *infrav1.AzureASOManagedControlPlane) (ctrl.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedControlPlaneReconciler.reconcileDelete", ) @@ -392,7 +392,7 @@ func (r *AzureASOManagedControlPlaneReconciler) reconcileDelete(ctx context.Cont return ctrl.Result{}, nil } - controllerutil.RemoveFinalizer(asoManagedControlPlane, infrav1alpha.AzureASOManagedControlPlaneFinalizer) + controllerutil.RemoveFinalizer(asoManagedControlPlane, infrav1.AzureASOManagedControlPlaneFinalizer) return ctrl.Result{}, nil } diff --git a/controllers/azureasomanagedcontrolplane_controller_test.go b/controllers/azureasomanagedcontrolplane_controller_test.go index a531c9d647b..013ef163f71 100644 --- a/controllers/azureasomanagedcontrolplane_controller_test.go +++ b/controllers/azureasomanagedcontrolplane_controller_test.go @@ -43,7 +43,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { @@ -51,7 +51,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { s := runtime.NewScheme() sb := runtime.NewSchemeBuilder( - infrav1alpha.AddToScheme, + infrav1.AddToScheme, clusterv1.AddToScheme, asocontainerservicev1.AddToScheme, corev1.AddToScheme, @@ -60,7 +60,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { fakeClientBuilder := func() *fakeclient.ClientBuilder { return fakeclient.NewClientBuilder(). WithScheme(s). - WithStatusSubresource(&infrav1alpha.AzureASOManagedControlPlane{}) + WithStatusSubresource(&infrav1.AzureASOManagedControlPlane{}) } t.Run("AzureASOManagedControlPlane does not exist", func(t *testing.T) { @@ -79,7 +79,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { t.Run("Cluster does not exist", func(t *testing.T) { g := NewGomegaWithT(t) - asoManagedControlPlane := &infrav1alpha.AzureASOManagedControlPlane{ + asoManagedControlPlane := &infrav1.AzureASOManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "amcp", Namespace: "ns", @@ -113,11 +113,11 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { Spec: clusterv1.ClusterSpec{ InfrastructureRef: &corev1.ObjectReference{ APIVersion: "infrastructure.cluster.x-k8s.io/v1somethingelse", - Kind: infrav1alpha.AzureASOManagedClusterKind, + Kind: infrav1.AzureASOManagedClusterKind, }, }, } - asoManagedControlPlane := &infrav1alpha.AzureASOManagedControlPlane{ + asoManagedControlPlane := &infrav1.AzureASOManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "amcp", Namespace: cluster.Namespace, @@ -141,7 +141,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { g.Expect(result).To(Equal(ctrl.Result{Requeue: true})) g.Expect(c.Get(ctx, client.ObjectKeyFromObject(asoManagedControlPlane), asoManagedControlPlane)).To(Succeed()) - g.Expect(asoManagedControlPlane.GetFinalizers()).To(ContainElement(infrav1alpha.AzureASOManagedControlPlaneFinalizer)) + g.Expect(asoManagedControlPlane.GetFinalizers()).To(ContainElement(infrav1.AzureASOManagedControlPlaneFinalizer)) g.Expect(asoManagedControlPlane.GetAnnotations()).To(HaveKey(clusterctlv1.BlockMoveAnnotation)) }) @@ -155,12 +155,12 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { }, Spec: clusterv1.ClusterSpec{ InfrastructureRef: &corev1.ObjectReference{ - APIVersion: infrav1alpha.GroupVersion.Identifier(), - Kind: infrav1alpha.AzureASOManagedClusterKind, + APIVersion: infrav1.GroupVersion.Identifier(), + Kind: infrav1.AzureASOManagedClusterKind, }, }, } - asoManagedControlPlane := &infrav1alpha.AzureASOManagedControlPlane{ + asoManagedControlPlane := &infrav1.AzureASOManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "amcp", Namespace: cluster.Namespace, @@ -172,14 +172,14 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { }, }, Finalizers: []string{ - infrav1alpha.AzureASOManagedControlPlaneFinalizer, + infrav1.AzureASOManagedControlPlaneFinalizer, }, Annotations: map[string]string{ clusterctlv1.BlockMoveAnnotation: "true", }, }, - Spec: infrav1alpha.AzureASOManagedControlPlaneSpec{ - AzureASOManagedControlPlaneTemplateResourceSpec: infrav1alpha.AzureASOManagedControlPlaneTemplateResourceSpec{ + Spec: infrav1.AzureASOManagedControlPlaneSpec{ + AzureASOManagedControlPlaneTemplateResourceSpec: infrav1.AzureASOManagedControlPlaneTemplateResourceSpec{ Resources: []runtime.RawExtension{ { Raw: mcJSON(g, &asocontainerservicev1.ManagedCluster{ @@ -191,7 +191,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { }, }, }, - Status: infrav1alpha.AzureASOManagedControlPlaneStatus{ + Status: infrav1.AzureASOManagedControlPlaneStatus{ Ready: true, }, } @@ -200,11 +200,11 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { Build() r := &AzureASOManagedControlPlaneReconciler{ Client: c, - newResourceReconciler: func(asoManagedControlPlane *infrav1alpha.AzureASOManagedControlPlane, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(asoManagedControlPlane *infrav1.AzureASOManagedControlPlane, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ owner: asoManagedControlPlane, reconcileFunc: func(ctx context.Context, o client.Object) error { - asoManagedControlPlane.SetResourceStatuses([]infrav1alpha.ResourceStatus{ + asoManagedControlPlane.SetResourceStatuses([]infrav1.ResourceStatus{ {Ready: true}, {Ready: false}, {Ready: true}, @@ -232,8 +232,8 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { }, Spec: clusterv1.ClusterSpec{ InfrastructureRef: &corev1.ObjectReference{ - APIVersion: infrav1alpha.GroupVersion.Identifier(), - Kind: infrav1alpha.AzureASOManagedClusterKind, + APIVersion: infrav1.GroupVersion.Identifier(), + Kind: infrav1.AzureASOManagedClusterKind, }, }, } @@ -266,7 +266,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { CurrentKubernetesVersion: ptr.To("Current"), }, } - asoManagedControlPlane := &infrav1alpha.AzureASOManagedControlPlane{ + asoManagedControlPlane := &infrav1.AzureASOManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "amcp", Namespace: cluster.Namespace, @@ -278,14 +278,14 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { }, }, Finalizers: []string{ - infrav1alpha.AzureASOManagedControlPlaneFinalizer, + infrav1.AzureASOManagedControlPlaneFinalizer, }, Annotations: map[string]string{ clusterctlv1.BlockMoveAnnotation: "true", }, }, - Spec: infrav1alpha.AzureASOManagedControlPlaneSpec{ - AzureASOManagedControlPlaneTemplateResourceSpec: infrav1alpha.AzureASOManagedControlPlaneTemplateResourceSpec{ + Spec: infrav1.AzureASOManagedControlPlaneSpec{ + AzureASOManagedControlPlaneTemplateResourceSpec: infrav1.AzureASOManagedControlPlaneTemplateResourceSpec{ Resources: []runtime.RawExtension{ { Raw: mcJSON(g, &asocontainerservicev1.ManagedCluster{ @@ -297,7 +297,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { }, }, }, - Status: infrav1alpha.AzureASOManagedControlPlaneStatus{ + Status: infrav1.AzureASOManagedControlPlaneStatus{ Ready: false, }, } @@ -315,7 +315,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { return nil }, }, - newResourceReconciler: func(_ *infrav1alpha.AzureASOManagedControlPlane, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(_ *infrav1.AzureASOManagedControlPlane, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ reconcileFunc: func(ctx context.Context, o client.Object) error { return nil @@ -344,8 +344,8 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { }, Spec: clusterv1.ClusterSpec{ InfrastructureRef: &corev1.ObjectReference{ - APIVersion: infrav1alpha.GroupVersion.Identifier(), - Kind: infrav1alpha.AzureASOManagedClusterKind, + APIVersion: infrav1.GroupVersion.Identifier(), + Kind: infrav1.AzureASOManagedClusterKind, }, }, } @@ -392,7 +392,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { DisableLocalAccounts: ptr.To(true), }, } - asoManagedControlPlane := &infrav1alpha.AzureASOManagedControlPlane{ + asoManagedControlPlane := &infrav1.AzureASOManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "amcp", Namespace: cluster.Namespace, @@ -404,14 +404,14 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { }, }, Finalizers: []string{ - infrav1alpha.AzureASOManagedControlPlaneFinalizer, + infrav1.AzureASOManagedControlPlaneFinalizer, }, Annotations: map[string]string{ clusterctlv1.BlockMoveAnnotation: "true", }, }, - Spec: infrav1alpha.AzureASOManagedControlPlaneSpec{ - AzureASOManagedControlPlaneTemplateResourceSpec: infrav1alpha.AzureASOManagedControlPlaneTemplateResourceSpec{ + Spec: infrav1.AzureASOManagedControlPlaneSpec{ + AzureASOManagedControlPlaneTemplateResourceSpec: infrav1.AzureASOManagedControlPlaneTemplateResourceSpec{ Resources: []runtime.RawExtension{ { Raw: mcJSON(g, &asocontainerservicev1.ManagedCluster{ @@ -423,7 +423,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { }, }, }, - Status: infrav1alpha.AzureASOManagedControlPlaneStatus{ + Status: infrav1.AzureASOManagedControlPlaneStatus{ Ready: false, }, } @@ -449,7 +449,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { return nil }, }, - newResourceReconciler: func(_ *infrav1alpha.AzureASOManagedControlPlane, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(_ *infrav1.AzureASOManagedControlPlane, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ reconcileFunc: func(ctx context.Context, o client.Object) error { return nil @@ -480,8 +480,8 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { }, Spec: clusterv1.ClusterSpec{ InfrastructureRef: &corev1.ObjectReference{ - APIVersion: infrav1alpha.GroupVersion.Identifier(), - Kind: infrav1alpha.AzureASOManagedClusterKind, + APIVersion: infrav1.GroupVersion.Identifier(), + Kind: infrav1.AzureASOManagedClusterKind, }, }, } @@ -528,7 +528,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { DisableLocalAccounts: ptr.To(true), }, } - asoManagedControlPlane := &infrav1alpha.AzureASOManagedControlPlane{ + asoManagedControlPlane := &infrav1.AzureASOManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "amcp", Namespace: cluster.Namespace, @@ -540,14 +540,14 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { }, }, Finalizers: []string{ - infrav1alpha.AzureASOManagedControlPlaneFinalizer, + infrav1.AzureASOManagedControlPlaneFinalizer, }, Annotations: map[string]string{ clusterctlv1.BlockMoveAnnotation: "true", }, }, - Spec: infrav1alpha.AzureASOManagedControlPlaneSpec{ - AzureASOManagedControlPlaneTemplateResourceSpec: infrav1alpha.AzureASOManagedControlPlaneTemplateResourceSpec{ + Spec: infrav1.AzureASOManagedControlPlaneSpec{ + AzureASOManagedControlPlaneTemplateResourceSpec: infrav1.AzureASOManagedControlPlaneTemplateResourceSpec{ Resources: []runtime.RawExtension{ { Raw: mcJSON(g, &asocontainerservicev1.ManagedCluster{ @@ -559,7 +559,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { }, }, }, - Status: infrav1alpha.AzureASOManagedControlPlaneStatus{ + Status: infrav1.AzureASOManagedControlPlaneStatus{ Ready: true, }, } @@ -585,7 +585,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { return nil }, }, - newResourceReconciler: func(_ *infrav1alpha.AzureASOManagedControlPlane, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(_ *infrav1.AzureASOManagedControlPlane, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ reconcileFunc: func(ctx context.Context, o client.Object) error { return nil @@ -617,7 +617,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { Paused: true, }, } - asoManagedControlPlane := &infrav1alpha.AzureASOManagedControlPlane{ + asoManagedControlPlane := &infrav1.AzureASOManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "amcp", Namespace: cluster.Namespace, @@ -638,7 +638,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { Build() r := &AzureASOManagedControlPlaneReconciler{ Client: c, - newResourceReconciler: func(_ *infrav1alpha.AzureASOManagedControlPlane, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(_ *infrav1.AzureASOManagedControlPlane, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ pauseFunc: func(_ context.Context, _ client.Object) error { return nil @@ -657,12 +657,12 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { t.Run("successfully reconciles delete", func(t *testing.T) { g := NewGomegaWithT(t) - asoManagedControlPlane := &infrav1alpha.AzureASOManagedControlPlane{ + asoManagedControlPlane := &infrav1.AzureASOManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Name: "amcp", Namespace: "ns", Finalizers: []string{ - infrav1alpha.AzureASOManagedControlPlaneFinalizer, + infrav1.AzureASOManagedControlPlaneFinalizer, }, DeletionTimestamp: &metav1.Time{Time: time.Date(1, 0, 0, 0, 0, 0, 0, time.UTC)}, }, @@ -672,7 +672,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) { Build() r := &AzureASOManagedControlPlaneReconciler{ Client: c, - newResourceReconciler: func(_ *infrav1alpha.AzureASOManagedControlPlane, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(_ *infrav1.AzureASOManagedControlPlane, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ deleteFunc: func(ctx context.Context, o client.Object) error { return nil diff --git a/controllers/azureasomanagedmachinepool_controller.go b/controllers/azureasomanagedmachinepool_controller.go index e212ae3984a..cca0bfb2358 100644 --- a/controllers/azureasomanagedmachinepool_controller.go +++ b/controllers/azureasomanagedmachinepool_controller.go @@ -43,7 +43,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/pkg/mutators" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -54,7 +54,7 @@ type AzureASOManagedMachinePoolReconciler struct { WatchFilterValue string Tracker ClusterTracker - newResourceReconciler func(*infrav1alpha.AzureASOManagedMachinePool, []*unstructured.Unstructured) resourceReconciler + newResourceReconciler func(*infrav1.AzureASOManagedMachinePool, []*unstructured.Unstructured) resourceReconciler } // ClusterTracker wraps a CAPI remote.ClusterCacheTracker. @@ -66,18 +66,18 @@ type ClusterTracker interface { func (r *AzureASOManagedMachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { _, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedMachinePoolReconciler.SetupWithManager", - tele.KVP("controller", infrav1alpha.AzureASOManagedMachinePoolKind), + tele.KVP("controller", infrav1.AzureASOManagedMachinePoolKind), ) defer done() - clusterToAzureASOManagedMachinePools, err := util.ClusterToTypedObjectsMapper(mgr.GetClient(), &infrav1alpha.AzureASOManagedMachinePoolList{}, mgr.GetScheme()) + clusterToAzureASOManagedMachinePools, err := util.ClusterToTypedObjectsMapper(mgr.GetClient(), &infrav1.AzureASOManagedMachinePoolList{}, mgr.GetScheme()) if err != nil { return fmt.Errorf("failed to get Cluster to AzureASOManagedMachinePool mapper: %w", err) } c, err := ctrl.NewControllerManagedBy(mgr). WithOptions(options). - For(&infrav1alpha.AzureASOManagedMachinePool{}). + For(&infrav1.AzureASOManagedMachinePool{}). WithEventFilter(predicates.ResourceHasFilterLabel(mgr.GetScheme(), log, r.WatchFilterValue)). Watches( &clusterv1.Cluster{}, @@ -93,7 +93,7 @@ func (r *AzureASOManagedMachinePoolReconciler) SetupWithManager(ctx context.Cont Watches( &expv1.MachinePool{}, handler.EnqueueRequestsFromMapFunc(utilexp.MachinePoolToInfrastructureMapFunc(ctx, - infrav1alpha.GroupVersion.WithKind(infrav1alpha.AzureASOManagedMachinePoolKind)), + infrav1.GroupVersion.WithKind(infrav1.AzureASOManagedMachinePoolKind)), ), builder.WithPredicates( predicates.ResourceHasFilterLabel(mgr.GetScheme(), log, r.WatchFilterValue), @@ -111,7 +111,7 @@ func (r *AzureASOManagedMachinePoolReconciler) SetupWithManager(ctx context.Cont PredicateLogger: &log, } - r.newResourceReconciler = func(asoManagedCluster *infrav1alpha.AzureASOManagedMachinePool, resources []*unstructured.Unstructured) resourceReconciler { + r.newResourceReconciler = func(asoManagedCluster *infrav1.AzureASOManagedMachinePool, resources []*unstructured.Unstructured) resourceReconciler { return &ResourceReconciler{ Client: r.Client, resources: resources, @@ -133,11 +133,11 @@ func (r *AzureASOManagedMachinePoolReconciler) Reconcile(ctx context.Context, re "controllers.AzureASOManagedMachinePoolReconciler.Reconcile", tele.KVP("namespace", req.Namespace), tele.KVP("name", req.Name), - tele.KVP("kind", infrav1alpha.AzureASOManagedMachinePoolKind), + tele.KVP("kind", infrav1.AzureASOManagedMachinePoolKind), ) defer done() - asoManagedMachinePool := &infrav1alpha.AzureASOManagedMachinePool{} + asoManagedMachinePool := &infrav1.AzureASOManagedMachinePool{} err := r.Get(ctx, req.NamespacedName, asoManagedMachinePool) if err != nil { return ctrl.Result{}, client.IgnoreNotFound(err) @@ -186,7 +186,7 @@ func (r *AzureASOManagedMachinePoolReconciler) Reconcile(ctx context.Context, re } if cluster.Spec.ControlPlaneRef == nil || !matchesASOManagedAPIGroup(cluster.Spec.ControlPlaneRef.APIVersion) || - cluster.Spec.ControlPlaneRef.Kind != infrav1alpha.AzureASOManagedControlPlaneKind { + cluster.Spec.ControlPlaneRef.Kind != infrav1.AzureASOManagedControlPlaneKind { return ctrl.Result{}, reconcile.TerminalError(fmt.Errorf("AzureASOManagedMachinePool cannot be used without AzureASOManagedControlPlane")) } @@ -201,7 +201,7 @@ func (r *AzureASOManagedMachinePoolReconciler) Reconcile(ctx context.Context, re return r.reconcileNormal(ctx, asoManagedMachinePool, machinePool, cluster) } -func (r *AzureASOManagedMachinePoolReconciler) reconcileNormal(ctx context.Context, asoManagedMachinePool *infrav1alpha.AzureASOManagedMachinePool, machinePool *expv1.MachinePool, cluster *clusterv1.Cluster) (ctrl.Result, error) { +func (r *AzureASOManagedMachinePoolReconciler) reconcileNormal(ctx context.Context, asoManagedMachinePool *infrav1.AzureASOManagedMachinePool, machinePool *expv1.MachinePool, cluster *clusterv1.Cluster) (ctrl.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedMachinePoolReconciler.reconcileNormal", ) @@ -303,7 +303,7 @@ func expectedNodeLabels(poolName, nodeRG string) map[string]string { } } -func (r *AzureASOManagedMachinePoolReconciler) reconcilePaused(ctx context.Context, asoManagedMachinePool *infrav1alpha.AzureASOManagedMachinePool) (ctrl.Result, error) { +func (r *AzureASOManagedMachinePoolReconciler) reconcilePaused(ctx context.Context, asoManagedMachinePool *infrav1.AzureASOManagedMachinePool) (ctrl.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedMachinePoolReconciler.reconcilePaused") defer done() log.V(4).Info("reconciling pause") @@ -323,7 +323,7 @@ func (r *AzureASOManagedMachinePoolReconciler) reconcilePaused(ctx context.Conte return ctrl.Result{}, nil } -func (r *AzureASOManagedMachinePoolReconciler) reconcileDelete(ctx context.Context, asoManagedMachinePool *infrav1alpha.AzureASOManagedMachinePool, cluster *clusterv1.Cluster) (ctrl.Result, error) { +func (r *AzureASOManagedMachinePoolReconciler) reconcileDelete(ctx context.Context, asoManagedMachinePool *infrav1.AzureASOManagedMachinePool, cluster *clusterv1.Cluster) (ctrl.Result, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.AzureASOManagedMachinePoolReconciler.reconcileDelete", ) diff --git a/controllers/azureasomanagedmachinepool_controller_test.go b/controllers/azureasomanagedmachinepool_controller_test.go index 497d1269bb5..3b915a27f91 100644 --- a/controllers/azureasomanagedmachinepool_controller_test.go +++ b/controllers/azureasomanagedmachinepool_controller_test.go @@ -38,7 +38,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) type FakeClusterTracker struct { @@ -57,7 +57,7 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { s := runtime.NewScheme() sb := runtime.NewSchemeBuilder( - infrav1alpha.AddToScheme, + infrav1.AddToScheme, clusterv1.AddToScheme, expv1.AddToScheme, asocontainerservicev1.AddToScheme, @@ -66,7 +66,7 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { fakeClientBuilder := func() *fakeclient.ClientBuilder { return fakeclient.NewClientBuilder(). WithScheme(s). - WithStatusSubresource(&infrav1alpha.AzureASOManagedMachinePool{}) + WithStatusSubresource(&infrav1.AzureASOManagedMachinePool{}) } t.Run("AzureASOManagedMachinePool does not exist", func(t *testing.T) { @@ -85,7 +85,7 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { t.Run("MachinePool does not exist", func(t *testing.T) { g := NewGomegaWithT(t) - asoManagedMachinePool := &infrav1alpha.AzureASOManagedMachinePool{ + asoManagedMachinePool := &infrav1.AzureASOManagedMachinePool{ ObjectMeta: metav1.ObjectMeta{ Name: "ammp", Namespace: "ns", @@ -113,7 +113,7 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { t.Run("Cluster does not exist", func(t *testing.T) { g := NewGomegaWithT(t) - asoManagedMachinePool := &infrav1alpha.AzureASOManagedMachinePool{ + asoManagedMachinePool := &infrav1.AzureASOManagedMachinePool{ ObjectMeta: metav1.ObjectMeta{ Name: "ammp", Namespace: "ns", @@ -158,11 +158,11 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { Spec: clusterv1.ClusterSpec{ ControlPlaneRef: &corev1.ObjectReference{ APIVersion: "infrastructure.cluster.x-k8s.io/v1somethingelse", - Kind: infrav1alpha.AzureASOManagedControlPlaneKind, + Kind: infrav1.AzureASOManagedControlPlaneKind, }, }, } - asoManagedMachinePool := &infrav1alpha.AzureASOManagedMachinePool{ + asoManagedMachinePool := &infrav1.AzureASOManagedMachinePool{ ObjectMeta: metav1.ObjectMeta{ Name: "ammp", Namespace: cluster.Namespace, @@ -209,12 +209,12 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { }, Spec: clusterv1.ClusterSpec{ ControlPlaneRef: &corev1.ObjectReference{ - APIVersion: infrav1alpha.GroupVersion.Identifier(), - Kind: infrav1alpha.AzureASOManagedControlPlaneKind, + APIVersion: infrav1.GroupVersion.Identifier(), + Kind: infrav1.AzureASOManagedControlPlaneKind, }, }, } - asoManagedMachinePool := &infrav1alpha.AzureASOManagedMachinePool{ + asoManagedMachinePool := &infrav1.AzureASOManagedMachinePool{ ObjectMeta: metav1.ObjectMeta{ Name: "ammp", Namespace: cluster.Namespace, @@ -232,8 +232,8 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { clusterctlv1.BlockMoveAnnotation: "true", }, }, - Spec: infrav1alpha.AzureASOManagedMachinePoolSpec{ - AzureASOManagedMachinePoolTemplateResourceSpec: infrav1alpha.AzureASOManagedMachinePoolTemplateResourceSpec{ + Spec: infrav1.AzureASOManagedMachinePoolSpec{ + AzureASOManagedMachinePoolTemplateResourceSpec: infrav1.AzureASOManagedMachinePoolTemplateResourceSpec{ Resources: []runtime.RawExtension{ { Raw: apJSON(g, &asocontainerservicev1.ManagedClustersAgentPool{ @@ -245,7 +245,7 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { }, }, }, - Status: infrav1alpha.AzureASOManagedMachinePoolStatus{ + Status: infrav1.AzureASOManagedMachinePoolStatus{ Ready: true, }, } @@ -263,11 +263,11 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { Build() r := &AzureASOManagedMachinePoolReconciler{ Client: c, - newResourceReconciler: func(asoManagedMachinePool *infrav1alpha.AzureASOManagedMachinePool, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(asoManagedMachinePool *infrav1.AzureASOManagedMachinePool, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ owner: asoManagedMachinePool, reconcileFunc: func(ctx context.Context, o client.Object) error { - asoManagedMachinePool.SetResourceStatuses([]infrav1alpha.ResourceStatus{ + asoManagedMachinePool.SetResourceStatuses([]infrav1.ResourceStatus{ {Ready: true}, {Ready: false}, {Ready: true}, @@ -295,8 +295,8 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { }, Spec: clusterv1.ClusterSpec{ ControlPlaneRef: &corev1.ObjectReference{ - APIVersion: infrav1alpha.GroupVersion.Identifier(), - Kind: infrav1alpha.AzureASOManagedControlPlaneKind, + APIVersion: infrav1.GroupVersion.Identifier(), + Kind: infrav1.AzureASOManagedControlPlaneKind, }, }, } @@ -324,7 +324,7 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { Count: ptr.To(3), }, } - asoManagedMachinePool := &infrav1alpha.AzureASOManagedMachinePool{ + asoManagedMachinePool := &infrav1.AzureASOManagedMachinePool{ ObjectMeta: metav1.ObjectMeta{ Name: "ammp", Namespace: cluster.Namespace, @@ -342,8 +342,8 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { clusterctlv1.BlockMoveAnnotation: "true", }, }, - Spec: infrav1alpha.AzureASOManagedMachinePoolSpec{ - AzureASOManagedMachinePoolTemplateResourceSpec: infrav1alpha.AzureASOManagedMachinePoolTemplateResourceSpec{ + Spec: infrav1.AzureASOManagedMachinePoolSpec{ + AzureASOManagedMachinePoolTemplateResourceSpec: infrav1.AzureASOManagedMachinePoolTemplateResourceSpec{ Resources: []runtime.RawExtension{ { Raw: apJSON(g, asoAgentPool), @@ -351,7 +351,7 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { }, }, }, - Status: infrav1alpha.AzureASOManagedMachinePoolStatus{ + Status: infrav1.AzureASOManagedMachinePoolStatus{ Ready: false, }, } @@ -372,7 +372,7 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { Build() r := &AzureASOManagedMachinePoolReconciler{ Client: c, - newResourceReconciler: func(_ *infrav1alpha.AzureASOManagedMachinePool, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(_ *infrav1.AzureASOManagedMachinePool, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ reconcileFunc: func(ctx context.Context, o client.Object) error { return nil @@ -437,8 +437,8 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { }, Spec: clusterv1.ClusterSpec{ ControlPlaneRef: &corev1.ObjectReference{ - APIVersion: infrav1alpha.GroupVersion.Identifier(), - Kind: infrav1alpha.AzureASOManagedControlPlaneKind, + APIVersion: infrav1.GroupVersion.Identifier(), + Kind: infrav1.AzureASOManagedControlPlaneKind, }, }, } @@ -467,7 +467,7 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { Count: ptr.To(3), }, } - asoManagedMachinePool := &infrav1alpha.AzureASOManagedMachinePool{ + asoManagedMachinePool := &infrav1.AzureASOManagedMachinePool{ ObjectMeta: metav1.ObjectMeta{ Name: "ammp", Namespace: cluster.Namespace, @@ -485,8 +485,8 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { clusterctlv1.BlockMoveAnnotation: "true", }, }, - Spec: infrav1alpha.AzureASOManagedMachinePoolSpec{ - AzureASOManagedMachinePoolTemplateResourceSpec: infrav1alpha.AzureASOManagedMachinePoolTemplateResourceSpec{ + Spec: infrav1.AzureASOManagedMachinePoolSpec{ + AzureASOManagedMachinePoolTemplateResourceSpec: infrav1.AzureASOManagedMachinePoolTemplateResourceSpec{ Resources: []runtime.RawExtension{ { Raw: apJSON(g, asoAgentPool), @@ -494,7 +494,7 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { }, }, }, - Status: infrav1alpha.AzureASOManagedMachinePoolStatus{ + Status: infrav1.AzureASOManagedMachinePoolStatus{ Ready: false, }, } @@ -512,7 +512,7 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { Build() r := &AzureASOManagedMachinePoolReconciler{ Client: c, - newResourceReconciler: func(_ *infrav1alpha.AzureASOManagedMachinePool, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(_ *infrav1.AzureASOManagedMachinePool, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ reconcileFunc: func(ctx context.Context, o client.Object) error { return nil @@ -548,12 +548,12 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { Spec: clusterv1.ClusterSpec{ Paused: true, ControlPlaneRef: &corev1.ObjectReference{ - APIVersion: infrav1alpha.GroupVersion.Identifier(), - Kind: infrav1alpha.AzureASOManagedControlPlaneKind, + APIVersion: infrav1.GroupVersion.Identifier(), + Kind: infrav1.AzureASOManagedControlPlaneKind, }, }, } - asoManagedMachinePool := &infrav1alpha.AzureASOManagedMachinePool{ + asoManagedMachinePool := &infrav1.AzureASOManagedMachinePool{ ObjectMeta: metav1.ObjectMeta{ Name: "ammp", Namespace: cluster.Namespace, @@ -583,7 +583,7 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { Build() r := &AzureASOManagedMachinePoolReconciler{ Client: c, - newResourceReconciler: func(_ *infrav1alpha.AzureASOManagedMachinePool, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(_ *infrav1.AzureASOManagedMachinePool, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ pauseFunc: func(_ context.Context, _ client.Object) error { return nil @@ -609,12 +609,12 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { }, Spec: clusterv1.ClusterSpec{ ControlPlaneRef: &corev1.ObjectReference{ - APIVersion: infrav1alpha.GroupVersion.Identifier(), - Kind: infrav1alpha.AzureASOManagedControlPlaneKind, + APIVersion: infrav1.GroupVersion.Identifier(), + Kind: infrav1.AzureASOManagedControlPlaneKind, }, }, } - asoManagedMachinePool := &infrav1alpha.AzureASOManagedMachinePool{ + asoManagedMachinePool := &infrav1.AzureASOManagedMachinePool{ ObjectMeta: metav1.ObjectMeta{ Name: "ammp", Namespace: cluster.Namespace, @@ -645,7 +645,7 @@ func TestAzureASOManagedMachinePoolReconcile(t *testing.T) { Build() r := &AzureASOManagedMachinePoolReconciler{ Client: c, - newResourceReconciler: func(_ *infrav1alpha.AzureASOManagedMachinePool, _ []*unstructured.Unstructured) resourceReconciler { + newResourceReconciler: func(_ *infrav1.AzureASOManagedMachinePool, _ []*unstructured.Unstructured) resourceReconciler { return &fakeResourceReconciler{ deleteFunc: func(ctx context.Context, o client.Object) error { return nil diff --git a/controllers/managedclusteradopt_controller.go b/controllers/managedclusteradopt_controller.go index a0bbddb1473..ee28ad5efcd 100644 --- a/controllers/managedclusteradopt_controller.go +++ b/controllers/managedclusteradopt_controller.go @@ -32,7 +32,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -89,7 +89,7 @@ func (r *ManagedClusterAdoptReconciler) Reconcile(ctx context.Context, req ctrl. for _, owner := range managedCluster.GetOwnerReferences() { if matchesASOManagedAPIGroup(owner.APIVersion) && - owner.Kind == infrav1alpha.AzureASOManagedControlPlaneKind { + owner.Kind == infrav1.AzureASOManagedControlPlaneKind { return ctrl.Result{}, nil } } @@ -103,13 +103,13 @@ func (r *ManagedClusterAdoptReconciler) Reconcile(ctx context.Context, req ctrl. }, Spec: clusterv1.ClusterSpec{ InfrastructureRef: &corev1.ObjectReference{ - APIVersion: infrav1alpha.GroupVersion.Identifier(), - Kind: infrav1alpha.AzureASOManagedClusterKind, + APIVersion: infrav1.GroupVersion.Identifier(), + Kind: infrav1.AzureASOManagedClusterKind, Name: managedCluster.Name, }, ControlPlaneRef: &corev1.ObjectReference{ - APIVersion: infrav1alpha.GroupVersion.Identifier(), - Kind: infrav1alpha.AzureASOManagedControlPlaneKind, + APIVersion: infrav1.GroupVersion.Identifier(), + Kind: infrav1.AzureASOManagedControlPlaneKind, Name: managedCluster.Name, }, }, @@ -143,13 +143,13 @@ func (r *ManagedClusterAdoptReconciler) Reconcile(ctx context.Context, req ctrl. Spec: resourceGroup.Spec, } - asoManagedCluster := &infrav1alpha.AzureASOManagedCluster{ + asoManagedCluster := &infrav1.AzureASOManagedCluster{ ObjectMeta: metav1.ObjectMeta{ Namespace: managedCluster.Namespace, Name: managedCluster.Name, }, - Spec: infrav1alpha.AzureASOManagedClusterSpec{ - AzureASOManagedClusterTemplateResourceSpec: infrav1alpha.AzureASOManagedClusterTemplateResourceSpec{ + Spec: infrav1.AzureASOManagedClusterSpec{ + AzureASOManagedClusterTemplateResourceSpec: infrav1.AzureASOManagedClusterTemplateResourceSpec{ Resources: []runtime.RawExtension{ {Object: resourceGroup}, }, @@ -180,13 +180,13 @@ func (r *ManagedClusterAdoptReconciler) Reconcile(ctx context.Context, req ctrl. Spec: managedCluster.Spec, } - asoManagedControlPlane := &infrav1alpha.AzureASOManagedControlPlane{ + asoManagedControlPlane := &infrav1.AzureASOManagedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Namespace: cluster.Namespace, Name: managedCluster.Name, }, - Spec: infrav1alpha.AzureASOManagedControlPlaneSpec{ - AzureASOManagedControlPlaneTemplateResourceSpec: infrav1alpha.AzureASOManagedControlPlaneTemplateResourceSpec{ + Spec: infrav1.AzureASOManagedControlPlaneSpec{ + AzureASOManagedControlPlaneTemplateResourceSpec: infrav1.AzureASOManagedControlPlaneTemplateResourceSpec{ Resources: []runtime.RawExtension{ {Object: managedCluster}, }, diff --git a/controllers/managedclusteradopt_controller_test.go b/controllers/managedclusteradopt_controller_test.go index 58245a0ecf6..de8487036fd 100644 --- a/controllers/managedclusteradopt_controller_test.go +++ b/controllers/managedclusteradopt_controller_test.go @@ -31,7 +31,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" - "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) func TestManagedClusterAdoptReconcile(t *testing.T) { @@ -72,7 +72,7 @@ func TestManagedClusterAdoptReconcile(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) err = asoresourcesv1.AddToScheme(s) g.Expect(err).ToNot(HaveOccurred()) - err = v1alpha1.AddToScheme(s) + err = infrav1.AddToScheme(s) g.Expect(err).ToNot(HaveOccurred()) client := fake.NewClientBuilder().WithScheme(s).WithObjects(managedCluster, rg).Build() rec := ManagedClusterAdoptReconciler{ @@ -80,10 +80,10 @@ func TestManagedClusterAdoptReconcile(t *testing.T) { } _, err = rec.Reconcile(ctx, req) g.Expect(err).ToNot(HaveOccurred()) - mcp := &v1alpha1.AzureASOManagedControlPlane{} + mcp := &infrav1.AzureASOManagedControlPlane{} err = rec.Get(ctx, types.NamespacedName{Name: managedCluster.Name, Namespace: managedCluster.Namespace}, mcp) g.Expect(err).ToNot(HaveOccurred()) - asomc := &v1alpha1.AzureASOManagedCluster{} + asomc := &infrav1.AzureASOManagedCluster{} err = rec.Get(ctx, types.NamespacedName{Name: managedCluster.Name, Namespace: managedCluster.Namespace}, asomc) g.Expect(err).ToNot(HaveOccurred()) } diff --git a/controllers/resource_reconciler.go b/controllers/resource_reconciler.go index 36a29952e0c..bd5e8ee0b16 100644 --- a/controllers/resource_reconciler.go +++ b/controllers/resource_reconciler.go @@ -34,7 +34,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/pkg/mutators" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -53,8 +53,8 @@ type watcher interface { type resourceStatusObject interface { client.Object - GetResourceStatuses() []infrav1alpha.ResourceStatus - SetResourceStatuses([]infrav1alpha.ResourceStatus) + GetResourceStatuses() []infrav1.ResourceStatus + SetResourceStatuses([]infrav1.ResourceStatus) } // Reconcile creates or updates the specified resources. @@ -63,7 +63,7 @@ func (r *ResourceReconciler) Reconcile(ctx context.Context) error { defer done() log.V(4).Info("reconciling resources") - var newResourceStatuses []infrav1alpha.ResourceStatus + var newResourceStatuses []infrav1.ResourceStatus for _, spec := range r.resources { gvk := spec.GroupVersionKind() @@ -89,8 +89,8 @@ func (r *ResourceReconciler) Reconcile(ctx context.Context) error { if err != nil { return fmt.Errorf("failed to get ready status: %w", err) } - newResourceStatuses = append(newResourceStatuses, infrav1alpha.ResourceStatus{ - Resource: infrav1alpha.StatusResource{ + newResourceStatuses = append(newResourceStatuses, infrav1.ResourceStatus{ + Resource: infrav1.StatusResource{ Group: gvk.Group, Version: gvk.Version, Kind: gvk.Kind, @@ -163,7 +163,7 @@ func (r *ResourceReconciler) Delete(ctx context.Context) error { defer done() log.V(4).Info("deleting resources") - var newResourceStatuses []infrav1alpha.ResourceStatus + var newResourceStatuses []infrav1.ResourceStatus for _, spec := range r.owner.GetResourceStatuses() { newStatus, err := r.deleteResource(ctx, spec.Resource) @@ -180,7 +180,7 @@ func (r *ResourceReconciler) Delete(ctx context.Context) error { return nil } -func (r *ResourceReconciler) deleteResource(ctx context.Context, resource infrav1alpha.StatusResource) (*infrav1alpha.ResourceStatus, error) { +func (r *ResourceReconciler) deleteResource(ctx context.Context, resource infrav1.StatusResource) (*infrav1.ResourceStatus, error) { ctx, log, done := tele.StartSpanWithLogger(ctx, "controllers.ResourceReconciler.deleteResource") defer done() @@ -214,7 +214,7 @@ func (r *ResourceReconciler) deleteResource(ctx context.Context, resource infrav return nil, fmt.Errorf("failed to get ready status: %w", err) } - return &infrav1alpha.ResourceStatus{ + return &infrav1.ResourceStatus{ Resource: resource, Ready: ready, }, nil diff --git a/controllers/resource_reconciler_test.go b/controllers/resource_reconciler_test.go index 2b51f72aeaf..1135ff5c6cf 100644 --- a/controllers/resource_reconciler_test.go +++ b/controllers/resource_reconciler_test.go @@ -34,7 +34,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/predicate" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) type FakeClient struct { @@ -69,7 +69,7 @@ func TestResourceReconcilerReconcile(t *testing.T) { s := runtime.NewScheme() sb := runtime.NewSchemeBuilder( - infrav1alpha.AddToScheme, + infrav1.AddToScheme, asoresourcesv1.AddToScheme, ) NewGomegaWithT(t).Expect(sb.AddToScheme(s)).To(Succeed()) @@ -77,7 +77,7 @@ func TestResourceReconcilerReconcile(t *testing.T) { fakeClientBuilder := func() *fakeclient.ClientBuilder { return fakeclient.NewClientBuilder(). WithScheme(s). - WithStatusSubresource(&infrav1alpha.AzureASOManagedCluster{}) + WithStatusSubresource(&infrav1.AzureASOManagedCluster{}) } t.Run("empty resources", func(t *testing.T) { @@ -85,7 +85,7 @@ func TestResourceReconcilerReconcile(t *testing.T) { r := &ResourceReconciler{ resources: []*unstructured.Unstructured{}, - owner: &infrav1alpha.AzureASOManagedCluster{}, + owner: &infrav1.AzureASOManagedCluster{}, } g.Expect(r.Reconcile(ctx)).To(Succeed()) @@ -98,7 +98,7 @@ func TestResourceReconcilerReconcile(t *testing.T) { c := fakeClientBuilder(). Build() - asoManagedCluster := &infrav1alpha.AzureASOManagedCluster{} + asoManagedCluster := &infrav1.AzureASOManagedCluster{} unpatchedRGs := map[string]struct{}{ "rg1": {}, @@ -153,9 +153,9 @@ func TestResourceReconcilerReconcile(t *testing.T) { t.Run("delete stale resources", func(t *testing.T) { g := NewGomegaWithT(t) - owner := &infrav1alpha.AzureASOManagedCluster{ - Status: infrav1alpha.AzureASOManagedClusterStatus{ - Resources: []infrav1alpha.ResourceStatus{ + owner := &infrav1.AzureASOManagedCluster{ + Status: infrav1.AzureASOManagedClusterStatus{ + Resources: []infrav1.ResourceStatus{ rgStatus("rg0"), rgStatus("rg1"), rgStatus("rg2"), @@ -235,7 +235,7 @@ func TestResourceReconcilerPause(t *testing.T) { s := runtime.NewScheme() sb := runtime.NewSchemeBuilder( - infrav1alpha.AddToScheme, + infrav1.AddToScheme, asoresourcesv1.AddToScheme, ) NewGomegaWithT(t).Expect(sb.AddToScheme(s)).To(Succeed()) @@ -243,7 +243,7 @@ func TestResourceReconcilerPause(t *testing.T) { fakeClientBuilder := func() *fakeclient.ClientBuilder { return fakeclient.NewClientBuilder(). WithScheme(s). - WithStatusSubresource(&infrav1alpha.AzureASOManagedCluster{}) + WithStatusSubresource(&infrav1.AzureASOManagedCluster{}) } t.Run("empty resources", func(t *testing.T) { @@ -251,7 +251,7 @@ func TestResourceReconcilerPause(t *testing.T) { r := &ResourceReconciler{ resources: []*unstructured.Unstructured{}, - owner: &infrav1alpha.AzureASOManagedCluster{}, + owner: &infrav1.AzureASOManagedCluster{}, } g.Expect(r.Pause(ctx)).To(Succeed()) @@ -263,7 +263,7 @@ func TestResourceReconcilerPause(t *testing.T) { c := fakeClientBuilder(). Build() - asoManagedCluster := &infrav1alpha.AzureASOManagedCluster{} + asoManagedCluster := &infrav1.AzureASOManagedCluster{} var patchedRGs []string r := &ResourceReconciler{ @@ -300,7 +300,7 @@ func TestResourceReconcilerDelete(t *testing.T) { s := runtime.NewScheme() sb := runtime.NewSchemeBuilder( - infrav1alpha.AddToScheme, + infrav1.AddToScheme, asoresourcesv1.AddToScheme, ) NewGomegaWithT(t).Expect(sb.AddToScheme(s)).To(Succeed()) @@ -308,7 +308,7 @@ func TestResourceReconcilerDelete(t *testing.T) { fakeClientBuilder := func() *fakeclient.ClientBuilder { return fakeclient.NewClientBuilder(). WithScheme(s). - WithStatusSubresource(&infrav1alpha.AzureASOManagedCluster{}) + WithStatusSubresource(&infrav1.AzureASOManagedCluster{}) } t.Run("empty resources", func(t *testing.T) { @@ -316,7 +316,7 @@ func TestResourceReconcilerDelete(t *testing.T) { r := &ResourceReconciler{ resources: []*unstructured.Unstructured{}, - owner: &infrav1alpha.AzureASOManagedCluster{}, + owner: &infrav1.AzureASOManagedCluster{}, } g.Expect(r.Delete(ctx)).To(Succeed()) @@ -325,12 +325,12 @@ func TestResourceReconcilerDelete(t *testing.T) { t.Run("delete several resources", func(t *testing.T) { g := NewGomegaWithT(t) - owner := &infrav1alpha.AzureASOManagedCluster{ + owner := &infrav1.AzureASOManagedCluster{ ObjectMeta: metav1.ObjectMeta{ Namespace: "ns", }, - Status: infrav1alpha.AzureASOManagedClusterStatus{ - Resources: []infrav1alpha.ResourceStatus{ + Status: infrav1.AzureASOManagedClusterStatus{ + Resources: []infrav1.ResourceStatus{ rgStatus("still-deleting"), rgStatus("already-gone"), }, @@ -582,9 +582,9 @@ func rgJSON(g Gomega, scheme *runtime.Scheme, rg *asoresourcesv1.ResourceGroup) return u } -func rgStatus(name string) infrav1alpha.ResourceStatus { - return infrav1alpha.ResourceStatus{ - Resource: infrav1alpha.StatusResource{ +func rgStatus(name string) infrav1.ResourceStatus { + return infrav1.ResourceStatus{ + Resource: infrav1.StatusResource{ Group: asoresourcesv1.GroupVersion.Group, Version: asoresourcesv1.GroupVersion.Version, Kind: "ResourceGroup", diff --git a/docs/book/src/managed/asomanagedcluster.md b/docs/book/src/managed/asomanagedcluster.md index 170f38f0005..7032a53367b 100644 --- a/docs/book/src/managed/asomanagedcluster.md +++ b/docs/book/src/managed/asomanagedcluster.md @@ -18,7 +18,7 @@ This new API defines new AzureASOManagedCluster, AzureASOManagedControlPlane, an AzureASOManagedMachinePool resources. An AzureASOManagedCluster might look like this: ```yaml -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedCluster metadata: name: my-cluster @@ -72,7 +72,7 @@ to leave room for CAPZ to manage the canonical `${CLUSTER_NAME}-kubeconfig` secr another name must be specified for this Secret to avoid CAPZ and ASO overwriting each other: ```yaml -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedControlPlane metadata: name: ${CLUSTER_NAME} @@ -118,3 +118,56 @@ To migrate one cluster to the ASO-based APIs: - Note: the cluster infrastructure object should not have any finalizers and should already be deleted - Remove finalizers from the cluster: `kubectl patch cluster --type merge -p '{"metadata": {"finalizers": null}}'` - Verify the old ASO resources like ResourceGroup and ManagedCluster managed by the old Cluster are deleted. + +### Migrating from v1alpha1 to v1beta1 + +With the introduction of `v1beta1` for ASO Managed APIs in CAPZ, users should migrate their clusters and manifests from `v1alpha1` to `v1beta1`. **Note:** `v1alpha1` and `v1beta1` are equivalent — this migration is straightforward and low risk. + +#### Steps to Migrate + +1. **Upgrade CAPZ using `clusterctl upgrade`** + + The CRDs will be updated automatically as part of the upgrade process. + +2. **Update API Versions in Manifests** + + For each AzureASOManaged... resource, change the `apiVersion` from `infrastructure.cluster.x-k8s.io/v1alpha1` to `infrastructure.cluster.x-k8s.io/v1beta1`. For example: + + ```yaml + ... + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: AzureASOManagedCluster + ... + ``` + + Make these changes for `AzureASOManagedCluster(Template)`, `AzureASOManagedControlPlane(Template)` and `AzureASOManagedMachinePool(Template)` definitions. + +3. **Update References in CAPI Objects** + + Update any references in CAPI objects (such as a Cluster’s `spec.infrastructureRef` and `spec.controlPlaneRef`) to point to the new `apiVersion`: + + ```yaml + spec: + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: AzureASOManagedCluster + name: my-cluster + controlPlaneRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: AzureASOManagedControlPlane + name: my-cluster + ``` + + Similarly, update any other references to the API version for those object kinds. + +### What to Expect After Migration + +After completing the steps above, the following should be true: + +- All resources are healthy and visible. For an informative snapshot of your cluster and its resources, you can run: + ```sh + clusterctl describe cluster + ``` + +- The resources are now using `v1beta1` and reconciliation is working as expected. +- The CRD storage version is set to `v1beta1`. diff --git a/feature/feature.go b/feature/feature.go index 81eb0faa572..31ca915e0a6 100644 --- a/feature/feature.go +++ b/feature/feature.go @@ -71,6 +71,6 @@ var defaultCAPZFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{ AKS: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // Remove in 1.12 AKSResourceHealth: {Default: false, PreRelease: featuregate.Alpha}, EdgeZone: {Default: false, PreRelease: featuregate.Alpha}, - ASOAPI: {Default: true, PreRelease: featuregate.Alpha}, + ASOAPI: {Default: true, PreRelease: featuregate.GA}, APIServerILB: {Default: false, PreRelease: featuregate.Alpha}, } diff --git a/main.go b/main.go index 343c0e8b0f2..a55a3629005 100644 --- a/main.go +++ b/main.go @@ -58,7 +58,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/controllers" @@ -80,7 +79,6 @@ func init() { _ = clientgoscheme.AddToScheme(scheme) _ = infrav1.AddToScheme(scheme) _ = infrav1exp.AddToScheme(scheme) - _ = infrav1alpha.AddToScheme(scheme) _ = clusterv1.AddToScheme(scheme) _ = expv1.AddToScheme(scheme) _ = kubeadmv1.AddToScheme(scheme) @@ -679,17 +677,17 @@ func registerWebhooks(mgr manager.Manager) { } if feature.Gates.Enabled(feature.ASOAPI) { - if err := infrav1alpha.SetupAzureASOManagedClusterWebhookWithManager(mgr); err != nil { + if err := infrav1.SetupAzureASOManagedClusterWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "AzureASOManagedCluster") os.Exit(1) } - if err := infrav1alpha.SetupAzureASOManagedControlPlaneWebhookWithManager(mgr); err != nil { + if err := infrav1.SetupAzureASOManagedControlPlaneWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "AzureASOManagedControlPlane") os.Exit(1) } - if err := infrav1alpha.SetupAzureASOManagedMachinePoolWebhookWithManager(mgr); err != nil { + if err := infrav1.SetupAzureASOManagedMachinePoolWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "AzureASOManagedMachinePool") os.Exit(1) } diff --git a/pkg/mutators/azureasomanagedcontrolplane.go b/pkg/mutators/azureasomanagedcontrolplane.go index e208e9b888c..7f55ca90e17 100644 --- a/pkg/mutators/azureasomanagedcontrolplane.go +++ b/pkg/mutators/azureasomanagedcontrolplane.go @@ -38,7 +38,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/conversion" "sigs.k8s.io/controller-runtime/pkg/reconcile" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -52,7 +52,7 @@ var ( ) // SetManagedClusterDefaults propagates values defined by Cluster API to an ASO ManagedCluster. -func SetManagedClusterDefaults(ctrlClient client.Client, asoManagedControlPlane *infrav1alpha.AzureASOManagedControlPlane, cluster *clusterv1.Cluster) ResourcesMutator { +func SetManagedClusterDefaults(ctrlClient client.Client, asoManagedControlPlane *infrav1.AzureASOManagedControlPlane, cluster *clusterv1.Cluster) ResourcesMutator { return func(ctx context.Context, us []*unstructured.Unstructured) error { ctx, _, done := tele.StartSpanWithLogger(ctx, "mutators.SetManagedClusterDefaults") defer done() @@ -95,7 +95,7 @@ func SetManagedClusterDefaults(ctrlClient client.Client, asoManagedControlPlane } } -func setManagedClusterKubernetesVersion(ctx context.Context, asoManagedControlPlane *infrav1alpha.AzureASOManagedControlPlane, managedClusterPath string, managedCluster *unstructured.Unstructured) error { +func setManagedClusterKubernetesVersion(ctx context.Context, asoManagedControlPlane *infrav1.AzureASOManagedControlPlane, managedClusterPath string, managedCluster *unstructured.Unstructured) error { _, log, done := tele.StartSpanWithLogger(ctx, "mutators.setManagedClusterKubernetesVersion") defer done() @@ -253,7 +253,7 @@ func agentPoolsFromManagedMachinePools(ctx context.Context, ctrlClient client.Cl ctx, log, done := tele.StartSpanWithLogger(ctx, "mutators.agentPoolsFromManagedMachinePools") defer done() - asoManagedMachinePools := &infrav1alpha.AzureASOManagedMachinePoolList{} + asoManagedMachinePools := &infrav1.AzureASOManagedMachinePoolList{} err := ctrlClient.List(ctx, asoManagedMachinePools, client.InNamespace(namespace), client.MatchingLabels{ diff --git a/pkg/mutators/azureasomanagedcontrolplane_test.go b/pkg/mutators/azureasomanagedcontrolplane_test.go index 8de0275bfdb..e3173044a69 100644 --- a/pkg/mutators/azureasomanagedcontrolplane_test.go +++ b/pkg/mutators/azureasomanagedcontrolplane_test.go @@ -36,7 +36,7 @@ import ( fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/conversion" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) func TestSetManagedClusterDefaults(t *testing.T) { @@ -45,16 +45,16 @@ func TestSetManagedClusterDefaults(t *testing.T) { tests := []struct { name string - asoManagedControlPlane *infrav1alpha.AzureASOManagedControlPlane + asoManagedControlPlane *infrav1.AzureASOManagedControlPlane cluster *clusterv1.Cluster expected []*unstructured.Unstructured expectedErr error }{ { name: "no ManagedCluster", - asoManagedControlPlane: &infrav1alpha.AzureASOManagedControlPlane{ - Spec: infrav1alpha.AzureASOManagedControlPlaneSpec{ - AzureASOManagedControlPlaneTemplateResourceSpec: infrav1alpha.AzureASOManagedControlPlaneTemplateResourceSpec{ + asoManagedControlPlane: &infrav1.AzureASOManagedControlPlane{ + Spec: infrav1.AzureASOManagedControlPlaneSpec{ + AzureASOManagedControlPlaneTemplateResourceSpec: infrav1.AzureASOManagedControlPlaneTemplateResourceSpec{ Resources: []runtime.RawExtension{}, }, }, @@ -63,9 +63,9 @@ func TestSetManagedClusterDefaults(t *testing.T) { }, { name: "success", - asoManagedControlPlane: &infrav1alpha.AzureASOManagedControlPlane{ - Spec: infrav1alpha.AzureASOManagedControlPlaneSpec{ - AzureASOManagedControlPlaneTemplateResourceSpec: infrav1alpha.AzureASOManagedControlPlaneTemplateResourceSpec{ + asoManagedControlPlane: &infrav1.AzureASOManagedControlPlane{ + Spec: infrav1.AzureASOManagedControlPlaneSpec{ + AzureASOManagedControlPlaneTemplateResourceSpec: infrav1.AzureASOManagedControlPlaneTemplateResourceSpec{ Version: "vCAPI k8s version", Resources: []runtime.RawExtension{ { @@ -118,7 +118,7 @@ func TestSetManagedClusterDefaults(t *testing.T) { s := runtime.NewScheme() g.Expect(asocontainerservicev1.AddToScheme(s)).To(Succeed()) - g.Expect(infrav1alpha.AddToScheme(s)).To(Succeed()) + g.Expect(infrav1.AddToScheme(s)).To(Succeed()) c := fakeclient.NewClientBuilder(). WithScheme(s). Build() @@ -140,14 +140,14 @@ func TestSetManagedClusterKubernetesVersion(t *testing.T) { tests := []struct { name string - asoManagedControlPlane *infrav1alpha.AzureASOManagedControlPlane + asoManagedControlPlane *infrav1.AzureASOManagedControlPlane managedCluster *asocontainerservicev1.ManagedCluster expected *asocontainerservicev1.ManagedCluster expectedErr error }{ { name: "no CAPI opinion", - asoManagedControlPlane: &infrav1alpha.AzureASOManagedControlPlane{}, + asoManagedControlPlane: &infrav1.AzureASOManagedControlPlane{}, managedCluster: &asocontainerservicev1.ManagedCluster{ Spec: asocontainerservicev1.ManagedCluster_Spec{ KubernetesVersion: ptr.To("user k8s version"), @@ -161,9 +161,9 @@ func TestSetManagedClusterKubernetesVersion(t *testing.T) { }, { name: "set from CAPI opinion", - asoManagedControlPlane: &infrav1alpha.AzureASOManagedControlPlane{ - Spec: infrav1alpha.AzureASOManagedControlPlaneSpec{ - AzureASOManagedControlPlaneTemplateResourceSpec: infrav1alpha.AzureASOManagedControlPlaneTemplateResourceSpec{ + asoManagedControlPlane: &infrav1.AzureASOManagedControlPlane{ + Spec: infrav1.AzureASOManagedControlPlaneSpec{ + AzureASOManagedControlPlaneTemplateResourceSpec: infrav1.AzureASOManagedControlPlaneTemplateResourceSpec{ Version: "vCAPI k8s version", }, }, @@ -177,9 +177,9 @@ func TestSetManagedClusterKubernetesVersion(t *testing.T) { }, { name: "user value matching CAPI ok", - asoManagedControlPlane: &infrav1alpha.AzureASOManagedControlPlane{ - Spec: infrav1alpha.AzureASOManagedControlPlaneSpec{ - AzureASOManagedControlPlaneTemplateResourceSpec: infrav1alpha.AzureASOManagedControlPlaneTemplateResourceSpec{ + asoManagedControlPlane: &infrav1.AzureASOManagedControlPlane{ + Spec: infrav1.AzureASOManagedControlPlaneSpec{ + AzureASOManagedControlPlaneTemplateResourceSpec: infrav1.AzureASOManagedControlPlaneTemplateResourceSpec{ Version: "vCAPI k8s version", }, }, @@ -197,9 +197,9 @@ func TestSetManagedClusterKubernetesVersion(t *testing.T) { }, { name: "incompatible", - asoManagedControlPlane: &infrav1alpha.AzureASOManagedControlPlane{ - Spec: infrav1alpha.AzureASOManagedControlPlaneSpec{ - AzureASOManagedControlPlaneTemplateResourceSpec: infrav1alpha.AzureASOManagedControlPlaneTemplateResourceSpec{ + asoManagedControlPlane: &infrav1.AzureASOManagedControlPlane{ + Spec: infrav1.AzureASOManagedControlPlaneSpec{ + AzureASOManagedControlPlaneTemplateResourceSpec: infrav1.AzureASOManagedControlPlaneTemplateResourceSpec{ Version: "vCAPI k8s version", }, }, @@ -508,7 +508,7 @@ func TestSetManagedClusterAgentPoolProfiles(t *testing.T) { ctx := context.Background() s := runtime.NewScheme() g.Expect(asocontainerservicev1.AddToScheme(s)).To(Succeed()) - g.Expect(infrav1alpha.AddToScheme(s)).To(Succeed()) + g.Expect(infrav1.AddToScheme(s)).To(Succeed()) g.Expect(expv1.AddToScheme(s)).To(Succeed()) fakeClientBuilder := func() *fakeclient.ClientBuilder { return fakeclient.NewClientBuilder().WithScheme(s) @@ -565,8 +565,8 @@ func TestSetManagedClusterAgentPoolProfiles(t *testing.T) { managedCluster := &asocontainerservicev1.ManagedCluster{} umc := mcUnstructured(g, managedCluster) - asoManagedMachinePools := &infrav1alpha.AzureASOManagedMachinePoolList{ - Items: []infrav1alpha.AzureASOManagedMachinePool{ + asoManagedMachinePools := &infrav1.AzureASOManagedMachinePoolList{ + Items: []infrav1.AzureASOManagedMachinePool{ { ObjectMeta: metav1.ObjectMeta{ Name: "wrong-label", @@ -582,8 +582,8 @@ func TestSetManagedClusterAgentPoolProfiles(t *testing.T) { }, }, }, - Spec: infrav1alpha.AzureASOManagedMachinePoolSpec{ - AzureASOManagedMachinePoolTemplateResourceSpec: infrav1alpha.AzureASOManagedMachinePoolTemplateResourceSpec{ + Spec: infrav1.AzureASOManagedMachinePoolSpec{ + AzureASOManagedMachinePoolTemplateResourceSpec: infrav1.AzureASOManagedMachinePoolTemplateResourceSpec{ Resources: []runtime.RawExtension{ { Raw: apJSON(g, &asocontainerservicev1.ManagedClustersAgentPool{ @@ -611,8 +611,8 @@ func TestSetManagedClusterAgentPoolProfiles(t *testing.T) { }, }, }, - Spec: infrav1alpha.AzureASOManagedMachinePoolSpec{ - AzureASOManagedMachinePoolTemplateResourceSpec: infrav1alpha.AzureASOManagedMachinePoolTemplateResourceSpec{ + Spec: infrav1.AzureASOManagedMachinePoolSpec{ + AzureASOManagedMachinePoolTemplateResourceSpec: infrav1.AzureASOManagedMachinePoolTemplateResourceSpec{ Resources: []runtime.RawExtension{ { Raw: apJSON(g, &asocontainerservicev1.ManagedClustersAgentPool{ @@ -640,8 +640,8 @@ func TestSetManagedClusterAgentPoolProfiles(t *testing.T) { }, }, }, - Spec: infrav1alpha.AzureASOManagedMachinePoolSpec{ - AzureASOManagedMachinePoolTemplateResourceSpec: infrav1alpha.AzureASOManagedMachinePoolTemplateResourceSpec{ + Spec: infrav1.AzureASOManagedMachinePoolSpec{ + AzureASOManagedMachinePoolTemplateResourceSpec: infrav1.AzureASOManagedMachinePoolTemplateResourceSpec{ Resources: []runtime.RawExtension{ { Raw: apJSON(g, &asocontainerservicev1.ManagedClustersAgentPool{ @@ -669,8 +669,8 @@ func TestSetManagedClusterAgentPoolProfiles(t *testing.T) { }, }, }, - Spec: infrav1alpha.AzureASOManagedMachinePoolSpec{ - AzureASOManagedMachinePoolTemplateResourceSpec: infrav1alpha.AzureASOManagedMachinePoolTemplateResourceSpec{ + Spec: infrav1.AzureASOManagedMachinePoolSpec{ + AzureASOManagedMachinePoolTemplateResourceSpec: infrav1.AzureASOManagedMachinePoolTemplateResourceSpec{ Resources: []runtime.RawExtension{ { Raw: apJSON(g, &asocontainerservicev1.ManagedClustersAgentPool{ diff --git a/pkg/mutators/azureasomanagedmachinepool.go b/pkg/mutators/azureasomanagedmachinepool.go index d4b89ba040f..0c92d23c55b 100644 --- a/pkg/mutators/azureasomanagedmachinepool.go +++ b/pkg/mutators/azureasomanagedmachinepool.go @@ -28,7 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/util/tele" ) @@ -115,11 +115,11 @@ func reconcileAutoscaling(agentPool *unstructured.Unstructured, machinePool *exp if machinePool.Annotations == nil { machinePool.Annotations = make(map[string]string) } - machinePool.Annotations[clusterv1.ReplicasManagedByAnnotation] = infrav1alpha.ReplicasManagedByAKS - } else if replicaManager != infrav1alpha.ReplicasManagedByAKS { + machinePool.Annotations[clusterv1.ReplicasManagedByAnnotation] = infrav1.ReplicasManagedByAKS + } else if replicaManager != infrav1.ReplicasManagedByAKS { return fmt.Errorf("failed to enable autoscaling, replicas are already being managed by %s according to MachinePool %s's %s annotation", replicaManager, machinePool.Name, clusterv1.ReplicasManagedByAnnotation) } - } else if !autoscaling && replicaManager == infrav1alpha.ReplicasManagedByAKS { + } else if !autoscaling && replicaManager == infrav1.ReplicasManagedByAKS { // Removing this annotation informs the MachinePool controller that this MachinePool is no longer // being autoscaled. delete(machinePool.Annotations, clusterv1.ReplicasManagedByAnnotation) diff --git a/pkg/mutators/azureasomanagedmachinepool_test.go b/pkg/mutators/azureasomanagedmachinepool_test.go index 50ec0b455e6..aa130af76be 100644 --- a/pkg/mutators/azureasomanagedmachinepool_test.go +++ b/pkg/mutators/azureasomanagedmachinepool_test.go @@ -33,7 +33,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" + infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) func TestSetAgentPoolDefaults(t *testing.T) { @@ -42,16 +42,16 @@ func TestSetAgentPoolDefaults(t *testing.T) { tests := []struct { name string - asoManagedMachinePool *infrav1alpha.AzureASOManagedMachinePool + asoManagedMachinePool *infrav1.AzureASOManagedMachinePool machinePool *expv1.MachinePool expected []*unstructured.Unstructured expectedErr error }{ { name: "no ManagedClustersAgentPool", - asoManagedMachinePool: &infrav1alpha.AzureASOManagedMachinePool{ - Spec: infrav1alpha.AzureASOManagedMachinePoolSpec{ - AzureASOManagedMachinePoolTemplateResourceSpec: infrav1alpha.AzureASOManagedMachinePoolTemplateResourceSpec{ + asoManagedMachinePool: &infrav1.AzureASOManagedMachinePool{ + Spec: infrav1.AzureASOManagedMachinePoolSpec{ + AzureASOManagedMachinePoolTemplateResourceSpec: infrav1.AzureASOManagedMachinePoolTemplateResourceSpec{ Resources: []runtime.RawExtension{}, }, }, @@ -60,9 +60,9 @@ func TestSetAgentPoolDefaults(t *testing.T) { }, { name: "success", - asoManagedMachinePool: &infrav1alpha.AzureASOManagedMachinePool{ - Spec: infrav1alpha.AzureASOManagedMachinePoolSpec{ - AzureASOManagedMachinePoolTemplateResourceSpec: infrav1alpha.AzureASOManagedMachinePoolTemplateResourceSpec{ + asoManagedMachinePool: &infrav1.AzureASOManagedMachinePool{ + Spec: infrav1.AzureASOManagedMachinePoolSpec{ + AzureASOManagedMachinePoolTemplateResourceSpec: infrav1.AzureASOManagedMachinePoolTemplateResourceSpec{ Resources: []runtime.RawExtension{ { Raw: apJSON(g, &asocontainerservicev1.ManagedClustersAgentPool{}), @@ -251,7 +251,7 @@ func TestReconcileAutoscaling(t *testing.T) { machinePool: &expv1.MachinePool{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ - clusterv1.ReplicasManagedByAnnotation: infrav1alpha.ReplicasManagedByAKS, + clusterv1.ReplicasManagedByAnnotation: infrav1.ReplicasManagedByAKS, }, }, }, @@ -267,14 +267,14 @@ func TestReconcileAutoscaling(t *testing.T) { machinePool: &expv1.MachinePool{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ - clusterv1.ReplicasManagedByAnnotation: "not-" + infrav1alpha.ReplicasManagedByAKS, + clusterv1.ReplicasManagedByAnnotation: "not-" + infrav1.ReplicasManagedByAKS, }, }, }, expected: &expv1.MachinePool{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ - clusterv1.ReplicasManagedByAnnotation: "not-" + infrav1alpha.ReplicasManagedByAKS, + clusterv1.ReplicasManagedByAnnotation: "not-" + infrav1.ReplicasManagedByAKS, }, }, }, @@ -290,7 +290,7 @@ func TestReconcileAutoscaling(t *testing.T) { expected: &expv1.MachinePool{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ - clusterv1.ReplicasManagedByAnnotation: infrav1alpha.ReplicasManagedByAKS, + clusterv1.ReplicasManagedByAnnotation: infrav1.ReplicasManagedByAKS, }, }, }, @@ -301,14 +301,14 @@ func TestReconcileAutoscaling(t *testing.T) { machinePool: &expv1.MachinePool{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ - clusterv1.ReplicasManagedByAnnotation: infrav1alpha.ReplicasManagedByAKS, + clusterv1.ReplicasManagedByAnnotation: infrav1.ReplicasManagedByAKS, }, }, }, expected: &expv1.MachinePool{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ - clusterv1.ReplicasManagedByAnnotation: infrav1alpha.ReplicasManagedByAKS, + clusterv1.ReplicasManagedByAnnotation: infrav1.ReplicasManagedByAKS, }, }, }, @@ -320,7 +320,7 @@ func TestReconcileAutoscaling(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "mp", Annotations: map[string]string{ - clusterv1.ReplicasManagedByAnnotation: "not-" + infrav1alpha.ReplicasManagedByAKS, + clusterv1.ReplicasManagedByAnnotation: "not-" + infrav1.ReplicasManagedByAKS, }, }, }, @@ -384,7 +384,7 @@ func TestSetAgentPoolCount(t *testing.T) { machinePool: &expv1.MachinePool{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ - clusterv1.ReplicasManagedByAnnotation: infrav1alpha.ReplicasManagedByAKS, + clusterv1.ReplicasManagedByAnnotation: infrav1.ReplicasManagedByAKS, }, }, Spec: expv1.MachinePoolSpec{ diff --git a/templates/cluster-template-aks-aso-clusterclass.yaml b/templates/cluster-template-aks-aso-clusterclass.yaml index 01dfe6c1492..5033d6e658a 100644 --- a/templates/cluster-template-aks-aso-clusterclass.yaml +++ b/templates/cluster-template-aks-aso-clusterclass.yaml @@ -6,12 +6,12 @@ metadata: spec: controlPlane: ref: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedControlPlaneTemplate name: ${CLUSTER_NAME}-control-plane infrastructure: ref: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedClusterTemplate name: ${CLUSTER_NAME} patches: @@ -31,7 +31,7 @@ spec: spec: location: ${AZURE_LOCATION} selector: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedClusterTemplate matchResources: infrastructureCluster: true @@ -62,7 +62,7 @@ spec: networkProfile: networkPlugin: azure selector: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedControlPlaneTemplate matchResources: controlPlane: true @@ -88,7 +88,7 @@ spec: type: VirtualMachineScaleSets vmSize: ${AZURE_NODE_MACHINE_TYPE} selector: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePoolTemplate matchResources: machinePoolClass: @@ -116,7 +116,7 @@ spec: type: VirtualMachineScaleSets vmSize: ${AZURE_NODE_MACHINE_TYPE} selector: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePoolTemplate matchResources: machinePoolClass: @@ -134,7 +134,7 @@ spec: name: ${CLUSTER_NAME}-pool0 infrastructure: ref: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePoolTemplate name: ${CLUSTER_NAME}-pool0 - class: default-worker @@ -146,11 +146,11 @@ spec: name: ${CLUSTER_NAME}-pool1 infrastructure: ref: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePoolTemplate name: ${CLUSTER_NAME}-pool1 --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedControlPlaneTemplate metadata: name: ${CLUSTER_NAME}-control-plane @@ -159,7 +159,7 @@ spec: template: spec: {} --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedClusterTemplate metadata: name: ${CLUSTER_NAME} @@ -168,7 +168,7 @@ spec: template: spec: {} --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePoolTemplate metadata: name: ${CLUSTER_NAME}-pool0 @@ -177,7 +177,7 @@ spec: template: spec: {} --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePoolTemplate metadata: name: ${CLUSTER_NAME}-pool1 diff --git a/templates/cluster-template-aks-aso.yaml b/templates/cluster-template-aks-aso.yaml index 9d1ea7d30a4..c8674b3b387 100644 --- a/templates/cluster-template-aks-aso.yaml +++ b/templates/cluster-template-aks-aso.yaml @@ -5,15 +5,15 @@ metadata: namespace: default spec: controlPlaneRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedControlPlane name: ${CLUSTER_NAME} infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedCluster name: ${CLUSTER_NAME} --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedControlPlane metadata: name: ${CLUSTER_NAME} @@ -39,7 +39,7 @@ spec: clientId: msi version: ${KUBERNETES_VERSION} --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedCluster metadata: name: ${CLUSTER_NAME} @@ -70,12 +70,12 @@ spec: dataSecretName: "" clusterName: ${CLUSTER_NAME} infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool name: ${CLUSTER_NAME}-pool0 version: ${KUBERNETES_VERSION} --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool metadata: name: ${CLUSTER_NAME}-pool0 @@ -111,12 +111,12 @@ spec: dataSecretName: "" clusterName: ${CLUSTER_NAME} infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool name: ${CLUSTER_NAME}-pool1 version: ${KUBERNETES_VERSION} --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool metadata: name: ${CLUSTER_NAME}-pool1 diff --git a/templates/flavors/aks-aso-clusterclass/azure-managed-cluster-template.yaml b/templates/flavors/aks-aso-clusterclass/azure-managed-cluster-template.yaml index bae469db031..374c04e8ada 100644 --- a/templates/flavors/aks-aso-clusterclass/azure-managed-cluster-template.yaml +++ b/templates/flavors/aks-aso-clusterclass/azure-managed-cluster-template.yaml @@ -1,4 +1,4 @@ -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedClusterTemplate metadata: name: ${CLUSTER_NAME} diff --git a/templates/flavors/aks-aso-clusterclass/azure-managed-controlplane-template.yaml b/templates/flavors/aks-aso-clusterclass/azure-managed-controlplane-template.yaml index 836bd0f7f6e..8a6df821e38 100644 --- a/templates/flavors/aks-aso-clusterclass/azure-managed-controlplane-template.yaml +++ b/templates/flavors/aks-aso-clusterclass/azure-managed-controlplane-template.yaml @@ -1,4 +1,4 @@ -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedControlPlaneTemplate metadata: name: ${CLUSTER_NAME}-control-plane diff --git a/templates/flavors/aks-aso-clusterclass/azure-managed-machinepool-template.yaml b/templates/flavors/aks-aso-clusterclass/azure-managed-machinepool-template.yaml index a745484a9f7..5bb034d720f 100644 --- a/templates/flavors/aks-aso-clusterclass/azure-managed-machinepool-template.yaml +++ b/templates/flavors/aks-aso-clusterclass/azure-managed-machinepool-template.yaml @@ -1,4 +1,4 @@ -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePoolTemplate metadata: name: ${CLUSTER_NAME}-pool0 @@ -7,7 +7,7 @@ spec: template: spec: {} --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePoolTemplate metadata: name: ${CLUSTER_NAME}-pool1 diff --git a/templates/flavors/aks-aso-clusterclass/clusterclass.yaml b/templates/flavors/aks-aso-clusterclass/clusterclass.yaml index 308851b93a1..53e9fb6ef6b 100644 --- a/templates/flavors/aks-aso-clusterclass/clusterclass.yaml +++ b/templates/flavors/aks-aso-clusterclass/clusterclass.yaml @@ -6,12 +6,12 @@ metadata: spec: controlPlane: ref: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedControlPlaneTemplate name: ${CLUSTER_NAME}-control-plane infrastructure: ref: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedClusterTemplate name: ${CLUSTER_NAME} workers: @@ -25,7 +25,7 @@ spec: name: ${CLUSTER_NAME}-pool0 infrastructure: ref: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePoolTemplate name: ${CLUSTER_NAME}-pool0 - class: default-worker @@ -37,7 +37,7 @@ spec: name: ${CLUSTER_NAME}-pool1 infrastructure: ref: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePoolTemplate name: ${CLUSTER_NAME}-pool1 # CAPI doesn't let you replace fields of array elements, so we patch the @@ -47,7 +47,7 @@ spec: - name: azureasomanagedcluster-spec definitions: - selector: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedClusterTemplate matchResources: infrastructureCluster: true @@ -68,7 +68,7 @@ spec: - name: azureasomanagedcontrolplane-spec definitions: - selector: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedControlPlaneTemplate matchResources: controlPlane: true @@ -99,7 +99,7 @@ spec: - name: azureasomanagedmachinepool-pool0-spec definitions: - selector: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePoolTemplate matchResources: machinePoolClass: @@ -127,7 +127,7 @@ spec: - name: azureasomanagedmachinepool-pool1-spec definitions: - selector: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePoolTemplate matchResources: machinePoolClass: diff --git a/templates/flavors/aks-aso/cluster-template.yaml b/templates/flavors/aks-aso/cluster-template.yaml index 6a815ee9d72..06710fad608 100644 --- a/templates/flavors/aks-aso/cluster-template.yaml +++ b/templates/flavors/aks-aso/cluster-template.yaml @@ -6,15 +6,15 @@ metadata: namespace: default spec: controlPlaneRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedControlPlane name: ${CLUSTER_NAME} infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedCluster name: ${CLUSTER_NAME} --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedControlPlane metadata: name: ${CLUSTER_NAME} @@ -39,7 +39,7 @@ spec: networkProfile: networkPlugin: azure --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedCluster metadata: name: ${CLUSTER_NAME} @@ -68,12 +68,12 @@ spec: dataSecretName: "" clusterName: "${CLUSTER_NAME}" infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool name: "${CLUSTER_NAME}-pool0" version: "${KUBERNETES_VERSION}" --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool metadata: name: "${CLUSTER_NAME}-pool0" @@ -107,12 +107,12 @@ spec: dataSecretName: "" clusterName: "${CLUSTER_NAME}" infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool name: "${CLUSTER_NAME}-pool1" version: "${KUBERNETES_VERSION}" --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool metadata: name: "${CLUSTER_NAME}-pool1" diff --git a/templates/test/ci/cluster-template-prow-aks-aso.yaml b/templates/test/ci/cluster-template-prow-aks-aso.yaml index 20feb179abb..1480718e6fb 100644 --- a/templates/test/ci/cluster-template-prow-aks-aso.yaml +++ b/templates/test/ci/cluster-template-prow-aks-aso.yaml @@ -5,15 +5,15 @@ metadata: namespace: default spec: controlPlaneRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedControlPlane name: ${CLUSTER_NAME} infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedCluster name: ${CLUSTER_NAME} --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedControlPlane metadata: name: ${CLUSTER_NAME} @@ -46,7 +46,7 @@ spec: jobName: ${JOB_NAME} version: ${KUBERNETES_VERSION} --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedCluster metadata: name: ${CLUSTER_NAME} @@ -81,12 +81,12 @@ spec: dataSecretName: "" clusterName: ${CLUSTER_NAME} infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool name: ${CLUSTER_NAME}-pool0 version: ${KUBERNETES_VERSION} --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool metadata: name: ${CLUSTER_NAME}-pool0 @@ -122,12 +122,12 @@ spec: dataSecretName: "" clusterName: ${CLUSTER_NAME} infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool name: ${CLUSTER_NAME}-pool1 version: ${KUBERNETES_VERSION} --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool metadata: name: ${CLUSTER_NAME}-pool1 @@ -163,12 +163,12 @@ spec: dataSecretName: "" clusterName: ${CLUSTER_NAME} infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool name: ${CLUSTER_NAME}-pool2 version: ${KUBERNETES_VERSION} --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool metadata: name: ${CLUSTER_NAME}-pool2 diff --git a/templates/test/ci/prow-aks-aso/patches/aks-pool2.yaml b/templates/test/ci/prow-aks-aso/patches/aks-pool2.yaml index 3c9bdc36f33..bac6ca112fa 100644 --- a/templates/test/ci/prow-aks-aso/patches/aks-pool2.yaml +++ b/templates/test/ci/prow-aks-aso/patches/aks-pool2.yaml @@ -12,12 +12,12 @@ spec: dataSecretName: "" clusterName: "${CLUSTER_NAME}" infrastructureRef: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool name: "${CLUSTER_NAME}-pool2" version: "${KUBERNETES_VERSION}" --- -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: AzureASOManagedMachinePool metadata: name: "${CLUSTER_NAME}-pool2" diff --git a/test/e2e/aks.go b/test/e2e/aks.go index bf59186709f..d476d80bce2 100644 --- a/test/e2e/aks.go +++ b/test/e2e/aks.go @@ -34,7 +34,6 @@ import ( "sigs.k8s.io/cluster-api/test/framework/clusterctl" "sigs.k8s.io/controller-runtime/pkg/client" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" ) @@ -158,7 +157,7 @@ func WaitForAKSSystemNodePoolMachinesToExist(ctx context.Context, input WaitForC var capzMPs []client.Object ammpList := &infrav1.AzureManagedMachinePoolList{} - asommpList := &infrav1alpha.AzureASOManagedMachinePoolList{} + asommpList := &infrav1.AzureASOManagedMachinePoolList{} if err := input.Lister.List(ctx, ammpList, opt1, opt2, opt3); err != nil { LogWarningf("Failed to list AzureManagedMachinePools: %+v", err) diff --git a/test/e2e/aks_machinepools.go b/test/e2e/aks_machinepools.go index de2b35e797d..ab1279d0e97 100644 --- a/test/e2e/aks_machinepools.go +++ b/test/e2e/aks_machinepools.go @@ -33,7 +33,6 @@ import ( "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/controller-runtime/pkg/client" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/pkg/mutators" ) @@ -88,8 +87,8 @@ func AKSMachinePoolSpec(ctx context.Context, inputGetter func() AKSMachinePoolSp if ammp.Spec.Mode != string(infrav1.NodePoolModeSystem) { isUserPool = true } - case infrav1alpha.AzureASOManagedMachinePoolKind: - ammp := &infrav1alpha.AzureASOManagedMachinePool{} + case infrav1.AzureASOManagedMachinePoolKind: + ammp := &infrav1.AzureASOManagedMachinePool{} err := bootstrapClusterProxy.GetClient().Get(ctx, types.NamespacedName{ Namespace: mp.Spec.Template.Spec.InfrastructureRef.Namespace, Name: mp.Spec.Template.Spec.InfrastructureRef.Name, diff --git a/test/e2e/azure_clusterproxy.go b/test/e2e/azure_clusterproxy.go index 646ce32de52..58391bead06 100644 --- a/test/e2e/azure_clusterproxy.go +++ b/test/e2e/azure_clusterproxy.go @@ -50,7 +50,6 @@ import ( "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/controller-runtime/pkg/client" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" ) @@ -76,7 +75,6 @@ func initScheme() *runtime.Scheme { framework.TryAddDefaultSchemes(scheme) Expect(infrav1.AddToScheme(scheme)).To(Succeed()) Expect(infrav1exp.AddToScheme(scheme)).To(Succeed()) - Expect(infrav1alpha.AddToScheme(scheme)).To(Succeed()) Expect(expv1.AddToScheme(scheme)).To(Succeed()) Expect(asoresourcesv1.AddToScheme(scheme)).To(Succeed()) Expect(asocontainerservicev1.AddToScheme(scheme)).To(Succeed()) diff --git a/test/e2e/azure_logcollector.go b/test/e2e/azure_logcollector.go index 9f0fb5ad681..ff370371eed 100644 --- a/test/e2e/azure_logcollector.go +++ b/test/e2e/azure_logcollector.go @@ -39,7 +39,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" kinderrors "sigs.k8s.io/kind/pkg/errors" - infrav1alpha "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha1" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" infrav1exp "sigs.k8s.io/cluster-api-provider-azure/exp/api/v1beta1" @@ -211,13 +210,13 @@ func getAzureManagedControlPlane(ctx context.Context, managementClusterClient cl return azManagedControlPlane, err } -func getAzureASOManagedCluster(ctx context.Context, managementClusterClient client.Client, namespace, name string) (*infrav1alpha.AzureASOManagedCluster, error) { +func getAzureASOManagedCluster(ctx context.Context, managementClusterClient client.Client, namespace, name string) (*infrav1.AzureASOManagedCluster, error) { key := client.ObjectKey{ Namespace: namespace, Name: name, } - azManagedCluster := &infrav1alpha.AzureASOManagedCluster{} + azManagedCluster := &infrav1.AzureASOManagedCluster{} err := managementClusterClient.Get(ctx, key, azManagedCluster) return azManagedCluster, err } @@ -255,13 +254,13 @@ func getAzureManagedMachinePool(ctx context.Context, managementClusterClient cli return azManagedMachinePool, err } -func getAzureASOManagedMachinePool(ctx context.Context, managementClusterClient client.Client, mp *expv1.MachinePool) (*infrav1alpha.AzureASOManagedMachinePool, error) { +func getAzureASOManagedMachinePool(ctx context.Context, managementClusterClient client.Client, mp *expv1.MachinePool) (*infrav1.AzureASOManagedMachinePool, error) { key := client.ObjectKey{ Namespace: mp.Spec.Template.Spec.InfrastructureRef.Namespace, Name: mp.Spec.Template.Spec.InfrastructureRef.Name, } - azManagedMachinePool := &infrav1alpha.AzureASOManagedMachinePool{} + azManagedMachinePool := &infrav1.AzureASOManagedMachinePool{} err := managementClusterClient.Get(ctx, key, azManagedMachinePool) return azManagedMachinePool, err }