Integration of WordPress web Application over kubernetes Engine with SQL Storage of GCP

Anshika Sharma
6 min readAug 25, 2020

--

Hello Everyone!!!

In this article, I am going to show the approach for completing π™‚π™€π™€π™œπ™‘π™š π˜Ύπ™‘π™€π™ͺ𝙙 𝙋𝙑𝙖𝙩𝙛𝙀𝙧𝙒 project task.

πŸ”° Project Description πŸ”°

1. Create multiple projects namely developer and production

2. Create 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.

🎯 I have completed this project using Google Qwiklab and so I use single project for both development and production .

🎯 Project Overview:

In this project, i have completed an integration of WordPress Web Application launched using a fully managed tool i.e., Kubernetes Engine with SQL Storage in Google Cloud Platform.

What is GCP ?

☁ Google Cloud Platform (GCP), offered by Google, is a suite of cloud computing services that runs on the same infrastructure that Google uses internally for its end-user products, such as Google Search, Gmail and You tube.

What is VPC?

A virtual private cloud (VPC) is a secure, isolated private cloud hosted within a public cloud.

So, lets start creating the integration now. We will complete it step by step:

Firstly, if we wanted to work on infrastructure of Google Cloud Platform then we need to create a project. I am going to use a single project here.

Step 1: Create two VPCs one for development and one for production environment and create separate subnet for both.

Creating dev VPC
Creating subnet in dev VPC
creating prod VPC
Creating subnet in prod VPC

After this we will add some rules to the firewall for both the VPCs.

Step 2: Creating a peering connection between both the VPCs.

Creating VPC peering
Connection from dev to prod VPC network

Similarly, we need to create a peering connection from prod to dev VPC network. Hence, we can get the Active peering connection between the VPC networks.

Active VPC peering network connection

Step 3: Creating a Kubernetes cluster using Kubernetes Engine in Google Cloud Platform.

Kubernetes Engine in GCP
Creating kubernetes cluster named mycluster

Now, we will set the no. of nodes (per zone).

Setting the node pool

Also, in the Network select the VPC to dev and Zone devlab01(created above).

Successfully created Kubernetes cluster, named mycluster

Step 4: Connecting to the Kubernetes Cluster.

For connecting to the cluster click to the connect button.

To connect to the cluster

Also, check all the nodes of this cluster.

All nodes of kubernetes cluster

Now, copy the command from here and run it on the terminal or command prompt(since i have gcloud-sdk already installed).

Command to connect the cluster

Before running the command, need to have the authenticate login.

Command for authentication login
Applying the connection command

After this check that kubeconfig is updated or not ? , using β€œkubectl config view” command.

command to access kubeconfig file
Kubeconfig view

Since the config file is successfully updated. So, next we will create deployment for WordPress using the yml file.

Step 5: Create Deployment using yml file, i.e.,

yml file for WordPress-deployment
yml file for WordPress-deployment(continue)

Now, apply this code for WordPress deployment.

Applying the yml code

Access all the resources of this cluster, using β€œkubectl get all” command.

Access all resources of this cluster

Step 6: Creating an SQL storage instance in Google Cloud Platform.

SQL instance
Creating SQL instance

Here we have filled the instance ID and Password to create the SQL instance.

After some minutes, we can see that the instance has been successfully created.

Successfully created SQL instance

Step 7: Connecting to the SQL instance through gcloud shell.

Connecting to SQL instance

After entering the password, we can access the mysql prompt here.

connecting to mysql server

Step 8: Creating separate user, database for connection from WordPress.

  1. Check for the users in this instance.
Checking for the users in this SQL instance

2. Create a new user, by providing username and password.

Creating user

3. Check for databases in this instance.

Checking for Databases

4. Create a new database for WordPress data.

Creating database

5. Set connectivity by adding a new user.

Setting connections
Adding Network

Step 9: Connecting to the WordPress instance that we have launched in Kubernetes cluster.

IP address for accessing WordPress instance
First page, to select language

After this , we need to enter the database name, username, password and IP address of the SQL instance that we have created. As soon as we submit, we get connected to the MySQL storage instance.

Installation Page

After this, provide the information for successful installation of WordPress.

Providing Information

Hit β€œInstall WordPress”. We get the Login Page.

Login page

Now, we can set any theme as per our choice and can write some interesting blogs, stories also everything will be secured as we have attached an SQL storage with this.

Lets write a story!!!

Created a blog

Hence this blog can be accessed by the given β€œView Post” button on the right pane.

Finally, with these steps I have successfully completed the Project of Google Cloud Platform Workshop based on Integrating Kubernetes with Google Cloud Platform using Google Kubernetes Engine to deploy WordPress web application and connecting SQL Storage to it for secured data.

Thank You!!!

πŸ’« Keep Sharing, Keep Learning πŸ’«

--

--

Anshika Sharma
Anshika Sharma

Written by Anshika Sharma

I am a tech enthusiast, researcher and work for integrations. I love to explore and learn about the new technologies and their right concepts from its core.

No responses yet