Deploy WordPress site on Google Cloud Platform

Deploy WordPress site on Google Cloud Platform

Hello everyone, in this task, I am going to deploy a WordPress site and connect this site to MySQL server for the database.


Task-1)

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.


PRACTICAL PART --

Step-1) Create multiple projects namely developer and production

So firstly, we are going to create two projects namely, mydevproject and myprodproject .

No alt text provided for this image
No alt text provided for this image

Step-2) Create a VPC network for both the projects -

Now before going to create VPC we have to enable a compute engine API as shown below image.

No alt text provided for this image

Now, we first enter inside the mydevproject project and going to create VPC then we switch to the myprodproject project and create a VPC .

No alt text provided for this image

Created vpc in dev project


No alt text provided for this image

Created subnet

>> we are creating a subnet so that every user from the outside can come inside or can access WordPress.

No alt text provided for this image

 Dev VPC has been created successfully. Now the same steps are going to follow for creating a VPC in prodproject.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Now , Prod VPC has been created successfully.

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

Before going to create VPC Peering, first, we have to allow the ports from the Firewall so that any user can access our WordPress.

Now we are going to create our own Firewall on both the projects so that in the future there will be no connectivity issue.

No alt text provided for this image

Allow all port

No alt text provided for this image
No alt text provided for this image

Now the same firewall we are going to create for another project.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Now we are going to create VPC Peering, VPC Peering helps to connect both the VPC for private access.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Above , as you can see the connection is inactive, it will be active when we create PVC peering to other projects also. See below

No alt text provided for this image
No alt text provided for this image

As you can see we have successfully created VPC Peering.

Step-4) Create a Kubernetes Cluster in the developer project and launch any web application with the load balancer.

Now we are going to create a cluster

No alt text provided for this image

Now we are going to launch the nodes in all 3 data centers as shown in the below image.

No alt text provided for this image

Now we are going to launch this cluster in our created VPC as shown in the below image.

No alt text provided for this image

Now cluster successfully launched as shown in the below image.


No alt text provided for this image

Cluster has successfully launched.

Now we are going to launch WordPress pod on our cluster using the Command line, for command-line access we need to give username and password as shown in the below image.

No alt text provided for this image

Copy the above image command and paste it on cmd.

Now we going to run some commands so that we can launch the pod, scale-out the pod, and expose the pod with LoadBalancer as shown in a below image.

No alt text provided for this image

Now use the external IP of the load balancer for opening WordPress.

Commands I used for 1) create deployment: kubectl create deployment mywordpress — image=wordpress.

2) For scaling deployment: kubectl scale deployment mywordpress — replicas=5

3) Expose the load balancer: kubectl expose deployment mywordpress — type=LoadBalancer — port=80

No alt text provided for this image

WordPress has been launched successfully.

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

Now we are going to launch SQL instance for backend connectivity as shown in the below image.

No alt text provided for this image
No alt text provided for this image

Now choose MYSQL as shown in the above image.

Now creating MySQL instances as shown in a below image.


No alt text provided for this image
No alt text provided for this image

Now Mysql instance has been initialized successfully as shown as below image.


No alt text provided for this image

Now to access the MySQL instance we have to add the network to allow the ports as shown in the below image.

No alt text provided for this image
No alt text provided for this image

In the above image, we are giving access to all the users of the public world.

Now we can create our own database as I am going to create “lwdb” database as shown in the below images.

No alt text provided for this image

The database has been created successfully.

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

Now we are going to install WordPress as shown in the below image.

No alt text provided for this image
No alt text provided for this image

WordPress successfully installed.


No alt text provided for this image

THANKS FOR VISITING MY ARTICLE

#THANKS TO #VIMAL_DAGA SIR.

#GCP #WORKSHOP

Trapti Jain

Frontend Enginner | Electronics Engineer | Learner

4y

Great👍👍.... Keep it up

Atishay Jain

SDE @Awiros | 3+ YOE in System design and Backend development | Building Public Safety Systems at Awiros

4y

Well done👍

Pranay Agrawal

DevOps Engineer | Aviatrix Certified Engineer | Red Hat Certified System Administrator | DevOps | Cloud

4y

Great✌️

Prabal Agrawal(He/Him)

DevOps Engineer @ Flutterwave | RHCSA Certified v8

4y

Good job vibhor ✌️👍

To view or add a comment, sign in

More articles by Vibhor Jain

Insights from the community

Others also viewed

Explore topics