Skip to content

Commit 0288f90

Browse files
committed
feat: surface machine version
Signed-off-by: Miltiadis Alexis <alexmiltiadis@gmail.com>
1 parent ab74f37 commit 0288f90

35 files changed

+1239
-75
lines changed

api/controlplane/kubeadm/v1beta1/conversion.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func (src *KubeadmControlPlane) ConvertTo(dstRaw conversion.Hub) error {
7979
if ok {
8080
bootstrapv1beta1.RestoreKubeadmConfigSpec(&restored.Spec.KubeadmConfigSpec, &dst.Spec.KubeadmConfigSpec)
8181
dst.Spec.MachineTemplate.Spec.Taints = restored.Spec.MachineTemplate.Spec.Taints
82+
dst.Status.Versions = restored.Status.Versions
8283
}
8384

8485
if src.Spec.RemediationStrategy != nil {

api/controlplane/kubeadm/v1beta1/zz_generated.conversion.go

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

api/controlplane/kubeadm/v1beta2/kubeadm_control_plane_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,17 @@ type KubeadmControlPlaneStatus struct {
713713
// +optional
714714
UpToDateReplicas *int32 `json:"upToDateReplicas,omitempty"`
715715

716+
// versions is the aggregated Kubernetes versions in this KubeadmControlPlane.
717+
// +optional
718+
// +listType=map
719+
// +listMapKey=version
720+
// +kubebuilder:validation:MaxItems=100
721+
Versions []clusterv1.StatusVersion `json:"versions,omitempty"`
722+
716723
// version represents the minimum Kubernetes version for the control plane machines
717724
// in the cluster.
725+
// Deprecated: This field is deprecated and is going to be removed in a future API version. Please use status.versions instead.
726+
//
718727
// +optional
719728
// +kubebuilder:validation:MinLength=1
720729
// +kubebuilder:validation:MaxLength=256

api/controlplane/kubeadm/v1beta2/zz_generated.deepcopy.go

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

api/core/v1beta1/conversion.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,20 @@ func (src *Cluster) ConvertTo(dstRaw conversion.Hub) error {
8989
if !reflect.DeepEqual(initialization, clusterv1.ClusterInitializationStatus{}) {
9090
dst.Status.Initialization = initialization
9191
}
92+
if ok {
93+
if restored.Status.ControlPlane != nil {
94+
if dst.Status.ControlPlane == nil {
95+
dst.Status.ControlPlane = &clusterv1.ClusterControlPlaneStatus{}
96+
}
97+
dst.Status.ControlPlane.Versions = restored.Status.ControlPlane.Versions
98+
}
99+
if restored.Status.Workers != nil {
100+
if dst.Status.Workers == nil {
101+
dst.Status.Workers = &clusterv1.WorkersStatus{}
102+
}
103+
dst.Status.Workers.Versions = restored.Status.Workers.Versions
104+
}
105+
}
92106
return nil
93107
}
94108

@@ -461,6 +475,7 @@ func (src *MachineSet) ConvertTo(dstRaw conversion.Hub) error {
461475
// Recover other values
462476
if ok {
463477
dst.Spec.Template.Spec.Taints = restored.Spec.Template.Spec.Taints
478+
dst.Status.Versions = restored.Status.Versions
464479
}
465480

466481
return nil
@@ -509,6 +524,7 @@ func (src *MachineDeployment) ConvertTo(dstRaw conversion.Hub) error {
509524
// Recover other values
510525
if ok {
511526
dst.Spec.Template.Spec.Taints = restored.Spec.Template.Spec.Taints
527+
dst.Status.Versions = restored.Status.Versions
512528
}
513529

514530
return nil
@@ -600,6 +616,7 @@ func (src *MachinePool) ConvertTo(dstRaw conversion.Hub) error {
600616
// Recover other values
601617
if ok {
602618
dst.Spec.Template.Spec.Taints = restored.Spec.Template.Spec.Taints
619+
dst.Status.Versions = restored.Status.Versions
603620
}
604621

605622
return nil
@@ -1259,6 +1276,16 @@ func Convert_v1beta1_ClusterClassStatus_To_v1beta2_ClusterClassStatus(in *Cluste
12591276
return nil
12601277
}
12611278

1279+
func Convert_v1beta2_ClusterControlPlaneStatus_To_v1beta1_ClusterControlPlaneStatus(in *clusterv1.ClusterControlPlaneStatus, out *ClusterControlPlaneStatus, s apimachineryconversion.Scope) error {
1280+
if err := autoConvert_v1beta2_ClusterControlPlaneStatus_To_v1beta1_ClusterControlPlaneStatus(in, out, s); err != nil {
1281+
return err
1282+
}
1283+
1284+
// Versions does not exist in the v1beta1 peer type and cannot be represented here.
1285+
// It is restored during full-object conversion from data preserved in annotations.
1286+
return nil
1287+
}
1288+
12621289
func Convert_v1beta2_ClusterStatus_To_v1beta1_ClusterStatus(in *clusterv1.ClusterStatus, out *ClusterStatus, s apimachineryconversion.Scope) error {
12631290
if err := autoConvert_v1beta2_ClusterStatus_To_v1beta1_ClusterStatus(in, out, s); err != nil {
12641291
return err
@@ -1416,6 +1443,16 @@ func Convert_v1beta2_Topology_To_v1beta1_Topology(in *clusterv1.Topology, out *T
14161443
return nil
14171444
}
14181445

1446+
func Convert_v1beta2_WorkersStatus_To_v1beta1_WorkersStatus(in *clusterv1.WorkersStatus, out *WorkersStatus, s apimachineryconversion.Scope) error {
1447+
if err := autoConvert_v1beta2_WorkersStatus_To_v1beta1_WorkersStatus(in, out, s); err != nil {
1448+
return err
1449+
}
1450+
1451+
// Versions does not exist in the v1beta1 peer type and cannot be represented here.
1452+
// It is restored during full-object conversion from data preserved in annotations.
1453+
return nil
1454+
}
1455+
14191456
func Convert_v1beta2_MachineDeploymentStatus_To_v1beta1_MachineDeploymentStatus(in *clusterv1.MachineDeploymentStatus, out *MachineDeploymentStatus, s apimachineryconversion.Scope) error {
14201457
if err := autoConvert_v1beta2_MachineDeploymentStatus_To_v1beta1_MachineDeploymentStatus(in, out, s); err != nil {
14211458
return err

api/core/v1beta1/zz_generated.conversion.go

Lines changed: 15 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/core/v1beta2/cluster_types.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,13 @@ type ClusterControlPlaneStatus struct {
14761476
// availableReplicas is the total number of available control plane machines in this cluster. A machine is considered available when Machine's Available condition is true.
14771477
// +optional
14781478
AvailableReplicas *int32 `json:"availableReplicas,omitempty"`
1479+
1480+
// versions is the aggregated Kubernetes versions in this control plane.
1481+
// +optional
1482+
// +listType=map
1483+
// +listMapKey=version
1484+
// +kubebuilder:validation:MaxItems=100
1485+
Versions []StatusVersion `json:"versions,omitempty"`
14791486
}
14801487

14811488
// WorkersStatus groups all the observations about workers current state.
@@ -1500,6 +1507,13 @@ type WorkersStatus struct {
15001507
// availableReplicas is the total number of available worker machines in this cluster. A machine is considered available when Machine's Available condition is true.
15011508
// +optional
15021509
AvailableReplicas *int32 `json:"availableReplicas,omitempty"`
1510+
1511+
// versions is the aggregated Kubernetes versions in cluster workers.
1512+
// +optional
1513+
// +listType=map
1514+
// +listMapKey=version
1515+
// +kubebuilder:validation:MaxItems=100
1516+
Versions []StatusVersion `json:"versions,omitempty"`
15031517
}
15041518

15051519
// SetTypedPhase sets the Phase field to the string representation of ClusterPhase.

api/core/v1beta2/common_types.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,20 @@ var NodeOutdatedRevisionTaint = corev1.Taint{
267267
Effect: corev1.TaintEffectPreferNoSchedule,
268268
}
269269

270+
// StatusVersion groups version-related status information.
271+
// +kubebuilder:validation:MinProperties=1
272+
type StatusVersion struct {
273+
// version is the Kubernetes version.
274+
// +required
275+
// +kubebuilder:validation:MinLength=1
276+
// +kubebuilder:validation:MaxLength=256
277+
Version string `json:"version"`
278+
279+
// replicas is the number of replicas at this version.
280+
// +optional
281+
Replicas *int32 `json:"replicas,omitempty"`
282+
}
283+
270284
// NodeUninitializedTaint can be added to Nodes at creation by the bootstrap provider, e.g. the
271285
// KubeadmBootstrap provider will add the taint.
272286
// This taint is used to prevent workloads to be scheduled on Nodes before the node is initialized by Cluster API.

api/core/v1beta2/machinedeployment_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,13 @@ type MachineDeploymentStatus struct {
460460
// +optional
461461
UpToDateReplicas *int32 `json:"upToDateReplicas,omitempty"`
462462

463+
// versions is the aggregated Kubernetes versions in this MachineDeployment.
464+
// +optional
465+
// +listType=map
466+
// +listMapKey=version
467+
// +kubebuilder:validation:MaxItems=100
468+
Versions []StatusVersion `json:"versions,omitempty"`
469+
463470
// phase represents the current phase of a MachineDeployment (ScalingUp, ScalingDown, Running, Failed, or Unknown).
464471
// +optional
465472
// +kubebuilder:validation:Enum=ScalingUp;ScalingDown;Running;Failed;Unknown

api/core/v1beta2/machinepool_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ type MachinePoolStatus struct {
138138
// +optional
139139
UpToDateReplicas *int32 `json:"upToDateReplicas,omitempty"`
140140

141+
// versions is the aggregated Kubernetes versions in this MachinePool.
142+
// +optional
143+
// +listType=map
144+
// +listMapKey=version
145+
// +kubebuilder:validation:MaxItems=100
146+
Versions []StatusVersion `json:"versions,omitempty"`
147+
141148
// phase represents the current phase of cluster actuation.
142149
// +optional
143150
// +kubebuilder:validation:Enum=Pending;Provisioning;Provisioned;Running;ScalingUp;ScalingDown;Scaling;Deleting;Failed;Unknown

0 commit comments

Comments
 (0)