Deployment of Wordpress in Google Cloud using GKE

B.V.Rohan Bharadwaj
7 min readSep 16, 2020

What is Google Cloud ?

Google Cloud Platform (GCP), is a service offered by Google, it’s essentially a suite of cloud computing services that runs under the same infrastructure that Google uses internally for its end-user products, such as Google Search Engine , Gmail , drive storage , and YouTube . Alongside a set of management tools, it provides a series of modular cloud services including computing, data storage, data analytics and machine learning. Registration requires a credit card or bank account details.

It’s most mainstream use cases are:

  • Compute Engine
  • Storage & Databases
  • Networking
  • Big Data
  • Cloud AI
  • IoT
  • GKE
  • API Platform

And these are just a few examples of the multitude of services GCP provides..

If we use any service or a tool ,We usually are given two options :

GUI or either from CLI .

But it’s recommended to use CLI , The gcloud CLI can authenticate, local configuration, developer workflow, interactions within Google Cloud APIs. With the gcloud command-line tool,we can perform many common cloud tasks, like creating a Compute Engine VM instance, managing a Google Kubernetes Engine cluster, and deploying an App Engine application, and so on~

For further information on it click_here.

What is Kubernetes ?

It’s an open-source COE, which stands for Container-Orchestration Engine . This will maintain the process of automating computer application deployment, scaling, and monitoring.

Task Objectives:

🔹 Create multiple projects namely developer and production

🔹 Create VPC network for both the projects

🔹 Create a link between both the VPC networks using VPC Peering

🔹 Create a Kubernetes Cluster in Developer project and launch any web application with the Load balancer

🔹 Create a SQL server in the Production project and create a database

🔹 Connect the SQL database to the web application launched in the Kubernetes cluster

Procedure:

→Step-1:

We start off , by creating two different Projects with unique IDs (for convenience )

→ Step 2:

Now , we create VPCs for the two projects so that we can work in a safe Virtual Private Network that we defined , this works in a similar manner to a conventional day-to-day network . But we can build our own virtual DataCenter using this:

Here we created two VPCs for individual projects

Now , we have a virtual topology along with configured prefix ranges for two subnets with proper network policies .All custom-configured to match the needs.

→ Step 3:

Next , we create a Peering between both the private networks :

Here, we have to create a VPC peering for a project

Now, that VPC peering for the prod-projects is created .But at the moment it’s inactive due to the peering connection, this will established if and only when the other project is also performing peering .Then, the status will activate.

In a similar fashion we may create the Dev-project VPC peering

→ Step 4:

Now, we create a kubernertes cluster then launch a few Kubernetes pods. We decided to go for GKE (Google Kubernetes Engine) service, this will let us host a webserver via pods. Now we launch the webserver in a cluster so that we can use the cluster to deploy the server:

Now that it’s created we can continue back at our Terminal in our system for convenience . This can be done when we create the cluster we also get an option to connect it back to our local system with Kubernetes installed

And the connect option lets you a prompt that will provide us a command which we’ll have to run it in the system’s command prompt or terminal

Copy that and paste it in the terminal

Now to start the Deployment procedure we do as follows:

kubectl create deployment word-press --image=wordpress

You may wanna test whether they are successfully launched or not, that can be done by:

kubectl get pods

Now to create a couple of replicas , For more number of pods

kubectl scale deployment word-press --replicas=3

Now , to have a proper traffic control we create a LoadBalancer

Then we expose the pods under the port 80 for accessing externally:

Now to access it via its IP

kubectl get services

Now our WebServer is up and running . But

We need a database before we can go any further…

→ Step 5:

Now we’ll create a database server which will be integrated into our WordPress server , So that the data used by the user that can be stored it in our database.

Within the prod-project we create a database server , so when we’ll launch te it then in a parallel it’ll create a MySQL instances for us.

Now we can choose whichever the type of SQL services we require:

In our case, it’s ought to be MySQL server since it’s what backs up the WordPress server behind the scenes

And with that the instance will be created:

Now that our MySQL server is created,we can make some modifications to our database ( like : setting up some network changes , allow users and so on)

Then we add usernames for connecting with the WordPress..

Now, we get back to WordPress pod which we launched a bit earlier

Now we can follow through the sign-up process :

Then Log-in :

And proceed to what we are gonna do in WordPress . Which is , to create a blog:

Now, the task is complete as we have created two different networks and peered them together with one having a cluster of WordPress pods connected to a back-end MySQL server.

Conclusion:

And that’s how easy it is, to deploy Wordpress on Google Cloud using GKE

This couldn’t have been done without the help of my friend:

Chethan Avinash

--

--

No responses yet