client-go
client-go copied to clipboard
"k8s.io/client-go/pkg/version".Get() not returning a valid Kubernetes client version
Hi! I'm trying to get the client version programmatically, similar to the kubectl version
command.
I'm using the Get()
method defined in the k8s.io/client-go/pkg/version
package to get the client version.
package main
import (
"fmt"
"k8s.io/client-go/pkg/version"
)
func main() {
clientversion := version.Get()
fmt.Println(test.String())
}
Executing the above code snippet, I'm getting the output below:
v0.0.0-master+$Format:%H$
Is there anything that I'm missing? If so, could you please tell me the best way to get the Client version?
Below is the output of kubectl version
CLI command:
kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short. Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.2", GitCommit:"7f6f68fdabc4df88cfea2dcf9a19b2b830f1e647", GitTreeState:"clean", BuildDate:"2023-05-17T14:13:27Z", GoVersion:"go1.20.4", Compiler:"gc", Platform:"darwin/arm64"}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.3", GitCommit:"9e644106593f3f4aa98f8a84b23db5fa378900bd", GitTreeState:"clean", BuildDate:"2023-03-15T13:33:12Z", GoVersion:"go1.19.7", Compiler:"gc", Platform:"linux/arm64"}
Thanks!