GCP WORKSHOP TASK


GCP WORKSHOP on 22nd &23rd August

 Task Implementation 

by: SHIVANGI SAXENA

  1. Create two projects one dev and other prod.
  2. In develop project, we create a VPC which will be in the Singapore region, and for prod project another VPC in US region. 
  3. Now connect both this project with the help of VPC peering. 
  4. In dev project using GCP Google Kubernetes Engine Service launch Kubernetes Cluster. 
  5. In prod project using GCP SQL service create MySQL Database. 
  6. Then launch a WordPress or any other pod as a front end on top of GKE Cluster then link it with SQL Database which will act as backend. 
STEPS :-

1. Open the console of GCP


2. Now go to project setting in the dashboard and create 2 projects namely prod and develop.






3. Now we will have to enable the billing for both of the projects that we have created.



4.  After enabling the billing part we will next move towards enabling the Compute Engine API on both of the projects namely the develop and prod.

5. Now go to Develop project and enable the Compute Engine API.




6. Similarly, perform the same steps in the Prod project also.

7. Creating VPC for develop project

  •  Click on create VPC network
  • Fill out the details of the subnet like Name, Region, IP address range, routing mode and click on create a VPC will be created on Singapore region.



8. Similar steps we will follow to create the prod project instance.




VPC PEERING 

  • develop project: 
  1. Go to VPC network peering and then VPC network and click on CREATE CONNECTION.
  2.  Click on continue. 
  3. Now set “vpc-peering-dev” as peering name and peer this network with another project VPC which is prod project VPC. 
  4. Peering shall be created and  it is inactive it will be activated when we will create vpc peering from prod project end also for connectivity.








 



  • Prod project 
  1. Go to VPC network peering and the click on Create connection.
  2. Set “vpc-peering-prod” as peering name and peer this network with another project VPC which is dev project VPC.









GOOGLE SDK INSTALLATION 

• Download Google Cloud SDK and open it. 
• Click on run. 
• Click on next. 
• Click on I agree.
• Click on next. 
• Then finally click on finish. 
• In further steps add the google account. 
• Then will be authenticated with Google Cloud SDK. 
• Now we can run “gcloud project list” command to see the list of projects running. 







Kubernetes

DEVELOP PROJECT 
  1. Launching Kubernetes Cluster using Google Kubernetes Engine. • Click on Kubernetes engine. 
  2. Enable Kubernetes Engine API if not enabled. 
  3. Now create the cluster- add name, location type. 
  4. Now add the node pools- name, version, size use machine type N1. 
  5. Then set the lab. 
  6. Now Kubernetes cluster will be created.
  7. By using “kubectl get nodes” command in our cmd we can see the number of slave nodes running





DEPLOYING WORDPRESS ON TOP OF KUBERNETES CLUSTER

  1.  "kubectl create deployment wprsweb1 --image=wordpress-5.1.1-php7.3-apache" by this command create one pod named as "wprsweb1". 
  2.  By "kubectl get pods" command,  see pod status is running. 
  3.  We can the whole details of our k8s cluster by "kubectl get all -o wide"  
  4. Use "kubectl get svc" command for the service of k8s and here one service is by default active by k8s. 
  5. Go to load balancing service in dev project.
  6. Currently, there will be no Load balancer.
  7. By - "kubectl expose deployment wprsweb1 --type=LoadBalncer --port=80" command we expose wordpress pod to the outside world and k8s service load balancer internally contact to the load balancer of GCP and launch one load balancer for us. 
  8. Then load balancer will be launched. 
  9. By "kubectl get svc" command you can see load balancer service is Acitve. 
  10. We will get an EXTERNAL IP through which anyone from the outside world can access my WordPress site.






Prod project:
  • Using GCP SQL service creating MySQL Database 
  1. Go to Cloud SQL Instances and click on Create Instance.  Then click on MySQL. 
  2. Set instance ID, root password, region and zone. 
  3. Click on create, an instance will be created with one public IP. 
  4. Go inside connections and set firewall. 
  5. Go to the Users tab and create a new user by clicking on add user account.
  6. Set username and password. 
  7. Go to database and click on create database for creating new database and set its name. 
  8. Click on option "connect using cloud shell", it will active cloud shell for us to connecting with SQL database using root user. 
  9. By using “show databases;” command we can see our database. 
  10. From SQL-database copy the public IP and username and password is already set.
  11. Go to WordPress URL click on continue and fill the database details.
  12. After filling all the details install the WordPress. 
  13. Provide the login details. 
  14. WordPress will be opened successfully, publish it.




Now we will launch a WordPress on top of GKE Cluster then we will link it with SQL Database which will act as backend.






 

 

 

 

Comments