Skip to content

Commit 1e34c2d

Browse files
committed
add spec.version and status.version to AzureASOManagedControlPlane
1 parent 2c02cd2 commit 1e34c2d

11 files changed

+40
-1
lines changed

config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedcontrolplanes.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ spec:
4848
type: object
4949
x-kubernetes-preserve-unknown-fields: true
5050
type: array
51+
version:
52+
description: |-
53+
Version is the Kubernetes version of the control plane. It fulfills Cluster API's control plane
54+
provider contract.
55+
type: string
5156
type: object
5257
status:
5358
description: AzureASOManagedControlPlaneStatus defines the observed state
@@ -96,6 +101,11 @@ spec:
96101
- resource
97102
type: object
98103
type: array
104+
version:
105+
description: |-
106+
Version is the observed Kubernetes version of the control plane. It fulfills Cluster API's control
107+
plane provider contract.
108+
type: string
99109
type: object
100110
type: object
101111
served: true

config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedcontrolplanetemplates.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ spec:
5656
type: object
5757
x-kubernetes-preserve-unknown-fields: true
5858
type: array
59+
version:
60+
description: |-
61+
Version is the Kubernetes version of the control plane. It fulfills Cluster API's control plane
62+
provider contract.
63+
type: string
5964
type: object
6065
type: object
6166
required:

config/crd/bases/infrastructure.cluster.x-k8s.io_azureasomanagedmachinepooltemplates.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ spec:
5656
type: object
5757
x-kubernetes-preserve-unknown-fields: true
5858
type: array
59+
version:
60+
description: |-
61+
Version is the Kubernetes version of the control plane. It fulfills Cluster API's control plane
62+
provider contract.
63+
type: string
5964
type: object
6065
type: object
6166
required:

exp/api/v1alpha1/azureasomanagedcontrolplane_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ type AzureASOManagedControlPlaneSpec struct {
3131

3232
// AzureASOManagedControlPlaneStatus defines the observed state of AzureASOManagedControlPlane.
3333
type AzureASOManagedControlPlaneStatus struct {
34+
// Version is the observed Kubernetes version of the control plane. It fulfills Cluster API's control
35+
// plane provider contract.
36+
//+optional
37+
Version string `json:"version,omitempty"`
38+
3439
//+optional
3540
Resources []ResourceStatus `json:"resources,omitempty"`
3641

exp/api/v1alpha1/azureasomanagedcontrolplanetemplate_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ type AzureASOManagedControlPlaneResource struct {
3333

3434
// AzureASOManagedControlPlaneTemplateResourceSpec defines the desired state of the templated resource.
3535
type AzureASOManagedControlPlaneTemplateResourceSpec struct {
36+
// Version is the Kubernetes version of the control plane. It fulfills Cluster API's control plane
37+
// provider contract.
38+
//+optional
39+
Version string `json:"version,omitempty"`
40+
3641
// Resources are embedded ASO resources to be managed by this resource.
3742
//+optional
3843
Resources []runtime.RawExtension `json:"resources,omitempty"`

exp/controllers/azureasomanagedcontrolplane_controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ func (r *AzureASOManagedControlPlaneReconciler) reconcileNormal(ctx context.Cont
206206
}
207207

208208
asoManagedControlPlane.Status.ControlPlaneEndpoint = getControlPlaneEndpoint(managedCluster)
209+
if managedCluster.Status.CurrentKubernetesVersion != nil {
210+
asoManagedControlPlane.Status.Version = "v" + *managedCluster.Status.CurrentKubernetesVersion
211+
}
209212

210213
return ctrl.Result{}, nil
211214
}

exp/controllers/azureasomanagedcontrolplane_controller_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) {
224224
Namespace: cluster.Namespace,
225225
},
226226
Status: asocontainerservicev1.ManagedCluster_STATUS{
227-
Fqdn: ptr.To("endpoint"),
227+
Fqdn: ptr.To("endpoint"),
228+
CurrentKubernetesVersion: ptr.To("Current"),
228229
},
229230
}
230231
asoManagedControlPlane := &infrav1exp.AzureASOManagedControlPlane{
@@ -275,6 +276,7 @@ func TestAzureASOManagedControlPlaneReconcile(t *testing.T) {
275276

276277
g.Expect(c.Get(ctx, client.ObjectKeyFromObject(asoManagedControlPlane), asoManagedControlPlane)).To(Succeed())
277278
g.Expect(asoManagedControlPlane.Status.ControlPlaneEndpoint.Host).To(Equal("endpoint"))
279+
g.Expect(asoManagedControlPlane.Status.Version).To(Equal("vCurrent"))
278280
})
279281

280282
t.Run("successfully reconciles pause", func(t *testing.T) {

templates/cluster-template-aks-aso-clusterclass.yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/cluster-template-aks-aso.yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/flavors/aks-aso-clusterclass/clusterclass.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ spec:
7777
path: /spec/template/spec
7878
valueFrom:
7979
template: |
80+
version: ${KUBERNETES_VERSION}
8081
resources:
8182
- apiVersion: containerservice.azure.com/v1api20231001
8283
kind: ManagedCluster

0 commit comments

Comments
 (0)