Deployment of WordPress Web Application by Integrating Google Cloud Platform with Kubernetes
Welcome to my Project article based on Google cloud platform.
This project is based on deployment of WordPress application using Integration of Google Cloud Platform and Kubernetes by Google Kubernetes Engine .
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.
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
Before I start briefing about my Project, let me introduce you to the following terms:-
What is VPC ?.
Virtual Private Cloud (VPC) enables us to launch resources into a virtual network that you’ve defined. This virtual network closely resembles a traditional network that you’d operate in your own data center, with the benefits of using the scalable infrastructure of GCP.
Subnetwork or subnet is a logical subdivision of an IP network. The practice of dividing a network into two or more networks is called subnetting. GCP provides two types of subnetting one is Public which allow the internet to access the machine and another is private which is hidden from the internet.
What is 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.
VPC Network Peering enables you to connect VPC networks so that workloads in different VPC networks can communicate internally. Traffic stays within Google’s network and doesn’t traverse the public internet.
What is Kubernetes ?
Kubernetes is a popular open source platform for container orchestration — that is, for the management of applications built out of multiple, largely self-contained runtimes called containers.
Containers have become increasingly popular since the Docker containerization project launched in 2013, but large, distributed containerized applications can become increasingly difficult to coordinate. By making containerized applications dramatically easier to manage at scale, Kubernetes has become a key part of the container revolution.
What is 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 conatiners inside it.Eg- one container for DB and one container for Wordpress in the same POD.
So , Lets get started →
1. First we have to create a project in Google cloud console So, I created one project named as mycloudproject for both platforms as development and production .
2)Under these project we have to create two VPC ( Virtual Private Cloud ) one for WordPress deployment and second for MySQL Database Instance . I have created these VPC in different regions as VPC1 in us-central1 and VPC2 in us-east1 resp . As inside VPC we have to create subnet for networking actions of the instances . One more thing we have to do is attaching firewall rule which allows all traffic to come inside the VPC as Ingress Rule .
Creating the vpc:
→ Now Create two VPC network one for development and other for production platforms :
→ Creating firewall rule for Ingress traffic :
3)To connect these VPC’s together we have to use VPC Peering service of Google cloud platform . For that we have to create VPC peer for both VPC and VPC1 as peer1 and peer2 .
PEER 1 AND PEER 2
Now when both VPC got connected to each other by VPC peering .Then we have build a kubernetes master slave architecture i.e cluster for deployment of WordPress application .For kubernetes we don’t need to create our own cluster and configure master and all because Google Cloud Platform provides Kubernetes As A Service by Google Kubernetes Engine .
To use Google Kubernetes Engine service we just have to tell the specifications in terms of Node Pool to them .Then they take all the responsibility further to create kubernetes cluster and about cluster management .
Google cloud platform gives us 4 ways to connect to this API:
- Goole cloud web console.
- CLI: using gcloud command -Activating cloud shell: without using our own base OS, we work on CLI and run the gloud commands over there. This facility is unique to GCP only, we dont get such facility in AWS.
- SDK (software development kit)
Follows the way to install Google Cloud SDK to get gcloud command on our CLI: link to download https://cloud.google.com/sdk
Now the Google sdk is installed Login through your gmail account using this command in command line.
gcloud auth login
After login return to the web console.
Now we have to Create Kubernetes Cluster for development platform in VPC1 :
Specify the node information for kubernetes cluster :
Now, Your cluster is created.
For deploying the WordPress application in kubernetes cluster we have to contact with Google Kubernetes Engine .As to communicate with kubernetes master which send further task to its slave nodes we require kubectl program to be configured in our system .
In these case we are using Google Cloud Platform which provides us Kubernetes As A Service using Google Kubernetes Engine and for these we have to contact to GCP from our system .
kubectl get nodes
use the above command to retrive the information about node used.
To deploy the WordPress application using kubernetes we have to create deployment in kubernetes which using WordPress image for launching the pods .
kubectl create deployment (name) --image=(image_name)
Load Balancer :As we are using Google Kubernetes Engine which by default uses load balancer of Google Cloud Platform .But for kubernetes it is an external load balancer since we have to provide the load balancer to kubernetes deployment .
kubectl expose deployment (deployment_name) --type=LoadBalancer --port=80
We can see through GUI one load balancer got created →
Now, we need a Database to store the data of our web-app.In GCP, for database as a a service to store information in rows and columns we have SQL. It gives us a fully managed database.
Click on the create database.
Creating new database :
To connect WordPress application with MySQL Database . Using public ip of load balancer we can connect to WordPress application .
After all the setup here its the wordpress application running .. on google cloud platform .. #googlecloudplatform #linuxworld #righteducation #rightmentor #worldrecordholder #selfreflection.
Thank you for visiting my article.