Application Deployment in GKE Cluster linked with GC SQL using VPC Peering.

Both SQL Server and Kubernetes Cluster will be launched in different private networks and will be linked using VPC peering.

Deepti Tiwari
6 min readOct 10, 2020

Cloud computing allows us to use resources active across the continent. There are many cases in which the connection between Private Networks launched in the different regions needs to be connected.

In this blog, I have explained how does the google Kubernetes engine work. This article will explain the connectivity of two VPC Network launched in a different region.

TASK DESCRIPTION.

  • Create multiple projects and one VPC in each of them.
  • Establish a link between both the VPC networks using VPC Peering.
  • Create a Kubernetes Cluster in one project and launch any web application with the load balancer.
  • Create a SQL server in the other project and create a database.
  • Connect both the servers, i.e. the SQL database to the web application launched in the Kubernetes cluster

CONCEPTS USED.

Launching the OS brings along a lot of other tasks of managing it. Accidental deletion, Persistent Volume, other configuration details are some of the things that have to be done. Kubernetes is one tool that helps in container orchestration. Google provides a superb way to manage Kubernetes services, through GKE (Google Kubernetes Engine).

In this project, we will be working on the Kubernetes clusters. A cluster is basically a group of systems/resources that work together systematically so as to finish the tasks in the queue effectively. It contains a master that assigns tasks to other slave nodes, and launch pods (containers) according to the need.

PROCEDURE :

The entire steps are broadly divided into four parts:

  1. Creating Virtual Private Clouds in different projects and connect them.
  2. Launch the Kubernetes Cluster.
  3. Launch SQL Server.
  4. Establish a connection between both the servers and launch the application.

Below is the detailed procedure of the project.

I. Creating Virtual Private Clouds in different projects and connect them.

  • Create two projects, one to launch the Kubernetes cluster (name: KUBEPROJECT) and another one to launch the SQL server (name: SQLPROJECT).
i) Interface to Create a project. ii) List of created Projects
  • Enable billing for both the projects.
  • The next step is to create VPCs in both the projects, with one lab each. We also have to give IP-range and region as shown in the image. For this project, VPC for the Kubernetes cluster is launched in asia-southeast1 (Singapore) and VPC for SQL server is launched in us-east1 (South Carolina).
Interface to create VPCs.
  • In a custom made VPC, by default there are no firewall rules. Therefore we have to create one for both the VPCs. The firewall rule made for this project allows all the traffic for all the ports.
Interface to create firewall rules.
  • To establish a connection between both the VPCs, we have to configure VPC Peering between these two.
Detail procedure to configure VPC PEERING is explained in this blog.
Interface for VPC Peerings.
  • The VPC Peering is confirmed when both the status shows “Active”, as shown in the image below.
List of VPC peerings establishes in both the projects.

— — —

II. Launch the Kubernetes Cluster.

  • The next step is to install and complete the setup of Google Cloud SDK. This will enable us to use the “gcloud” command on our personal system.
Snapshot while installing GC SDK.
  • To launch the Kubernetes cluster, Google Kubernetes Engine Service will be used.
  • Go to Console >> Kubernetes Engine >> Clusters >>”Create Cluster” .
  • Fill the details as shown in the below images (according to the need).
Interface to create a Kubernetes cluster.
  • Open Google Cloud SDK Shell on your desktop.
  • To connect the desktop with the cluster launched, GCP provides a command. (Available in front of the name of the cluster in the list of clusters).
  • Copy the command and run it on the GC SDK shell.
Google Cloud SDK Shell
  • Create a deployment using the image “wordpress” (available on docker hub).
  • Increase the number of pods according to the need.
>kubectl.exe create deplyment deployment_name --image=wordpress
//command to create a deployment using mentioned image of one pod.
>kubectl.exe scale deployment deployment_name --replicas=N
//command to increase or decrease the number of pods to N.
>kubectl.exe get pods
//command to list all the running pods.
Google Cloud SDK Shell
  • GCP provides a facility of Load Balancer to handle the traffic. Expose the port 80 of the pod to the load balancer.
>kubectl.exe expose deployment deployment_name --type=LoadBalancer --port=80
//command to expose port 80 to load balancer.
Google Cloud SDK Shell
  • Using this command, GCP will launch a load balancer on the cloud, that can be seen in Console >> Kubernetes Engine >> Workloads section.
List of Load Balancers created.
  • Details of load balancer can be seen by clicking on the Load Balancer’s name. We can find the public IP at the page bottom.
WebPage displaying Details of Load Balancer.

The Kubernetes cluster is launched.

— — —

III. Launch SQL Server.

  • Go to Console >> SQL >> “Create Instance” and fill the details required.
Interface to create SQL instance
  • Now the SQL instance will be launched. The next step is to create a dataset in the instance.
Interface to create database.
  • It's important to specify the range of IPs that will be allowed to access the server. In this project, all the IPs are allowed.
Connection Setting for SQL Instance.

The SQL Server is launched.

— — —

IV. Establish a connection between both the servers and launch the application.

  • Open the application using the Public IP of Load Balancer. The following page will be launched.
  • Enter the details of the database server to establish a connection.
WordPress Interface
  • Select “Run the installation”.
WordPress Interface
  • The following page will appear in which we have to fill the details to create an account.
WordPress Interface
  • Finally, this webpage appears when the process of making the account is complete.
Finally Launched webpage

— — —

THANK YOU !!!

--

--