Deploying A Kubernetes Cluster Using Google Kubernetes Engine(GKE)
Tags: cloudnative, gcp, kubernetes, tutorial
Published: 2022-12-08 13:52:21


The advent and widespread adoption of virtualisation in the world of computing has not  exactly been a smooth journey. There is a constant need for these technologies to be improved. One of these improvements brought about containerization, which is a standalone and lightweight package of an application and its dependencies such as libraries, framework and runtime.  The difficulty in managing multiple containers necessitated the advent of Kubernetes(K8s). 

Kubernetes is an open source platform for container orchestration, that is, it is used in the management of containerized applications. It was initially a proprietary technology of Google but considering  its industry wide usage and increasing popularity and adoption it was open sourced in the year 2014. 

K8s was developed to abstract and ease the tedious task of creating, managing, and destroying multiple containers and most significantly to have a central control plane to monitor the execution and operation of various deployments.



The adoption of Kubernetes has been made more accessible to beginners by Google Cloud’s managed Kubernetes service known as Google Kubernetes Engine (GKE). It simplifies the creation, management, deployment and monitoring of Kubernetes clusters. 

Before we begin I will like to define some basic concepts to introduce a number of technologies to persons who might not be conversant with Kubernetes or are just starting out. 

**Pods** : A pod is simply an abstraction of multiple containers. Containers need to communicate with each other, thus a pod facilitates this by allowing containers to share storage and networking resources.

**Deployment file** : Containers and pods are ephemeral, meaning they do not persist forever. Thus a deployment file defines the number of pods to be created 

**Service** : A service refers to how we choose to expose our pods

**Nodes** : These refer to the underlying compute resources (virtual machines/instances) that a Kubernetes cluster is setup on. In the case of GCP, compute engine, and EC2 instance for AWS.

This demonstration on how to deploy a Google Kubernetes Engine has three principal objectives.

Firstly, to build and modify GKE clusters using the Google Cloud Console.

Secondly, to deploy a Pod using the Google Cloud Console.

Thirdly, to monitor and examine the provisioned cluster and pods.

Let’s get started!

To begin with, you need to be registered as a GCP user. The process involved to do this is simple and you can easily set up your account by following the step by step guide offered on the Google cloud website https://console.cloud.google.com/ Alternatively you can register an account on Qwiklabs https://www.cloudskillsboost.google/ to follow this demonstration.

Now that we have explored the various means to access the Google Cloud console we can login and access the GCP console.

**_A. Click on the navigation menu and select Kubernetes Engine. Select clusters from the options provided_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ldfcspdeb8dvwac6ypid.png)

&nbsp;


**_B. Click create from the open dialog box_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oj0jfszhopmw7ayzlybn.png)

&nbsp;





**_C. Choose the ’Standard’ configuration_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/54mcani9a5dl5ib5w3w1.png)

&nbsp;



The console shows the various fields you can fill to enter the configuration details for the cluster. Depending on your workload and the amount of capacity you will need, you can provision the amount of nodes you will require, machine type and the location closest to your end users to reduce latency.

**_D. I am  creating this cluster in the ‘us-central1a’ and naming it standard-cluster-1’.  For this demonstration I will accept the defaults and click ‘create’. (I will not delve into advanced configurations since this article seeks to provide a simple introduction of working with GKE)_** ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j3a3belf31tr70xgbqaz.png)

&nbsp;



**_E. It can take a while for the clusters to be provisioned. As shown below(in the area I’ve marked up)I have been prompted that my cluster creation ‘can take up to five minutes or more’_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/upbvi3me8vhf7owxltur.png)

&nbsp;




**_F. As you can see, the cluster was successfully created_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hsv3pmse23g970t4ftp8.png)

A great benefit of running workloads in the cloud is the elasticity it provides. This section of my demonstration will be on how to perform a simple modification of a GKE Cluster.  For instance, while hosting a workload on GKE, more compute resources are needed in your use case. You can simply provision additional nodes as required.


**_G. Click on the navigation menu and select Kubernetes Engine. Select clusters from the options provided and click on ’standard-cluster-1’_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/paaf4pr39ts9lj0ugs5x.png)

&nbsp;


**_H. Click on default pool from the node pools section_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4hnybxjo4qqqoh2hwid2.png)

&nbsp;




**_I. Select “RESIZE” at the top of the default pool page_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bw8o3bs5k52l6uht1oxe.png)

&nbsp;


**_J. Modify the number of nodes from 3 to 4 and click on the “RESIZE” button_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xq6kecniumgp1nsdphca.png)

&nbsp;



We will now deploy a workload. A reverse proxy will be run in a deployed pod.  The reverse proxy will be using is an NGINIX web server.

**_K. As usual we will go to the navigation menu and select Kubernetes Engine. Select “Workloads” from the options listed.  A dialog box opens, click on “Deploy”_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tl244n0k7kxwsoglny5n.png)

&nbsp;


**_L. The default container image is “nginix” . This is the latest version so we can proceed and click on “Continue”. (For security purposes and as prescribed by best practices you should configure environment variables when deploying your workload)_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6kb4wovi7f2292q6v3zf.png)

&nbsp;

**_M. At the bottom of the page there a number of fields we can modify to suit our application needs. As you can see the cluster we created (standard-cluster-1) is available so we can go ahead and click on “DEPLOY”_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qo77i9jpqrr9eatvs5io.png)

&nbsp;

**_N. After a short while we can see our deployment is completed_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wztunfl1w9tzb4i2dgqm.png)


Now we can examine the details of our deployed pods 

**_O. Here is an overview of some events and key metrics such as disk usage, CPU and memory consumption.  These metrics coupled with logs are what monitoring and observability tools like Prometheus and Grafana ingest to provide analytics, insights, and even for data visualization to meet business needs._**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/61f6hxbnze8hs8hnko1z.jpg)

&nbsp;

**EVENTS**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kx7ur58xbsdeyj0htbem.png)



**YAML**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f4dvbeatqnl60mtoc5kl.png)




**_The YAML find for the configuration of the workload can also be viewed on the YAML tab_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/stmv68ybxi6ar3nsma49.png)







**_Similarly, a granular visibility into the deployed pods can be done by selecting any of these pods under the “Managed pods” section_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yktddj6g6bsgo2zgdmzz.png)



**_Key metrics of deployed pods_**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tek7hfvyydmrzxv7k7ei.png)




**_Events indicating the timestamps the pods were created along with their  current states._**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u74i6ppdi9r0lcm3r0lk.png)




**_The YAML tab also provides an overview of the YAML files used in configuring the pod._**![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h89g31whuwp4mq19oorh.png)

&nbsp;


This article has sought to provide a simple and introductory level understanding of container orchestration using Kubernetes and how you can get started with it in GCP by using GKE to deploy your containerized workloads.