GCP Workshop Task Documentation
Published on September 11,2020

GCP Workshop Task Documentation

Hello everyone, this article provides the necessary steps for completing the task that was given to us after the two day Google Cloud Workshop by Linux World . Here I have integrated setup of WordPress(Web Hosting Site) with the help of Google Cloud Services.

BEFORE STARTING UP WITH THE STEPS LET'S GET SOME PREREQUISITES ABOUT THE TASK AND IT'S REQUIREMENTS:-

SERVICES OF GOOGLE CLOUD PLATFORM THAT I WILL USE FOR THIS SETUP:-

1.) PROJECT IN GCP:-

A project organizes all your Google Cloud resources. A project consists of a set of users; a set of APIs; and billing, authentication, and monitoring settings for those APIs. So, for example, all of your Cloud Storage buckets and objects, along with user permissions for accessing them, reside in a project.

2.) GOOGLE KUBERNETES ENGINE:-

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

3.) VPC(VIRTUAL PRIVATE CLOUD):-

A virtual private cloud is an on-demand configurable pool of shared computing resources allocated within a public cloud environment, providing a certain level of isolation between the different organizations using the resources. 

4.) GOOGLE COMPUTE ENGINE:-

Google Compute Engine is the Infrastructure as a service component of Google Cloud Platform which is built on the global infrastructure that runs Google's search engine, Gmail, YouTube and other services. Google Compute Engine enables users to launch virtual machines on demand.

5.) WORD PRESS IMAGE:-

WordPress is web publishing software you can use to create your own website or blog. Since it was released in 2003, WordPress has become one of the most popular web publishing platforms.  The WordPress image was made available through Docker which was loaded on the top of a container made available by kubernetes engine.

6.) DOCKER:-

Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels.

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

NOTE:- DUE TO LACK OF FREE CREDITS AND RESOURCES AVAILABLE IN FREE TRIAL I COULD NOT MAKE ANOTHER PROJECT OR CREATE ANOTHER VPC NETWORK OR KUBERNETES CLUSTER, HENCE IN THIS DOCUMENTATION I HAVE DEPICTED ALREADY COMPLETED TASK AS AT THAT TIME I DIDN'T CLICK THE SCREENSHOTS FOR EACH STEP

---------------------------------------------------------------------------------------------------------------

STEPS :-

Step1: First of all login to GCP console and create two projects namely Developer Project and ProductionProject.

No alt text provided for this image


Step2: Now we have two create TWO VPCs in TWO different PROJECTS

  • FIRST VPC:

1.)IN project <DeveloperProject>

-name: vpcdeveloperproject

- add new subnet with name: lab1

Create the VPC with following properties as depicted by the images below:-

No alt text provided for this image

-Configure the firewall with the given properties and Click on Create to create the VPC on DeveloperProject

No alt text provided for this image
No alt text provided for this image
  • SECOND VPC:

1.)IN project <ProductionProject>

-Name: vpcproductionproject

- Add new subnet with name: lab2

Create VPC with the below depicted properties and after selecting the properties click on Create.

No alt text provided for this image

------------------------------------VPC CREATION COMPLETE ----------------------------------


STEP 3:- A VPC peering means connecting two VPCs in same network that enables you to route traffic between them using private IPv4 addresses or IPv6 addresses. Instances in either VPC can communicate with each other as if they are within the same network. I have launched vpcdeveloperproject in asia-southeast 1(Singapore) region and vpcproductionproject in us-east 1(Carolina)region. So to make connectivity I have to do this peering. So, we have to do this peering from both the sides

1.) DeveloperProject: Creating VPC peering with the following settings as depicted below and click on Create.

No alt text provided for this image


-After clicking it should display:-

No alt text provided for this image

2.) ProductionProject:

  • Repeat the procedure for VPC peering creation as in DeveloperProject with the following settings:-
No alt text provided for this image

After creation it should display as below:-

No alt text provided for this image

-----------------------------------VPC PEERING COMPLETE--------------------------------------


STEP4:- Now we have to create a Kubernetes cluster using GKE(Google Kubernetes_Engine)

1.) Select GKE in GCP navigation menu in DeveloperProject, and select cluster in it.

No alt text provided for this image

2.) Now enter required cluster basics specifications as are given in the picture below:-

No alt text provided for this image

3.) Give specifications as depicted below in default-pool option present at the left hand side menu bar (when creating a new one):-

No alt text provided for this image

-As depicted below, create 4 nodes in the nodes section:-

No alt text provided for this image

- At last in networking settings select network as vpcdeveloperproject and node subnet as lab1, and then click on Create

-CLUSTER CREATED SUCCESSFULLY

No alt text provided for this image

-As you can see four nodes launched in the Compute instances as VMinstances.

No alt text provided for this image

-Now, let's connect to the Kubernetes Cluster .In below picture you will see that there is a link with credentials , you have to copy this and paste in the command prompt after installing google SDK in your system.

No alt text provided for this image

-Here we have to past the command we get above,

No alt text provided for this image

-As I have already deployed the WordPress image on the container and created its 3 replicas,therefore it is displaying 3 pods. To deploy the image file on container and create replicas write command:-

1. kubectl create deployment mywordpress --image=wordpress

2. kubectl scale deployment mywordpress --replicas=5

-Now we have to create LoadBalancer for our web server loadbalancer will distribute the load of client in all the pods when client hit to the server increase

No alt text provided for this image

-As I had already created load Balancer for the web server ,therefore the picture above is depicting load balancer already in the services. To create load Balancer write the following commands:-

  1. kubectl expose deploy mywordpress --type=LoadBalancer --port=80
No alt text provided for this image


-Now, we have to add database server to provide data services to wordpress.

------------------------NOW WE HAVE TO CREATE DATABASE SERVER-----------------

STEP5: We will create database in our vpcproductionproject which is present in our project named ProductionProject

-Select SQL in navigation menu in GCP:-

No alt text provided for this image

-As I had already made a database,hence to create database Click on Create instance,then select MySQL .

-Fill in the details for database creation such as Instance ID, root password,region and database version. In the connectivity section , connect it with private IP vpcproductionproject, Select Allocate and connect. Then Click on Create.

No alt text provided for this image

-mysql-database created in vpcproductionproject.

No alt text provided for this image


-Create a database, in this case I have created a database named databaseforwp.

No alt text provided for this image

-Create a user from the options depicted in the above picture, my new user name is geetu

--------------NOW LETS CONNECT DATABASE TO THE WORDPRESS-----------------

-Providing Credentials of Database to the WordPress

-After providing credentials we are ready for installation and login.Click on Run Installation. Here I am already Logged In,hence it doesn't ask me for installation.

-Add Login and password and we are ready to go now!!!

-------------------------------------SETUP COMPLETE----------------------------------------------

No alt text provided for this image


SERVER RUNNING SUCCESSFULLY NOW WE CAN CUSTOMIZE OUR WORDPRESS IN WHATEVER WAY WE WANT AND HOST OUR OWN SITE

To view or add a comment, sign in

More articles by Geetansh Sharma

Others also viewed

Explore content categories