-
Notifications
You must be signed in to change notification settings - Fork 448
Migrated AzureASOManaged API to v1beta1 #5660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should mark each of the v1alpha1 types as deprecated per https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning/#version-deprecation. I see kubebuilder makes that easy with a marker like this:
Then that warning gets blasted whenever that API version is used to prompt people to update: % kubectl get azureasomanagedcluster.v1alpha1.infrastructure.cluster.x-k8s.io
Warning: infrastructure.cluster.x-k8s.io/v1alpha1 AzureASOManagedCluster is deprecated. infrastructure.cluster.x-k8s.io/v1beta1 should be used instead.
NAME AGE
aks-aso-6548 45s |
||
// +kubebuilder:subresource:status | ||
// +kubebuilder:storageversion | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't covered in e2e atm, but we should at least manually verify that upgrading from a previous version of CAPZ that used v1alpha1 as the storage version doesn't break existing workload clusters when the CRD is updated to the new storage version. We should definitely follow up soon after this though with automated tests if we absolutely have to cut the release with the rest of these changes before then. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Finished manually verify that upgrading from a previous version of CAPZ that used v1alpha1 as the storage version doesn't break existing workload clusters when the CRD is updated to the new storage version.
|
||
|
||
// 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{}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropping this here for myself to make sure no unexpected changes sneak in: