Google Cloud Platform (GCP by LinuxWorld)

VPC Peer, Kubernetes Cluster, SQL server, WordPress on Google Cloud Platform

Hey guys , i have Completed My Task of workshop on Google cloud platform, which is held on 22nd August and 23rd August, Organised by LinuxWorld Informatics PVT. LTD. with World’s Best mentor Vimal daga sir.

It was the great expereience , i learnt a lot

The Task was to do :

1. Create a project

2. Create VPC network for the projects

3. Create a link between both the VPC networks using VPC Peering

4. Create a Kubernetes Cluster and launch any web application with the Load balancer

5. Create a SQL server and create a database

6. Connect the SQL database to the web application launched in the Kubernetes cluster

And what i did as Solution is :

First of all, open browser and type console.google.com . after that we have to create a account on this and add account to billing address. because without adding billing address we can’t process further.

Step 1: we have to create a project.

For this we have to go compute engine and create a project and launch one operating system. and select the region for these operating system and change boot disk I selected centos version 7 in my project and now launch it.

Step 2: So in this step we are going to launch two vpc network

and in this two vpc we will launch operating system and create one lab for both vpc.

VPC : It is virtual private cloud it provides a service and it will create entire network for you , inside these we can create labs.

create a vpc and give a name vpc1 and

than create a subnet in vpc1 and we can give it a name lab1

select its region and give IP like 10.0.1.0/24 and click on create.

same thing do for create vpc2 with subnet lab2 and IP 10.0.1.0/25.

now go to compute and launch one operating system os1 in vpc1

and select region us-east1 and a datacenter.

go to network interface and select vpc1. do same thing for vpc

  1. so two vpc network is created after that we have to connect both vpc and we can use vpc peering to peer these two vpc.

Step 3: go to vpc peering and create connection give a name of it like peer1

and select peered vpc in same project beacuse we created only one project

and select the project id and and vpc network .

after that we can see vpc peering status is inactive .

for this we have to do same thing for vpc2 and connect it with vpc1 network .

after connecting we can see both vpc status is active.

so open the os2 shell and ping os1 with its external IP

and than we can see that both os can ping each other .

step 4: In this we have to create a Kubernetes cluster and launch a web application with load balancer.

  • Go to kubernetes engine and create a cluster click defaultpool and select number of node size is one and select regional location type and click create . Now cluster is created. go to connect and copy the link and paste it to local cmd.
  • so to run kubectl command we have to download google cloud sdk after that go to your cmd and type gcloud init after that set sdk with cloud account and now we are able to run gcloud command on cmd.
  • Next thing we have to download kubectl for it so paste the link in cmd for kubectl and install it.
  • In our local cmd type following command to run os and load balancer.
  • kubectl.exe run myos1 — image=vimal13/apache-webserver-php
  • kubectl.exe get pods
  • kubectl.exe get pode -o wide
  • kubectl.exe create deployment myweb — image=vimal13/apache-webserver-php
  • kubectl.exe expose deployement myweb — type=LoadBlancer — port=80
  • kubectl get services
  • after than we can see all services and its IP , so copy the IP of load balancer and paste it to your local browser , now we are able to see web application .

Step 5: In this step we are creating a sql server and a database

  • For this go to sql and create and create ainstance. give a name for it and select user as a root and set a password for it. select region and version of mysql .
  • go to overview and edit instance and select connectivity as public IP and add a network and give network range as 0.0.0.0/0 and save it.
  • After that open cloud shell and type there mysql -h (IP of instance) -u root -p. than enter password and now sql is open . so here we can see our databases with (show databases; )command and create one database either command or gui.

Step 6: Connect the SQL database to the web application launched in the Kubernetes cluster

  • For this we have to do following commads in our local terminal
  • kubectl.exe create deployment mywp — image=wordpress
  • kubectl.exe get pods
  • kubectl.exe get pods -o wide
  • kubectl get deploy
  • kubectl expose deploy mywp — type=LoadBalancer — port=80
  • kubectl get services
  • paste external IP of load balancer on browser and now we are able to connect wordpress with our databse
  • when wordpress open than give user id and password and ip of databse and conncet it.
  • now our database it connected. and front end connected to our backend.

enter user name password and databse host that is IP of database

now we are able to connect our front end to backend .

…………….THE MOBILE VIEW…………

Thank you so much Vimal Daga sir 🙏🏼 to teach like this

and the my Lucky charm Priyanka…for helping in writing the article…🤗

--

--

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
Ashutosh K

Ashutosh K

⊙DevOps Engineer@Teqfocus, ⊙DevOps, MLOps, Cloud, Ansible Enthusiast