Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubectl is not installed on GCE by default

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?

like image 504
Oleksandr Berezianskyi Avatar asked May 04 '15 12:05

Oleksandr Berezianskyi


People also ask

Does Gcloud install kubectl?

Cloud Shell comes preinstalled with the Google Cloud CLI and kubectl command-line tool. The gcloud CLI provides the primary command-line interface for Google Cloud, and kubectl provides the primary command-line interface for running commands against Kubernetes clusters.

What is GCE Kubernetes?

Google Kubernetes Engine (GKE) provides a managed environment for deploying, managing, and scaling your containerized applications using Google infrastructure. The GKE environment consists of multiple machines (specifically, Compute Engine instances) grouped together to form a cluster.

How do I know if kubectl is installed?

By default, kubectl configuration is located at ~/. kube/config . If you see a URL response, kubectl is correctly configured to access your cluster. If you see a message similar to the following, kubectl is not configured correctly or is not able to connect to a Kubernetes cluster.


3 Answers

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

  • You must have the Google Cloud SDK installed
  • For further information, Quick Start Guide
like image 122
Tom Kay Avatar answered Oct 02 '22 08:10

Tom Kay


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

like image 44
Robert Bailey Avatar answered Oct 02 '22 07:10

Robert Bailey


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

like image 31
Alex Robinson Avatar answered Oct 02 '22 09:10

Alex Robinson