Skip to content

Commit d360641

Browse files
Jeff Rosejohannesfrey
authored andcommitted
feat: add kubernetes version to status column
1 parent 7e69ad9 commit d360641

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

api/v1alpha1/vcluster_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ type VClusterStatus struct {
7272
// ObservedGeneration is the latest generation observed by the controller.
7373
// +optional
7474
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
75+
76+
// KubernetesVersion is the version of Kubernetes running in the virtual cluster
77+
// +optional
78+
KubernetesVersion string `json:"kubernetesVersion,omitempty"`
7579
}
7680

7781
// GetConditions returns the set of conditions for this object.

controllers/vcluster_controller.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,20 @@ func (r *VClusterReconciler) checkReadyz(vCluster *v1alpha1.VCluster, restConfig
471471
return false, nil
472472
}
473473

474+
// If readiness check passed, get the version info
475+
kubeClient, err := r.ClientConfigGetter.NewForConfig(restConfig)
476+
if err != nil {
477+
return true, fmt.Errorf("failed to create kubernetes client: %w", err)
478+
}
479+
480+
version, err := kubeClient.Discovery().ServerVersion()
481+
if err != nil {
482+
return true, fmt.Errorf("failed to get kubernetes version: %w", err)
483+
}
484+
485+
// Update the status with version information
486+
vCluster.Status.KubernetesVersion = version.GitVersion
487+
474488
return true, nil
475489
}
476490

0 commit comments

Comments
 (0)