Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify kubectl client version installed via gcloud SDK

I probably missed this in the docs somewhere, but since I haven't found it yet, I'll ask: How can I specify the version of kubectl CLI when installing with the gcloud SDK?

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"13+", GitVersion:"v1.13.9-2+4a03651a7e7e04", GitCommit:"4a03651a7e7e04a0021b2ef087963dfb7bd0a17e", GitTreeState:"clean", BuildDate:"2019-08-16T19:08:17Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"13+", GitVersion:"v1.13.7-gke.24", GitCommit:"2ce02ef1754a457ba464ab87dba9090d90cf0468", GitTreeState:"clean", BuildDate:"2019-08-12T22:05:28Z", GoVersion:"go1.11.5b4", Compiler:"gc", Platform:"linux/amd64"}
$ gcloud components update

All components are up to date.
$ which kubectl
/Users/me/Projects/googlecloud/google-cloud-sdk/bin/kubectl
$ which gcloud
/Users/me/Projects/googlecloud/google-cloud-sdk/bin/gcloud
$ ls -nL /Users/me/Projects/googlecloud/google-cloud-sdk/bin | grep kubectl
-rwxr-xr-x   1 501  20  44296840 Aug 16 12:08 kubectl
-rwxr-xr-x   1 501  20  54985744 Apr 30 21:56 kubectl.1.11
-rwxr-xr-x   1 501  20  56860112 Jul  7 21:34 kubectl.1.12
-rwxr-xr-x   1 501  20  44329928 Aug  5 02:52 kubectl.1.13
-rwxr-xr-x   1 501  20  48698616 Aug  5 02:55 kubectl.1.14
-rwxr-xr-x   1 501  20  48591440 Aug  5 02:57 kubectl.1.15

So I'm using the gcloud-installed kubectl, and I see that the version I want is locally installed. The gcloud components update command run previously indicated that kubectl would be set to the default version of 1.13, but I haven't caught any indication of how to change the default version.

I imagine I could create a link, or copy the version I want onto Users/me/Projects/googlecloud/google-cloud-sdk/bin/kubectl, but I'm leary of messing with the managed environs of gcloud.

like image 898
Ben Avatar asked Mar 04 '23 12:03

Ben


2 Answers

Whelp, I went ahead and ran the following

KUBE_BIN=$(which kubectl)
rm $KUBE_BIN
ln ~/googlecloud/google-cloud-sdk/bin/kubectl.1.15 $KUBE_BIN

and now i get

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.2", GitCommit:"f6278300bebbb750328ac16ee6dd3aa7d3549568", GitTreeState:"clean", BuildDate:"2019-08-05T09:23:26Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"darwin/amd64"}

and everything seems to be working just fine...

like image 108
Ben Avatar answered Mar 08 '23 14:03

Ben


IIRC you cannot.

But, as you show, you have multiple major-minor versions available and, because kubectl is distributed as a static binary, you can, e.g.

kubectl1.15 version
like image 40
DazWilkin Avatar answered Mar 08 '23 13:03

DazWilkin