Support us on YouTube by Subscribing our YouTube Channel. Click here to Subscribe our YouTube Channel

Thursday, 20 August 2020

Working up with Google Kubernetes Engine in Google Cloud Platform

In this article, we will learn How to get started with GKE i.e. Google Kubernetes Engine in Google Cloud Platform. GKE provides the easiest and simplest way to set up the Kubernetes cluster. Kubernetes (K8s) is an Open Source system for automating deployment, scaling, and management of the containerized applications.

Few Articles, which I already wrote and might be helpful for you if you are beginning with Google Cloud Platform are:


Let’s begin:

Step 1:

Log in to the Google Cloud Platform by visiting https://console.cloud.google.com/ (Google provides $300 as a free trial, but for that, you need to link your credit card).

Once logged in, you will be redirected to the dashboard of the Google Cloud Platform.
Step 2:
Before creating a Kubernetes cluster, we need to make sure that Kubernetes Engine API and Container Registry API. Click on Dashboard Submenu available under API & Services Menu.
Search Kubernetes Engine API and Container Registry API and make sure that both API Status is Enabled.


Step 3:

We can create the Kubernetes Cluster either by Google Cloud Shell or with Google Cloud Console.  Let’s see how to create the Kubernetes cluster in both ways. Click on Google Cloud Shell Icon in order to connect with google cloud through the command line.

For ease, let’s Set up the environment variable MY_ZONE and pass the zone in which we want to create our Kubernetes Cluster. We can also pass the zone directly in the command without using the environmental variable.

Step 4:
Create the Kubernetes Cluster with the below command in Google Cloud Shell.
gcloud container clusters create <NAME_OF_CLUSTER> --zone $MY_ZONE –num-nodes 2
You can also pass the –machine-type if want a specific machine type configuration in the above command. On running the above command, you will see the message like shown in the below image on the successful creation of the Kubernetes Cluster.
We can also check the Cluster by clicking on Clusters submenu of the Kubernetes Engine menu.
You can see the Kubernetes Cluster created by us in the above steps with Cluster size as 2.
We can also create the Kubernetes Cluster by clicking on the create cluster button and providing the Cluster Details like Cluster Name, Location as well as details related to the Nodes like the size of Nodes, enable autoscaling.

Now, Let’s check the VM Instances created by Clicking VM Instances Sub menu in Compute Engine Menu. You can clearly see that 2 VM Instances are up and ready for use.

Step 5:

Kubernetes command-line tool i.e. Kubectl allows us to run the command against the Kubernetes cluster. In case you need to check the kubectl version use kubectl version command.

Let’s deploy the Nginx image with the kubectl command as shown below. You can use an image as per your need. In Kubernetes, all containers run in a pod. If pod count not provided, a single pod will be created.

Now let’s check the status of the pods with kubectl get pods command. In the below image, you can clearly see the status of the Pod is running.
Once all pods are in running state, we can expose the ngnix cluster as an external service. Expose the ngnix cluster as an external service. The below command will create a network load balancer to balance the network traffic.
Now, run kubectl get services and check the External_IP assigned against the Load balancer. It will take around a minute to see the value of External_IP. If not shown, wait for a minute and re-run the command to check again the External_IP.
Step 6:
Visit the external IP to see that server is being served through the load balancer.
We can scale up pods running for the service with the below command.
Once executed, we can check the number of pods with the kubectl get pods command. We can clearly see that now pods count is increased to 3.
Let’s again check the external IP associated with load balancer service with the kubectl get services. On Increasing the pods/replica, our associated external I.P. is not affected.

Again, access the application with the browser by using the external I.P. Address. Our application is still running in perfect condition after scaling up the application. 

I hope this article will help you in getting started with Google Kubernetes Engine in Google Cloud Platform.

0 comments:

Post a Comment

Subscribe us on YouTube

Subscribe Now

Popular Posts

Contact us

Name

Email *

Message *

Like us on Facebook