Open In App

Creating a GKE Cluster and Deploying a Container

Last Updated : 17 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Pre-requisite: GCP

          In this article, we are going to see how we can create a Google Kubernetes Engine Cluster for deploying a Containerized application. We are also going to see how we can deploy a containerized application in this cluster. We will use a simple application by GCP (Google Cloud Platform) which runs through an NGINX server. So, let’s get to it.

GKE Cluster: Google Kubernetes Engine Cluster is a collection of VM nodes, and a Master Node called a Cluster control plane. The master node handles the worker nodes while the application is run by worker nodes.

Container: A container is a small package of applications with its dependencies.

Containerized Application: Containerized application is software that runs in isolated containers.

Steps to create a GKE cluster in GCP

Step 1: 

On the GCP console navigate to Kubernetes Engine > Clusters. On the cluster page click Create. If you want to manage your cluster on your own, then select standard else select autopilot mode which manages the cluster automatically. Once you decide then click on configure.

Cluster page

 

Step 2: Type your desired cluster name and select the GCP region where you want to create a cluster.

Name & region

 

Step 3: Click Next and select your network and subnet. For now, we have selected the default network. Choose your network access. Select public if you want to access the cluster from the internet else select private.

Select Network and subnet

 

Step 4: Select the pod IP address range and service IP range. Specify tags if you want.

Pod IP & Service IP

 

Step 5: Click next and configure advanced settings accordingly else leave it to default. Then click review and create. After review click create. The cluster deployment will take around 7-10 minutes. On the overview page, if the status shows a green checkmark, then your cluster is ready to use.

Configure Service mesh, Security & Metadata

 

Cluster status check

 

Steps to deploy a containerized application (As Containers) in the GKE cluster

Step 1: On the cluster overview page click on DEPLOY. Specify your container image you can select an existing image or create a new image. For this tutorial, we are using the default nginx template image. You can specify the init command according to your application.

Select image

 

Step 2: Click Continue. Under Configuration specify your application/deployment name. you can add a label apart from the default app label. You can also add a YAML file for configuration details. Then select your GKE cluster from the list.

Configure Deployment name, Namespace & labels

 

 

Step 3: Click Continue. Check Expose deployment as a new service. This will allow our nginx server to be exposed to the internet. Specify ports accordingly. Keep everything else default and click Deploy. Once the deployment is successful go to Workloads from the sidebar. Select the deployed app from the overview page. On the deployment overview page, you can view containers and pods.

Expose deployment

 

Workloads

 

Select pod

 

Step 4: Finally, scroll to the bottom to see the exposed service.

Exposed services

 

Step 5: Click on Endpoint URL to view the application in the browser. In our case, we will see the default NGINX page.

Access application

 

 


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads