How to connect to kubernetes cluster locally and open dashboard?

5/16/2018

I have a new laptop and kubernetes cluster running on Google Cloud Platform. How can I access that cluster from local machine to execute kubectl commands, open dashboard etc?

That is not clearly stated in the documentation.

-- shalakhin
google-cloud-platform
google-kubernetes-engine
kubernetes
shell

2 Answers

5/18/2018

The first thing you would need to do once you've installed Cloud SDK is ensure it is authenticated to your Google Cloud Platform account/project. To do this you need to run:

gcloud auth login

And then follow the on screen instructions.

Also you will need to install kubectl to access/control aspests of your cluster:

gcloud components install kubectl

You can also install it through native package management by following the instructions here.

Once your gcloud is authenticated to your project you can run this to ensure kubectl is pointing at your cluster and authenticated:

gcloud container clusters get-credentials CLUSTER_NAME --zone ZONE

You'll now be able to issue commands with kubectl that target the cluster you defined in the previous step.

You can access the dashboard following the instructions here.

-- neilH
Source: StackOverflow

5/16/2018

From your local workstation, you need to have the gcloud tool installed and properly configured to connect to the correct GCE account. Then you can run:

 gcloud container clusters get-credentials [CLUSTER_NAME]

This will setup kubectl to connect to your kubernetes cluster.

Of course you'll need to install kubectl either using gcloud with:

gcloud components install kubectl

Or using specific instructions for your operating system.

Please check the following link for more details: https://cloud.google.com/kubernetes-engine/docs/quickstart

Once you have kubectl access you can deploy and access the kubernetes dashboard as described here: https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/

-- whites11
Source: StackOverflow