Gain kubectl & helm access to a hub

Each of the hubs in the 2i2c Pilot runs on Google Cloud Platform and Kubernetes. To access the Kubernetes objects (in order to inspect them or make changes), use the kubectl command line tool.

Project Access

First, you’ll need to access the Google Cloud projects on which the hubs run. You can find the current list of active projects by examining the gcp.project values in the files under config/hubs/*.cluster.yaml.

Commandline tools installation

You can do all this via Google Cloud Shell, but might be easier to do this on your local machine. You’ll need the following tools installed:

  1. gcloud

  2. kubectl

  3. helm

Authenticating

First, you need to gcloud auth login, so you can perform gcloud operations. Next, you need to do gcloud auth application-default login so kubectl and helm could use your auth credentials.

Fetch Cluster credentials

For each cluster, you’ll need to fetch credentials at least once with gcloud container clusters get-credentials.

gcloud container clusters get-credentials <cluster-name> --region <region> --project <project-name>

You can get authoritative information for <cluster-name>, <zone> and <project-name> from files under config/hubs.

With that, kubectl and helm should now work!

(Optional) Access via Google Cloud Shell

Instead of setting up the tools & authenticating locally, you can do all this via Google Cloud Shell. It has all the tools installed, and the authentication done. Instead of doing gcloud container clusters get-credentials yourself, you can instead:

  1. Go to the Google Cloud Kubernetes Engine page (for the appropriate project)

  2. Click on Connect, as seen in the figure below.

    ../../_images/gcp-k8s-dashboard.png
    ../../_images/gcp-run-in-shell.png
  3. This will spin up an interactive cloud shell where you have kubectl access.