Home / Google Cloud / Deploy Microservices to Google Kubernetes Engine

Deploy Microservices to Google Kubernetes Engine

Last updated on May 11th, 2023

Estimated reading time: 5 minutes

Kubernetes is most popular open-source container orchestration platform.Google Kubernetes engine is fully managed service offering by Google Cloud platform.

Google Kubernetes features

  • Auto repair and Auto Upgrade
  • POD and cluster auto-scaling
  • Seamless integration with cloud logging, monitoring and other GCP services.
  • Uses container optimized OS Hardened OS built by Google.

If you are new to Google cloud platform refer article to create tier account here Google cloud free tier account – Full Stack Tutorials Hub . Free Tier account provides 300 $ credit to learn and explore google cloud services.

Google Kubernetes Engine Cluster Set up using cloud console

  1. Create a new Google cloud project.
project create

2. Enable GKE API. Search for Google Kubernetes API and enable GKE API in your project.

API

3. Cluster set up from google cloud console .Search for Google Kubernetes Engine and click on create. It will open cluster creation pop up. The cluster creation experience frequently changes.

cluster set up

Auto pilot is a new GKE cluster mode. In Auto pilot responsibly of cluster and node management is delegated to GKE. In this article you will learn to create cluster in standard mode.

Specify cluster name and select default configuration for the cluster.

In Zonal Cluster replicas would be distributed across multiple Zones. This provides higher availability and horizontal scaling. Even if entire Zone goes down application request would be served from available zone.

In Regional Cluster replicas would be distributed across multiple Regions. This provides higher availability and horizontal scaling. Even if entire region goes down application request would be served from available region.

With free trial account there are limited resource availability. We will select Zonal cluster and click on click on create cluster.

It will take some time for Google cloud platform to set up new cluster.

cluster name
default cluster configuration

Navigate to GKE cluster management and it will display new cluster creation status. When the cluster creation set up process is completed it will display green tick.

Default configuration creates cluster with 3 node pools. Each Node pools has 2 VCPU’s attached with 4 GB memory.

cluster ready

Deploy Microservices to GKE cluster

As a first step, you would need to create container image of the application and push it to google registry.

If you are new to application containerization and Google container registry refer this article Containerize a .NET 6 Application And Publish A Docker Container Image To google cloud registry – Full Stack Tutorials Hub for step-by-step tutorial on application containerization and pushing container images to Google Registry.

  1. Set up current project in cloud shell
gcloud config set project wired-apex-383508

2. Connect to GKE Cluster

gcloud container clusters get-credentials gkeqa --zone us-central1-c --project wired-apex-383508

Once connection is established kube config entry would be generated.

3. Create a deployment by specifying deployment name and image path.

kubectl create deployment microserviceone --image gcr.io/buildcustomimage/custom-image:0.1
get deployments

Execute kubectl to get deployments.

4. To access application from outside it needs to be exposed as a service

kubectl expose deployment microserviceone --type=LoadBalancer --port=8080 --target-port=80
get services

Exposing a Deployment would create service. In this example, we have exposed deployment as Load Balancer Service on port 8080.

kubectl get services --watch

Wait for some time and you would see external IP address assigned to mircoserviceone

IP address

In the browser window,application can be reached using External Ip and port number 35.193.253.160:8080 .

Scroll to Top