Configuring Google Cloud

This topic describes how to configure your Google Cloud environment.

Create a Google Cloud Project

A project is required to consume any Google Cloud services, including GKE clusters. When you log into the console you can select or create a project from the dropdown at the top.

Create an environment variable, replacing ??? with your project ID.

export GCP_PROJECT_ID=???

Install the gcloud SDK

Follow the quickstart instructions to install the Google Cloud SDK which includes the gcloud CLI. You may need to add the google-cloud-sdk/bin directory to your path. Once installed, gcloud init will open a browser to start an oauth flow and configure gcloud to use your project.

gcloud init

Configure Docker Credential Helper for gcr

Configure your docker environment to push images to Google Container Registry:

gcloud components install docker-credential-gcr
docker-credential-gcr configure-docker

This is only needed once for a new install of docker.

Install kubectl

Kubectl is the Kubernetes CLI. It is used to manage minikube as well as hosted Kubernetes clusters like GKE. If you don’t already have kubectl on your machine, you can use gcloud to install it.

gcloud components install kubectl

Configure gcloud

Check your default project, region, and zone, and list your available projects

gcloud config list
gcloud projects list

If necessary change the default project.

gcloud config set project $GCP_PROJECT_ID

To list the available compute regions and zones:

gcloud compute zones list

To change the default region and zone:

gcloud config set compute/region us-east4
gcloud config set compute/zone us-east4-c
gcloud config list compute/

Enable the necessary APIs for gcloud. The following are required for GCR and GKE. You may also need to enable billing for your project.

gcloud services enable \
  cloudapis.googleapis.com \
  container.googleapis.com \
  containerregistry.googleapis.com