Hosting Wordpress site and SQL database in Google Cloud Platform.
In this blog, I am explaining the creating the wordpress site using the google kubernetes engine (GKE) and linking it with SQL database.
Task details:
1. Create VPC network for developer and production environment.
2. Create a link between both the VPC networks using VPC Peering
3. Create a Kubernetes Cluster in developer project and launch any web application with the Load balancer
4. Create a SQL server in the production project and create a database
5. Connect the SQL database to the web application launched in the Kubernetes cluster
Solution:
Step-1:Creating the VPC networks for both the Production and developer.
Open the google cloud platform
and login to your account ,if you doesn’t have account create the new one.
After logging you will get a window like this.
Go to VPC, and create the production vpc.
Then click on create it will create the VPC for you.
Do the same way for the developer VPC by changing the entries.
Step2: Create a link between both the VPC networks using VPC Peering
Go to VPC>Vpc Peering
Then click on create,
click on continue.
But still on checking status it is inactive for making it active we need to do it same for both VPC.
After clicking on create it will peer the both vpc’s.
Now, it is active and VPC peering successful.
Step3: Create a Kubernetes Cluster in developer project and launch any web application with the Load balancer.
Go to Kubernetes Engine, and create cluster.
On clicking create cluster it will opens the page as below.
Fill the details as per your requirements.
give the size of nodes and gke version, autoscaling etc.
In the nodes,give the details of the nodes such as image info and disk size, type etc.
Create your network setup as per your requirement.
That’s it they are the basic requirement for the cluster.But if you want to do advance setup you can explore it and click on create cluster.
After created,click on connect to cluster.
You can use the cloud shell as well as you can use the above command in your pc by using gcloud command.
Installing gcloud:
Go to the “https://cloud.google.com/sdk/docs/quickstart”.
to download the gcloud software in windows.
If you are using any other OS like mac or linux.
You can search the google as “Quickstart for ______”
____=OS_name
After installation,
use the gcloud init for initialising the gcloud command.
That’s it you installed the gcloud command.
Creating the wordpress using GKE.
For controlling the kubernetes cluster you need to install the “kubectl” command.
And add path to the environmental variable.
You can check whether they are working or not by using kubectl -V
Creating the wordpress in GKE.
Creating the replicas and load balancer
To know the services running and checking the public IP’s of services.
Here, the above is the External IP or Public IP of wordpress site.
Step4: Create a SQL server in the production project and create a database
Go to API’s and services and activate the Cloud SQL API.
Then go to Cloud SQL.
Here we are using MySQL database so click on MYSQL database.
Fill the details and click on create to create the db.
After creating it will go to dashboard of SQL.
You can add the users by clicking on add user account.
On clicking add new user will be created.
Step5: Connect the SQL database to the web application launched in the Kubernetes cluster
Connecting to the WordPress
Use the External_IP of the wordpress service for connecting.
Then this screen popups.
Select the language and continue
connecting wp to the database.
Fill the details and click on submit
That’s it we have successfully connected the SQL database with Wordpress.
Fill the username , password and details and get started.
That’s all guys ,we have successfully created the project.
Thank you for giving your valuable time for reading.
Hope it would helped you.