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 .
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.
Now, we first enter inside the mydevproject project and going to create VPC then we switch to the myprodproject project and create a VPC .
Created vpc in dev project
Created subnet
>> we are creating a subnet so that every user from the outside can come inside or can access WordPress.
Dev VPC has been created successfully. Now the same steps are going to follow for creating a VPC in prodproject.
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.
Allow all port
Now the same firewall we are going to create for another project.
Now we are going to create VPC Peering, VPC Peering helps to connect both the VPC for private access.
Above , as you can see the connection is inactive, it will be active when we create PVC peering to other projects also. See below
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
Now we are going to launch the nodes in all 3 data centers as shown in the below image.
Now we are going to launch this cluster in our created VPC as shown in the below image.
Now cluster successfully launched as shown in the below 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.
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.
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
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.
Now choose MYSQL as shown in the above image.
Now creating MySQL instances as shown in a below image.
Now Mysql instance has been initialized successfully as shown as below image.
Now to access the MySQL instance we have to add the network to allow the ports as shown in the below 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.
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.
WordPress successfully installed.
THANKS FOR VISITING MY ARTICLE
#THANKS TO #VIMAL_DAGA SIR.
#GCP #WORKSHOP
Frontend Enginner | Electronics Engineer | Learner
4yGreat👍👍.... Keep it up
SDE @Awiros | 3+ YOE in System design and Backend development | Building Public Safety Systems at Awiros
4yWell done👍
DevOps Engineer | Aviatrix Certified Engineer | Red Hat Certified System Administrator | DevOps | Cloud
4yGreat✌️
DevOps Engineer @ Flutterwave | RHCSA Certified v8
4yGood job vibhor ✌️👍