Published on

Installing or Upgrading Kubectl

Authors

Today while interacting with a new Kubernetes cluster (version 1.11 of Kubernetes) I tried to delete a statefulset but received a cryptic error:

no kind "GetOptions" is registered for version "apps/v1"

After doing a quick search online I found that the cause of this is due to the Kubernetes statefulset API having changed in version 1.11. My kubectl client needed to be updated to the newest version in order to interact with this new cluster.

The official docs for installing kubectl refer you to a Github page with tars of the latests versions but they do not seem to be precompiled. Instead it seems that the easiest is to get the binary from storage.googleapis.com

The difficulty is working out what OS value to use as well as what architecture as there is no list of possible options. The storage api for kubectl uses the following form:

https://storage.googleapis.com/kubernetes-release/release/`versionYouWant`/bin/`os`/`cpuArchitecture`/kubectl

There is no complete list of this online but after a bit of Googling I came across this Gist and modified it to get specifically kubectl. To use gsutil from this gist you can install it using pip as outlines here * sudo pip install gsutil

My modified script to see possible OSs and architectures for a specific version can be found below:

> gsutil ls -R gs://kubernetes-release/release/v1.9.10 | grep -i kubectl
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/darwin/386/kubectl
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/darwin/386/kubectl.md5
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/darwin/386/kubectl.sha1
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/darwin/amd64/kubectl
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/darwin/amd64/kubectl.md5
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/darwin/amd64/kubectl.sha1
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/386/kubectl
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/386/kubectl.md5
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/386/kubectl.sha1
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/amd64/kubectl
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/amd64/kubectl.md5
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/amd64/kubectl.sha1
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/arm/kubectl
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/arm/kubectl.md5
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/arm/kubectl.sha1
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/arm64/kubectl
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/arm64/kubectl.md5
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/arm64/kubectl.sha1
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/ppc64le/kubectl
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/ppc64le/kubectl.md5
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/ppc64le/kubectl.sha1
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/s390x/kubectl
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/s390x/kubectl.md5
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/linux/s390x/kubectl.sha1
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/windows/386/kubectl.exe
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/windows/386/kubectl.exe.md5
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/windows/386/kubectl.exe.sha1
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/windows/amd64/kubectl.exe
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/windows/amd64/kubectl.exe.md5
    https://storage.googleapis.com/kubernetes-release/release/v1.9.10/bin/windows/amd64/kubectl.exe.sha1