WordPress site hosting on Google Cloud Platform
In this project, we are going to deploy WordPress site on Google Cloud Platforms services. We will use Google Kubernetes Engine to deploy our WordPress site and SQL service to deploy our database. In this project we also cover some basic services like VPC and Load Balancer.
Project Description:
1. Create two VPC's namely developer and production
2. Create a link between both the VPC networks using VPC Peering
3. Create a Kubernetes Cluster in developer vpc and launch any web application with the Load Balancer
4. Create a SQL server in the production vpc and create a database
5. Connect the SQL database to the web application launched in the Kubernetes cluster
As I am using QwikLabs, I am going to create both the production and developer VPC in same Project.
Prerequisite: Before going to the project implementation, let's set up all the prerequisite.
- Google Cloud SDK: Install this tool which help you in managing your resources and application.
- kubectl Command Line: This command line tool will help you in managing your kubernetes cluster.
Step1: Create two VPC named under production and development by going to the VPC network service. You have to specify subnet for both of them with IP's addresses range.
Step2: Create VPC network for the VPC's by using VPC Peering Network service which will connect both the VPC's. When you create first connection from 'dev-vpc' to 'prod-vpc' then you will be see it is inactive. It will acitve after you establish connection between 'prod-vpc' to 'dev-vpc'.
Step3: Create kubernetes cluster.
- Give name, choose regional in location type and select respective region.
- In Node pool details, select no. of nodes per zone 1.
- In a Networking tab choose dev-vpc that we created earlier with respective subnet. Then click on create.
- This will create cluster. Click on connect to connect to our cluster from CLI.
- A link will be provided for command-line access to connect to the cluster.
- Run this command on CMD and we can see our cluster and nodes.
- Create WordPress deployment and expose it to the LoadBalancer service.
- We can see now our service is ready and expernal-IP generated
- Load Balancer service is create in GCP cloud we can see from WebUI
- After browsing our External-IP we can WordPress site.
Step4: Create a SQL server in the production vpc and create a database
- Create MySQL Data base from GCP's SQL service.
- Provide Instance ID and Password.
- Edit the Instance and add new network allowing all IP's
- Add user to the Database
- Create a database 'testdb' and give password. We will connect our WordPress application to this database.
- In overview we can see public IP that will be used while connecting application to the database instance.
Step5: Connect the SQL database to the web application launched in the Kubernetes cluster
After setting up we are now able to access our site which is hosted on Google Kubernetes Engine and database in GCP SQL server.
Thank You for Reading !!