Skip to content

Commit 7bc688a

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

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
@@ -465,6 +465,20 @@ func (r *VClusterReconciler) checkReadyz(vCluster *v1alpha1.VCluster, restConfig
465465
return false, nil
466466
}
467467

468+
// If readiness check passed, get the version info
469+
kubeClient, err := r.ClientConfigGetter.NewForConfig(restConfig)
470+
if err != nil {
471+
return true, fmt.Errorf("failed to create kubernetes client: %w", err)
472+
}
473+
474+
version, err := kubeClient.Discovery().ServerVersion()
475+
if err != nil {
476+
return true, fmt.Errorf("failed to get kubernetes version: %w", err)
477+
}
478+
479+
// Update the status with version information
480+
vCluster.Status.KubernetesVersion = version.GitVersion
481+
468482
return true, nil
469483
}
470484

0 commit comments

Comments
 (0)