Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/v1alpha1/vcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ type VClusterStatus struct {
// ObservedGeneration is the latest generation observed by the controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// KubernetesVersion is the version of Kubernetes running in the virtual cluster
// +optional
KubernetesVersion string `json:"kubernetesVersion,omitempty"`
}

// GetConditions returns the set of conditions for this object.
Expand Down
14 changes: 14 additions & 0 deletions controllers/vcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,20 @@ func (r *VClusterReconciler) checkReadyz(vCluster *v1alpha1.VCluster, restConfig
return false, nil
}

// If readiness check passed, get the version info
kubeClient, err := r.ClientConfigGetter.NewForConfig(restConfig)
if err != nil {
return true, fmt.Errorf("failed to create kubernetes client: %w", err)
}

version, err := kubeClient.Discovery().ServerVersion()
if err != nil {
return true, fmt.Errorf("failed to get kubernetes version: %w", err)
}

// Update the status with version information
vCluster.Status.KubernetesVersion = version.GitVersion

return true, nil
}

Expand Down