Deployment of WordPress on Kubernetes and SQL Database through GCP

Google Cloud Platform [GCP]

Google Cloud Platform is a suite of public cloud computing services offered by Google. The platform includes a range of hosted services for compute, storage and application development that run on Google hardware. Google Cloud Platform services can be accessed by software developers, cloud administrators and other enterprise IT professionals over the public internet or through a dedicated network connection.

Google Cloud Platform is a suite of public cloud computing services offered by Google. The platform includes a range of hosted services for compute, storage and application development that run on Google hardware. Google Cloud Platform services can be accessed by software developers, cloud administrators and other enterprise IT professionals over the public internet or through a dedicated network connection.

  • Google Compute Engine, which is an infrastructure-as-a-service (IaaS) offering that provides users with virtual machine instances for workload hosting.
  • Google App Engine, which is a platform-as-a-service (PaaS) offering that gives software developers access to Google’s scalable hosting. Developers can also use a software developer kit (SDK) to develop software products that run on App Engine.
  • Google Cloud Storage, which is a cloud storage platform designed to store large, unstructured data sets. Google also offers database storage options, including Cloud Datastore for NoSQL nonrelational storage, Cloud SQL for MySQL fully relational storage and Google’s native Cloud Bigtable database.
  • Google Container Engine, which is a management and orchestration system for Docker containers that runs within Google’s public cloud. Google Container Engine is based on the Google Kubernetes container orchestration engine.

Addition to this Google also offer Google Cloud Endpoints which allows developers to create services based on RESTful API’s, Any cast DNS servers, Direct interconnection, LOAD BALANCING, monitoring and logging services.

Google Kubernetes Engine (GKE) provides a managed environment for deploying, managing, and scaling your containerized applications using Google infrastructure. The GKE environment consists of multiple machines (specifically, Compute Engine instances) grouped together to form a cluster.

A load balancer distributes user traffic across multiple instances of your applications. By spreading the load, load balancing reduces the risk that your applications experience performance issues. A load balancer distribute your load-balanced compute resources in single or multiple regions — close to your users — and to meet your high availability requirements. Cloud Load Balancing can put your resources behind a single any cast IP and scale your resources up or down with intelligent auto scaling.

GCP Load balancing

A Virtual Private Cloud (VPC) is a global private isolated virtual network partition that provides managed networking functionality for your Google Cloud Platform (GCP) resources. In this diagram, you can see the default VPC network spanning multiple regions and zones, and subnets within various parts of the network servicing VMs. All of these subnets can natively route to each other, and as long as the firewalls permit it, VMs can reach one another within this VPC. The instances within the VPC have internal IP addresses and can communicate privately with each other across the globe.

VPC Network

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. … Traffic stays within Google’s network and doesn’t traverse the public internet.

VPC Peering

POD : A pod is a collection of containers and its storage inside a node of Kubernetes cluster . It is possible to create a pod with multiple container’s inside it. Eg- one container for Data Base Management and one container for Wordpress in the same POD.

Using the above discussed services provided by Google, I have tried to perform a task of configuring two nodes in different regions, On one of the node I launched a Kubernetes services with load balancing to run WordPress and on another node which I launched in America data base center, On this I created a database for WordPress.

Task Details :

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

Now, As We all have gathered required Information for doing the task.

<Lets Get started Now>

  1. Creating two Projects devproject & prodproject

2. VPC network setup for the projects we created and peering [connecting] these network.

Now creating VPC network for project- “devproject” in the region us-central1

VPC network name “securedev”

Creating Subnets inside the above network

Here I have asked google to assign some IP range which my network will use

The Range of IP will only be used in above network for assigning to the subnets.

Firewall for lab1

Right Now I have zero firewall and allowed all the IP, the firewall I created is totally unsecure but here we can create one for our lab whenever required.

Similarly, We did the same for the prodproject, The VPC network for this project I have made a setup in region “asia-southeast1” i.e. Singapore.

Creating Subnets in this VPC network with IP range as shown

Firewall “prodfirewall” is being setup

The above firewall is similar to that of above so I must reveal there is zero security for secure network we must use a good firewall setup but for now I will go with this only.

→ As we have made VPC for both the network now let us peer these networks.

Peering from devproject to prodproject and then did the same from prodproject to devproject.

We need to setup this from both side so as to give approval to devproject from prodproject that they can connect to prodproject and vice versa.

Peering prodproject from devproject
Peering devproject from prodproject

3. Launching instances in devproject using command

command used to launch instances in devproject
GCP GUI mode confirms that instance is launched

4. Launching Instance in Prodproject

command used to launch the instance
CLI view showing launch of instance in prodproject
GUI view of prodproject

Checking VPC Peering b/w the two projects

Checking connection from prodproject to devproject
Checking connection from devproject to prodproject

As you can see the VPC peering of networks was successful

5. Launching Kubernetes Cluster in devproject

Command which can also be used if we want to launch using CLI mode

Command Used to install kubernetes engine for using it on GCP through command prompt of windows.

Screenshot of command used in command prompt

6. Launching Kubernetes cluster

Generation kubernetes cluster
Showing all the Cluster launched
Showing cluster is launched

7. On Kubernetes-cluster Launching deployment of image “wordpress” which kubernetes install as container from docker hub.

Using the command “ kubectl.exe create deployment myos1 — image=wordpress ”

Deployment Launched

then I have replicated the image myos1 using command →

## kubectl.exe scale deployment myos1 — replicas=5 ##

Replicas of Deployment Launched

8. launching Load balancer

Load Balancer launched
Internal Connection of Load Balancer
Load balancer running over the Kubernetes Deployment
Accessing Database from CLI mode

Since all things are set . Therefore, Let’s connect the database to wordpress

So, for that we will the external IP of load balancer and get to login page of wordpress

Connection of database “wordpressdb” created in Singapore with image containing “Wordpress” already installed which is launched in US

The image used in this context was installed/pulled from docker hub

Connecting database of prodproject with wordpress
Login page for wordpress

So, I successfully connected the database and wordpress.

#######TASK COMPLETED#######




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Why React Native is better than Flutter for mobile application development

Offline Content Migration in AEM — using oak-upgrade

AEM OAK Repository Version Information as shown in CRXDE|Lite

Time for new Project: 2.5D Platformer

Bitident integration in MyETPWallet

Frequently Asked Questions(FAQ) in Building and Dockerizing flask-MongoDB Web Application

How to do web scraping in python ( use case, tips and advices)

Cold walkthrough from Tryhackme

Not Every One Can Code

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ayush Gupta

Ayush Gupta

More from Medium

Cloud — Understanding of Containers and Virtual Machines/Virtualization?

Cloud Infrastructure Setup Guide

Azure Kubernetes Service (AKS) — Industry Use Case

Cloud Computing & Various Platform