Deployment of WordPress Web Application by Integrating Google Cloud Platform with Kubernetes

Shreyas Basutkar
7 min readSep 9, 2020

Hello World! In this article, I am going to talk about an overview of the Google Cloud Platform. We have installed WebApp with the help of Kubernetes(K8s) on the top of the Google Cloud Platform. The first thing we should know, What is Google Cloud Platform?, What is Kubernetes?, How we can launch our entire webpage on K8s?

What is Google Cloud Platform?

Google Cloud Platform is a suite of public cloud computing services offered by Google. The platform includes a range of hosted services for compute, storage and application development that run on Google hardware. Google Cloud Platform services can be accessed by software developers, cloud administrators, and other enterprise IT professionals over the public internet or through a dedicated network connection.

What is Kubernetes?

Kubernetes is an open-source container-orchestration system for automating computer application deployment, scaling, and management. It was originally designed by Google and is now maintained by the Cloud Native Computing Foundation

How we can launch our entire webpage on K8s?

For this we require following steps to perform the practical:

1. Create multi projects with dev and prod

2. Create a VPC network for a dev project

3.Create a VPC network for prod project

4. Connect both the VPC network with VPC peering

5. Create a Kubernetes Cluster in dev project and launch a WordPress/Joomla application with the Load balancer

6. Create a SQL server in prod project and create a database

7. Connect the SQL database with the application launched in the K8s cluster

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 and You tube.

1) For building any kind of Infrastructure on Google Cloud Platform we have to build it under a project . So, I created one project named as cloudproject for both platforms as development and production .

2)Under these project we have to create two VPC ( Virtual Private Cloud ) one for WordPress deployment and second for MySQL Database Instance . I have created these VPC in different regions as VPC1 in us-central1 and VPC2 in us-east1 resp . As inside VPC we have to create subnet for networking actions of the instances . One more thing we have to do is attaching firewall rule which allows all traffic to come inside the VPC as Ingress Rule .

→Creating firewall rule for Ingress traffic :

→ Creating VPC network for development and production platforms :

3)For connecting these VPC’s we have to use VPC Peering service of GCP . For peering the VPC’S we have to create VPC peer for both VPC1 and VPC2 as peer1 and peer2 .

4) Now both VPC got connected by VPC peering .Then we have build a kubernetes master slave architecture i.e cluster for deployment of WordPress application .For kubernetes we don’t need to create our own cluster and configure master and all because Google Cloud Platform provides Kubernetes As A Service by Google Kubernetes Engine .

To use Google Kubernetes Engine service we just have to tell the specifications in terms of Node Pool to them .Then they take all the responsibility further to create kubernetes cluster and about cluster management .

→ Creating Kubernetes Cluster for development platform in VPC1 :

5)For deploying the WordPress application in kubernetes cluster we have to contact with Google Kubernetes Engine .As to communicate with kubernetes master which send further task to its slave nodes we require kubectl program to be configured in our system .

In these case we are using Google Cloud Platform which provides us Kubernetes As A Service using Google Kubernetes Engine and for these we have to contact to GCP from our system .For these we have to install Google Cloud SDK Shell Program in our system which provides us all the GCP respective commands to use Google Cloud .

→ Log in to Google Cloud Platform using Google Cloud SDK :

gcloud auth login

— -> Use of Google Cloud Native Commands :

To see the node information use command :

kubectl get nodes

To communicate with kubernetes cluster running on Google Cloud we have to update the kubeconfig file such that kubectl command is configured to contact to Google Kubernetes Engine .

6)To deploy the WordPress application using kubernetes we have to create deployment in kubernetes which using WordPress image for launching the pods .

kubectl create deployment webapp --image=wordpress

fter creating the kubernetes deployment we have to launch the WordPress application on internet as by default in kubernetes environment is isolated .For these we have to expose the deployment on port number 80 to access the application .Here we also require one load balancer for the deployment which balances all the traffic load coming from public world on the application .

⏩ Load Balancer : As we are using Google Kubernetes Engine which by default uses load balancer of Google Cloud Platform .But for kubernetes it is an external load balancer since we have to provide the load balancer to kubernetes deployment .

kubectl expose deployment (deployment_name) --type=LoadBalancer --port=80

In kubernetes the load balancer is known as Service .We can see all the services used by the deployment using command →

kubectl get services

We can see through GUI one load balancer got created →

7)Now our front end of WordPress application got ready .To create the back end means to store the user data of WordPress application we use MySQL database . For us the critical thing is to manage the database for that we use Database As A Service by Google Cloud as MySQL .

So,we have to launch these MySQL Database instance using SQL service of Google Cloud in production environment i.e in VPC2.

→ Adding authorized network to public ip of MySQL Instance :

→ Log in to MySQL Instance to see available databases :

mysql -h 192.168.43.4 -u root -p

→Creating new database :

8) Final step is to connect WordPress application to back end i.e with MySQL Database . Using public ip of load balancer we can connect to WordPress application .

⏩ Now to connect MySQL database with WordPress application we have to add database login and password of the database user .

After successfully connecting the database and login to WordPress we can run the installation of the WordPress application .

Thank you very much for reading my blog hope it will help you:

If you like my blog please like and hit a subscribe to my profile.

You can find me on LinkedIn:

--

--