Deployment of WordPress Web Application on Google Kubernetes Engine

Rohit Raut
5 min readOct 8, 2020

--

Task Description

  1. Create multiple projects namely developer and production

2. Create a VPC network for both the projects

3. Create a link between both the VPC networks using VPC Peering

4. Create a Kubernetes Cluster in developer project and launch any web application with the Load balancer

5. Create a SQL server in the production project and create a database

6. Connect the SQL database to the web application launched in the Kubernetes cluster

I had Completed this using Google QuickLab and In QuickLab account, there is no permission to create multiple projects so I am using a single project for both developer and production.

Similar Kind of Project I already did it using AWS-EKS

Google Cloud Platform

Google Cloud Platform (GCP), offered by Google, is a suite of cloud computing services that runs on the same infrastructure that Google uses internally for its end-user products, such as Google Search, Gmail, file storage, and YouTube. Alongside a set of management tools, it provides a series of modular cloud services including computing, data storage, data analytics and machine learning.

Google Cloud Platform provides infrastructure as a service, platform as a service, and serverless computing environments.

Step 1: Create multiple projects namely developer and production

To build any kind of Infrastructure in GCP it is compulsory to create a project and this is a project which is given by quickLab. I am using the same project for the development and the production environment.

Step 2: Create a VPC network for both the projects

In this project, We have to create two VPC(Virtual Private Network). We can choose any region to create it. I have created VPC with the name VPC1 with subnet as subnet1 and VPC2 with subnet as subnet2.

When we create a new VPC by default all ports are blocked and there is no firewall rule is defined so we have to create a firewall rule for both. here I am creating a firewall rule that allows all ports.

Step 3. Create a link between both the VPC networks using VPC Peering

Google Cloud VPC Network Peering allows internal IP address connectivity across two Virtual Private Cloud (VPC) networks regardless of whether they belong to the same project or the same organization.

VPC Network Peering enables you to connect VPC networks so that workloads in different VPC networks can communicate internally. Traffic stays within Google’s network and doesn’t traverse the public internet. This provides more security to the environment. To connect two VPC each of one has its own peering to other VPC. like 1 to 2 and 2 to 1 other it won't connect.

Step-4: Create a Kubernetes Cluster in developer project and launch any web application with the Load balancer

Creating a Kubernetes Cluster in VPC 2 :

Choosing VPC and Region
Choose Node Type and Node Count in each zone

Cluster is created

Launching Web application On Kubernetes Cluster

To deploy a web application on Cluster we have to contact to cluster and to communicate with the master we required the kubectl program. To contact to GCP from our system. For these, we have to install Google Cloud SDK Program in our system.

To login into Google cloud SDK

gcloud auth login

To see all running Project

gcloud projects list

After clicking on connect in Kubernetes Dashboard.

Copy the command Line Access and running on the local system automatically configures Kubectl Program.

Now run the following Command

kubectl get nodes

To Deploy a web app where I am using WordPress.

kubectl create deployment deployment-name --image=image_name

To expose the web app to the outside world

kubectl expose deployment deployment-name --type=LoadBalancer --port=80

Now run the command

kubectl get all

copy the External-IP and paste in the browser

Step 5: Create a SQL server in the production project and create a database

TO access from the database from the outside world

Database created

Step 6: Connect the SQL database to the web application launched in the Kubernetes cluster

Finally, Successfully Completed the task.

I would like to thanks Mr.Vimal Daga Sir.

Thank you for reading…

--

--

No responses yet