kubectl is not installed on GCE by default

5/4/2015

Following the guide I'm trying to manage Google Container Engine cluster from another machine on Google Compute Engine. Here is the output from my GCE instance:

oleksandr_berezianskyi_gmail_com@docker-managed-jenkins:~$ sudo gcloud components update preview
All components are up to date.
oleksandr_berezianskyi_gmail_com@docker-managed-jenkins:~$ sudo gcloud components update alpha
All components are up to date.
oleksandr_berezianskyi_gmail_com@docker-managed-jenkins:~$ gcloud alpha container kubectl create -f cassandra.yaml
ERROR: (gcloud.alpha.container.kubectl) This command requires the kubernetes client (kubectl), which is installed with the gcloud preview component. Run 'gcloud components update preview', or make sure kubectl is installed somewhere on your
 path.

As you see my Google Cloud SDK seems to be up-to-date but still not working properly on GCE. Is there something I'm missing?

-- Oleksandr Berezianskyi
google-compute-engine
google-kubernetes-engine

4 Answers

11/5/2015

The correct way to install kubectl is now gcloud components install kubectl

-- Tom Kay
Source: StackOverflow

5/4/2015

If you have run gcloud components update that will install the kubectl binary on your system, it just won't be in your path. It will be located in the cloud-sdk install directory. You can add it to your path manually by running

export PATH=$PATH:/usr/local/share/google/google-cloud-sdk/bin/

or you can create a symlink from a directory that is already in your path, like /usr/local/bin by running

sudo ln -s /usr/local/share/google/google-cloud-sdk/bin/kubectl /usr/local/bin/kubectl

-- Robert Bailey
Source: StackOverflow

11/28/2016

As of (at least) 138.0.0 (Nov 2016)

It's now gcloud components install kubectl

This is when running:

Your current Cloud SDK version is: 138.0.0

Here are the related instructions:

To install or remove components at your current SDK version [138.0.0], run:
  $ gcloud components install COMPONENT_ID
  $ gcloud components remove COMPONENT_ID

To update your SDK installation to the latest version [141.0.0], run:
  $ gcloud components update
-- Daniel Lee
Source: StackOverflow

5/4/2015

You can download the current version of the kubectl binary from this Google Cloud Storage URL: https://storage.googleapis.com/kubernetes-release/release/v0.18.2/bin/linux/amd64/kubectl

-- Alex Robinson
Source: StackOverflow