Launching website(Wordpress) on top of Kubernetes cluster with Database connectivity by using GCP services.

Yashraj Oswal
5 min readAug 28, 2020

Google cloud platform (GCP) is a tool for cloud computing where user can use the same technologies used by Google products like Google search, YouTube, Gmail etc.

In GCP there are numerous API’s and Engines which enables the user to use Google’s virtual hardware and software, which has higher rate of computing power and performance. We can operate virtual operating system, Create website and link with database, and create n numbers of clusters using Kubernetes in various regions / zones offered by Google.

GoogleCloudPlatform

Task:

1. Create multiple projects namely developer and producer

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.

1. Creation of Multiple projects:

Create new project through GCP GUI
Create new project through Google command shell interface

PS: “Make sure you link your projects with billing account”

2. Create VPC network for both the projects

Virtual Private Cloud (VPC) is a configuration pool for sharing computing resources. In GCP, virtual private network provides networking functionality to Google compute engine virtual machine (VM) instance, Google Kubernetes Engine (GKE), and App engine environment.

VPC for Developer project:

VPC for developer project (Region: asia-southest1)
Creation of Subnet in asia-southeast1(Singapore)
Set dynamic routing to regional and create the VPC for developer project

VPC for production project:

Create VPC for Producer project in USA-east1 region
Create Subnet in USA-east1 region
Set dynamic routing to regional and create VPC

3. Create a link between both VPC using VPC peering.

Google Cloud VPC Network Peering allows internal IP address connectivity across two Virtual Private Cloud (VPC) networks regardless of whether they belong to the same project or the same organization.

Connect both the project using VPC peering, here connect developer project IP with producer IP
connecting Producer project IP with Developer IP

4. Create a Kubernetes Cluster in developer project and launch any web application(Wordpress) with the Load balancer

Kubernetes (K8s) is used for automating deployment, scaling, and management of containerized applications

Step 1: Install gcloud in the base OS:

Link:https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe

After installation it will prompt you to connect the gcloud with GCP Account

Step 2: Download Kubectl.exe

Link: https://storage.googleapis.com/kubernetes-release/release/v1.16.14/bin/windows/amd64/kubectl.exe

Step3: Create Kubernetes cluster in developer project:

*First enable Kubernetes Engine API*
Create cluster as shown above and choose Location type as regional so that clusters are been created in the Three data centers of asia-southeast1(Singapore)
Here you can create no. of node clusters, I have set one each in all three data centers.
Here you have the option to choose image type and select the machine configuration for the clusters
Select the VPC network and Subnet for the cluster creation
After few moments the cluster is been created and appeared in the cluster window
Click on connect button appeared in the generated cluster and copy & paste the command in cmd
In cmd paste the copied command to connect and generate entry for cluster

To check: kubectl.exe get nodes -> It will show the created nodes.

Creating deployment and adding webpage on top of the cluster
Load balancer is been created

5. Create a SQL server in the producer project and create a database

Create SQL instance in producer project
Choose Mysql
Create MYSQL instance
MYSQL instance is been created successfully
Create database user
Create Database into mysql instance
Make use of google command shell and connect to database IP

6. Connect the SQL database to the web application launched in the Kubernetes cluster.

Launch the IP Address of wordpress on web browser (copy paste the generated IP)
Wordpress Installation page will appear, select your preferred language and click continue
Connect Database and Wordpress(website)
Now your Database and Wordpress is connected and it will prompt you to run installation
Create admin credentials which will used by you to access your site
After that login page will appear, Enter the login credentials here
After successfully login, you will see your dashboard
Design your website and launch on the server
When you successfully connect your database with wordpress following tables are auto-generated in the database

Here I have successfully completed the task given by my mentor Mr. Vimal Daga sir. I am also thankful to Linuxworld Pvt Ltd for giving me the opportunity to explore and learn Google Cloud Platform.

--

--