[root@gx dashboard]# kubectl get node
NAME STATUS ROLES AGE **VERSION**
minikube Ready master 7d20h **v1.15.0**
returns the version for a particular node. How do I do this using client-go?
Sample code for getting Kubernetes version from NodeInfo
using Go-client:
// Create clientset
clientset, err := kubernetes.NewForConfig(config)
if err != nil {
panic(err.Error())
}
// Get node object
node, err := clientset.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{})
if err != nil {
panic(err.Error())
}
// You can read Kubernetes version from either KubeletVersion or KubeProxyVersion
kVersion := node.Status.NodeInfo.KubeletVersion
// kVersion := node.Status.NodeInfo.KubeProxyVersion
fmt.Println(kVersion)