Cloud Computing, Google Cloud (GCP)

4 Mins Read

Deploying a Highly Available and Scalable JAVA Tomcat Application on Google Kubernetes Engine (GKE)

Introduction

Google Kubernetes Engine is a fully managed Kubernetes cluster offered by Google Cloud Platform.

GKE offers two modes of the operational cluster: Standard and Autopilot.

In this blog, we are going to deploy a highly available application on GKE with a step-by-step guide.

GKE

Perquisites:

  1. A GCP Account
  2. A sample WAR application
  3. A MySQL instance if you have a database connected with the application

Kubernetes components to be covered:

  1. Deployment
  2. Service
  3. Ingress
  4. Secrets(tls)

Step by Step Guide

Step 1: Activate GCP Cloud Shell by clicking on the icon GKE icon from the right top of the console

It will activate the Cloud Shell as per below:

GKE

Note: The Project has already been selected as we open Cloudshell from web browser. Use gcloud config set project [PROJECT_ID] to change project.

Step 2: Create a ct-demo repository for storing container images in the Docker repository

Step 3: Create a Dockerfile

Step 4: Upload your WAR application in CloudShell

GKE

GKE

Step 5: Create Docker image from Dockerfile in the same directory where WAR file is uploaded

Output:

Note: The PROJECT_ID is environment variable to store Project ID information. Instead of env variable you can also use paste Project ID directly in above command

Step 6: Push Docker Image in Artifact repository created in Step 2

Step 7: Create GKE Cluster

Step 8: Create deployment.yml from below textbox and run command

Step 9: Create service.yml from below textbox and run command

Step 10: Upload SSL to cloud shell and add SSL into secrets that Ingress controller will use for SSL-termination

Step 11: Create ingress.yml from below textbox and run the command

Step 12: Review all the resources and test your application by requesting an External IP of the ingress controller

Output:

Optional:

To Create HorizontalPodAutoscaler on deployment on the basis of CPU usage

Keep it up! You have deployed a highly available and scalable Tomcat application on GKE

I hope you find this blog helpful for your Kubernetes (GKE) journey

Please do not forget to delete resources to avoid incurring charges to your Google account using the below commands

Conclusion:

Kubernetes works on the same design principles that run popular Google services and provides the same advantages as automatic management, monitoring, and liveness probes for application containers, automatic scaling, rolling updates, and more. When running your applications on a cluster, you use Google’s 10+ years of technology and experience to run production workloads in containers.

For detailed information on Kubernetes works, here is a blog on Beginner’s Guide with Real-world Illustration

About CloudThat

We here at CloudThat are the official Google Cloud Partner, AWS Advanced Consulting Partner, Microsoft gold partner, helping people develop knowledge on cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

Feel free to drop a comment or any queries that you have regarding Google Cloud Platform, Google Kubernetes Engine, consulting requirements and we will get back to you quickly. To get started, go through our Expert Advisory page and Managed Services Package that is CloudThat’s offerings.

WRITTEN BY CloudThat

SHARE

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!