A Kubernetes cluster is controlled using the kubectl
command. The method of configuring kubectl
depends on where Kubernetes is installed.
To install kubectl using the Google Cloud SDK:
gcloud components install kubectl
To configure kubectl to control an existing Kubernetes cluster in Container Engine:
gcloud container clusters get-credentials $CLUSTER_NAME
When using minikube, the kubectl binary needs to be manually downloaded and placed in the path.
# Version of Kubernetes.
K8S_VERSION=$(curl -sS https://storage.googleapis.com/kubernetes-release/release/stable.txt)
# Operating System. Can be one of {linux, darwin}
GOOS=linux
# Architecture. Can be one of {386, amd64, arm64, ppc641e}
GOARCH=amd64
# Download and place in path.
curl -Lo kubectl http://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/${GOOS}/${GOARCH}/kubectl
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
The minikube binary automatically configures kubectl when starting a cluster.
minikube start
# kubectl is now ready to use!