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.
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.
- 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
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.
The entire steps are broadly divided into four parts:
- Creating Virtual Private Clouds in different projects and connect them.
- Launch the Kubernetes Cluster.
- Launch SQL Server.
- 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).
- 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).
- 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.
- 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.
- The VPC Peering is confirmed when both the status shows “Active”, as shown in the image below.
— — —
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.
- 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).
- 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.
- 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.
- 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.
- Using this command, GCP will launch a load balancer on the cloud, that can be seen in Console >> Kubernetes Engine >> Workloads section.
- 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.
The Kubernetes cluster is launched.
— — —
III. Launch SQL Server.
- Go to Console >> SQL >> “Create Instance” and fill the details required.
- Now the SQL instance will be launched. The next step is to create a dataset in the instance.
- 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.
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.
- Select “Run the installation”.
- The following page will appear in which we have to fill the details to create an account.
- Finally, this webpage appears when the process of making the account is complete.
— — —
THANK YOU !!!