Deploying Wordpress on top of Google Cloud Platform with Kubernetes

What is Cloud Computing?

Cloud computing is the delivery of computing services — including servers, storage, databases, networking, software, analytics, and intelligence — over the Internet (cloud) to offer faster innovation, flexible resources, and economies of scale. We only pay for cloud services you use, helping lower your operating costs, run your infrastructure more efficiently and scale as your business needs change.

Task Details :

  1. Create multiple projects namely developer and production

I completed this project using Google Qwiklab and since I use single project for both development and production . Qwiklab gives you temporary credentials(200 credits) to Google Cloud Platform so you can learn the cloud over duration of 30–50 minute labs per session. 1 session costs you 1 credit.

194 out of 200 credits left

Google Cloud Platform

Google Cloud Platform is a 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.

The core cloud computing products in Google Cloud Platform include:

  • Google Compute Engine, which is an infrastructure-as-a-service (IAAS) offering that provides users with virtual machine instances for workload hosting.

So lets begin,

  1. Go to Qwiklabs and login/create an account if you don’t already.Once logged in, you will see “Baseline: Deploy & Develop” quest. Click on the blue button “Enroll in the quest”.Once enrolled, go to the first lab and click on Start Lab. You can use either 30 min or 50 min lab each cost you 1 credit.

2. Click on Open Google Console and enter the username and password provided . And you will be directed to following screen.

3. Under these project we have to create two VPC ( Virtual Private Cloud ) one for WordPress deployment and second for MySQL Database Instance .

4. Click on Create VPC Network … Here, I’m going to create developervpc in Singapore region

5. In the same way, create another VPC in OREGON region

6. 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 .

7. Create peering connection in developervpcand productionvpc

After creating of peering in both vpc it will look like this

8. Now create Kubernetes Cluster in developervpc.To enable Compute Engine Api ,Click on Api’s & Services,library,Compute and then Compute Engine Api.

9. Now create Kubernetes Cluster in developervpc and Click on create button .

10. Connect to the Cluster using CLI(google shell) by clicking on Connect.

11. You can see the nodes in the cluster using this cmd kubectl get nodes

12. Now in one pod of the cluster we will launch docker image called WordPress.

kubectl create deployment mywordpress --image=wordpress

13. After creation of pod we will expose the pod using LoadBalancer which will be used to balances the traffic load on port number 80 to access the application. It will take some time to expose the pod.

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

14. 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 by Google Cloud .

So,we have to launch these MySQL Database instance using SQL service of Google Cloud in production environment and add firewall to it.

15. To heck everything is working smoothly use command

Eg mysql -h IP -u root -p
mysql -h 34.74.74.235 -u root -p

16. Create a database through wordpress will connect

17. Now connect to the WordPress instance that we have launched in Kubernetes cluster and copy the IP adress of wordpress instance and open it in browser.

kubectl get all 

I’m an undergraduate student at IIIT Ranchi, pursuing my B-Tech in Electronics and Communication Engineering.