How To Setup and Configure Kubernetes Cluster On Google Cloud (GCE)

Google cloud offers its own managed Kubernetes cluster setup using google container engine aka GKE. If you use GKE you can avoid the Kubernetes administrative overhead as it is taken care by Google cloud. You just need to focus on deploying applications on Kubernetes.

Prerequisites: To follow this tutorial, you should have a Google Cloud account and google cloud SDK installed on your system. If you don’t have google cloud SDK installed, you can follow this tutorial for the setup –> Google cloud SDK setup

Setting Up Kubernetes Cluster On Google Cloud

In this tutorial, we will guide you through the steps for setting up a highly available multi zone kubernetes cluster. Follow the steps given below for the setup.

Step 1: We will launch a multi-zone cluster using the gcloud CLI. The syntax for launching a kubernetes cluster is given below.

In this example, I am spinning up the cluster in asia-east1 region with one instance per zone (total three zones) using g1-small(1.7GB) machine type. The actual command would look like the following.

Now, if you check the google compute engine dashboard, you can see three instances launch in three different zones as shown below.

READ  How to Setup Prometheus Monitoring On Kubernetes Cluster

google container engine instances

Step 2: You can get all the information about the  GKE cluster using the following command.

Syntax:

Example Command:

Kubectl Utility

Kubectl is a command line utility for interacting with the kubernetes cluster. You can get more information about kubectl from here 

To install kubectl component, execute the following gcloud command.

Now, you can get your cluster info using kubectl command using the following command.

Accessing Kubernetes Dashboard

Kubernetes has a web UI where you can monitor and manage your deployed application. The web UI is a part of Kubernetes so you cannot access it from google cloud dashboard. You can read more about the web dashboard from here. Follow the steps given below to access the web UI.

1. Head over to google cloud dashboard –> Container Engine –> Container Clusters. There you will find a connect option as shown below. Once you click the connect button, you will see a pop up with two commands.

kubernetes dashboard

Popup will look like the following.

connecting kubernetes dashboard

2. Execute the commands as shown in the pop-up. An example is shown below.

The following command will set the credentials on your local machine to authenticate to kubernetes cluster.

Then, you need to start the proxy using the following command.

READ  Docker Tutorial : Getting Started With Docker Swarm

BY default, you will be able to access kubernetes on http://localhost:8001/ui. You can also run the proxy in different port using the –port flag as shown below.

You can run the proxy in the background by adding a & at the end of the command as shown below.

If you access the web UI, by default you will be able to view only the cluster node information as shown below. Once you start deploying applications, you can monitor and manage it from the UI.

kubernetes dashboard

Launching a kubernetes cluster on google cloud is very simple as compared to AWS or on-prem data center setups. In the coming series of articles, we will cover more articles on how to deploy and manage applications on a kubernetes cluster.


ONLINE COURSE: The Complete Kubernetes Course

Learn how you can run, deploy, manage and maintain containerized Docker applications on Kubernetes

  • Learn to launch kubernetes cluster
  • Get started with Containerization of apps
  • Deploy applications on kubernetes cluster
  • Run stateful and stateless applications on containers

 

Free DevOps Resources

Get DevOps news, tutorials and resources in your inbox. A perfect way If you want to get started with devops. Like you, we dont like spam.

Leave a Reply

Your email address will not be published. Required fields are marked *