INFRASTRUCTURE DEPLOYED ON GOOGLE CLOUD PLATFORM

INFRASTRUCTURE DEPLOYED ON GOOGLE CLOUD PLATFORM

Objectives of the Task:-

1) Create multiple projects namely Developer and Production.

2) Create VPC Network for both the Projects i.e. in Dev project we have to create one VPC in Singapore region while in Prod project we have to create one VPC in US region.

3) Create a link between both the VPC Networks using VPC Peering.

4) In the Dev project : Create a Kubernetes Cluster in Developer Project and launch any web application with the load Balancer using GCP Google Kubernetes Engine Service.

5) In the Prod project : Create SQL server in Production Project and also create MySQL Database using GCP SQL service.

6) Connect the SQL database to the web application launched in the Kubernetes cluster i.e. we have to launch WordPress, Drupal, etc. pod as a front-end on the top of GKE Cluster and link it with SQL database which is acting as a back-end for us.

REQUIREMENTS :-

Must have a Google Cloud account to deploy this project on GCP.

No alt text provided for this image

LATER SERVICE PROVIDER IS USED TO PROVIDE ALL THE SERVICES & NOW CLOUD COMPUTING IS USED TO PROVIDE EACH SERVICE BASED ON REQUIREMENT.

If a company or cloud computing company are publicly providing the services is known as PUBLIC CLOUD COMPUTING .

Some of the public clouds which the companies are using are :

  1. AWS
  2. AZURE
  3. ALIBABA CLOUD
  4. GOOGLE CLOUD PLATFORM(GCP)

Google is using the same resources from Google cloud platform.

Business companies such as Uber ,Netflix etc.. can deploy their services either on the top of their own premises or on the top of service provider. Here on-premises indicates their own Ram CPU that is their own resources and in on-premises investment is huge and here service provider refers to that one’s who provides compute as a service , provides storage as a service and the service providers is known as cloud computing. 

Here we are going to deal with one of the most demanding public cloud known as Google cloud platform or GCP. GCP is the one who provides us resources like compute as a service ,storage as a service ,network as a service etc.

WHAT IS GOOGLE COMPUTE ENGINE ?

Google compute engine is one service by GCP that provides computer as a service. If we want to use Google compute engine service then we have to enable its API in GCP cloud. Then we can launch the OS (instance) using the google compute engine service.

In google cloud platform , project is independent bundle to manage the resources. While creating project , internally a project id is assigned to the project , even though we can change the project id.

DATACENTER : In India, GCP has one region known as Asia South 1 that refers to Mumbai contain 3 availability zones such as 1A, 1B and 1C that help us for disaster recovery.

API stands for application program interface every service in GCP is running with one program and that is known as API .for every services in GCP Google provide us API initially most of the API is disabled so you have to enable it.

VPC : It provides network as a service VPC is like a company or we can say that it is like building and inside the VPC we have multiple subnets that is Labs. VPC internally provide routers switches and DHCP server etc. for us. If in one VPC we are running with two subnets that is lab1 and lab2 and we want to connect these two subnets or labs we have to do network peering.

KUBERNETES : Kubernetes is one of the management tools for managing the containers. We can only launch the docker container technology to launch the OS but docker is not meant for management. one challenge or use case come up while using Kubernetes is that as soon as no of request comes up i.e. clients suddenly increases our program automatically launch one more OS for us and if client decreases code terminate that OS. Here we are doing scaling if client increase our program add new OS that is scale in while if client decreases our program terminate that OS that is scale out. 

 It manages fault Tolerance part. It manages auto scaling part. It manages load balancing part. And tone’s of use case’s managed by Kubernetes. 

CLUSTERING : If you have one or more master and multiple slaves and they work together this kind of set up is known as multinode cluster. If you have one node and both master and slave are using this node this kind of set up is known as singlenode cluster.

WHAT IS GOOGLE KUBERNETES ENGINE ?

Google Kubernetes engine provides one command to connect to master and slave using Windows or wherever you are g-cloud program running then you can run all the Kubernetes command using Kubectl such as:-

  • Kubectl get nodes
  • Kubectl get pods
  • Kubectl get ns

Replicas are the one that do horizontal scale in for scale out for us. cloud has one load balancing service named as load balancer that is an independent service of load balancer. ? but we can also configure load balancer using Kubernetes that take GCP external load balancer. GKE provides us Kubernetes as a service. In GKE , we can create the nodes based on our requirement.

ENDPOINT : Endpoint is defined as the authentication data of the Kubernetes cluster.

IAM : IAM is a way through which we can give access to multiple user that some user have owner power other one has view power while some other has edit power only.

LOADBALANCER CONCEPT : LoadBalancer — it is a one type of service which balances the node between two ports. Mostly used in multinode clusters.

GOOGLE APP ENGINE : It provide us platform as a service which is useful for developer to test the codes. In GAE , we can run our code of any language.

Let's Start Practical Part:-

We know that GCP is a suite of services and to use any of the services we need to create a project. Here we are creating two different projects, one for the Developer Team and another for the Production Team. But in my case I am using Qwicklabs in which we allocate only one project so I am working in one project.

CREATION OF VPC:-

dev-project:

No alt text provided for this image

Now we have to create new VPC Network so for this click on CREATE VPC NETWORK.

No alt text provided for this image

Click on "myvpcdev" for more details.

No alt text provided for this image
No alt text provided for this image

prod-project:

Click on CREATE VPC NETWORK for creating new VPC.

Here I am setting my VPC name as "myvpcforprod" and for this VPC I am setting one lab or subnet as "subnet-lab2".

No alt text provided for this image

Here I am launching this VPC in US region i.e. "us-east1" and setting IP address range as "10.0.20.0/24".

No alt text provided for this image

Here just click on create and VPC will be created.

No alt text provided for this image

VPC PEERING:-

dev-project:

No alt text provided for this image

Here we have to go to VPC Network peering in the VPC Network and click on CREATE CONNECTION.

Click on Continue.

Here I am setting "vpc-peering-dev" as a peering name and my VPC Network for dev project is "myvpcdev" and I am peering this VPC Network with another project VPC i.e. prod project VPC.

No alt text provided for this image

Here we can see peering is created but is inactive because we have to create VPC peering from prod project and also for connectivity.

No alt text provided for this image

prod-project:

Go to VPC Networking peering and click on CREATE CONNECTION.

Here I am setting "vpc-peering-prod" as a peering name and my VPC Network for prod project is "myvpcforprod" and I am peering VPC Network with another project VPC i.e. dev project VPC.

No alt text provided for this image

Here we can see peering is created and status is also active because now both the VPC has connectivity through peering.

No alt text provided for this image

IN THE DEV PROJECT : I AM GOING TO LAUNCH KUBERNETES CLUSTER USING GCP GOOGLE KUBERNETES ENGINE SERVICE.

Here click on Kubernetes Engine.

No alt text provided for this image

Here I am going to NODE POOLS.

Here I am setting number of nodes as "1".

No alt text provided for this image

At the Nodes I am using machine type as "N1".

No alt text provided for this image

Here in the Cluster Basics I am setting location type as "regional", allocating "asia-southeast1" as a region and give cluster a name as "k8s-cluster-wp".

No alt text provided for this image

Here I am setting the lab as "sub-lab1".

No alt text provided for this image

Here we can see that my Kubernetes Cluster using GKE has been configured.

No alt text provided for this image


For connecting to this cluster using windows command line we have to copy this command, which is given by our cluster and for Google Cloud console click connect then run cloud shell. I am doing on cloud shell.

Paste that command in windows command line or in cloud shell and hit enter.

Here you can see KubeConfig entry is generated for "k8s-cluster-wp".

By "kubectl get pods" command you can see there is no pods or no resource found in the default namespace.

By "kubectl get nodes" command you can see I have 3 slave nodes or worker nodes.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

DEPLOYING WORDPRESS ON THE TOP OF K8S CLUSTER:-

Recently there is no pods.

By "kubectl create deployment wordpress-pod -image=wordpress:5.1.1-php7.3-apache" this command I have created one pod named as "wordpress-pod".

By "kubectl get pods" command, you can see my pod status is running.

No alt text provided for this image
No alt text provided for this image

Here you can the whole details of your k8s cluster by "kubectl get all -o wide" command it shows us about replica set , in which slave your pod is running and it also show us service.

No alt text provided for this image

Here you can see by "kubectl get svc" command about the service of k8s and here one service is by default active by k8s.

No alt text provided for this image

In the dev project go to load balancing service.

Here you can see there is no load balancer.

No alt text provided for this image

By "kubectl expose deployment wordpress-pod --type=LoadBalancer --port=80" command I am exposing my 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.

No alt text provided for this image

Here we can see that load balancer is launched.

No alt text provided for this image

Here you can the whole details of your LoadBalancer by "kubectl get all -o wide" command.

By "kubectl get svc" command you can see load balancer service is Active.

No alt text provided for this image

Now by this EXTERNAL IP anyone from the outside world can access my wordpress site.

Click on continue.

No alt text provided for this image

Before clicking on lets go! we have to think about the database for this now I am switching my project to prod and where I am going to launch MySQL database and link it with the wordpress.

IN THE PROD PROJECT : I AM GOING TO CREATE MYSQL DATABASE USING GCP SQL SERVICE:-

No alt text provided for this image

Go to Cloud SQL Instances and click on CREATE INSTANCE.

Then click on Choose MySQL.

Here I am setting Instance ID as "sql-database", Root password, Region as "us-east1" with "b" Datacenter or Zone and I am using Version "MySQL 5.7".

No alt text provided for this image

By clicking on create we will see that instance is being created.

We can see my "sql-database" has been created and having one Public IP.

No alt text provided for this image

Here I am going inside the connections.

And setting an firewall as allow all where I set network cidr as "0.0.0.0/0".

Then just click on save.

No alt text provided for this image
No alt text provided for this image

Here I am going to create an new user for my database for this, we have to click on ADD USER ACCOUNT.

And here I am setting username and password , then click ADD.

No alt text provided for this image
No alt text provided for this image

Here you can see "prachika" user has been created.

No alt text provided for this image

Now go to databases and click on CREATE DATABASE for creating new database.

No alt text provided for this image

Here I am setting database name as "mydatabase" database has been created.

No alt text provided for this image

Now we can connect database with user created using "gcloud sql connect sql-database --user=root --quiet" command.

No alt text provided for this image
No alt text provided for this image

Here from my "mydatabase" I am copying the Public IP and I know my username as "prachika" and I set one password just for testing.

Their is an photo expected but due to password issue I removed it.

So you can see here I fill all the details of my SQL database that will link SQL which is running in US region or in prod project with the wordpress which is running in the Singapore region or in dev project.

Just click on run the installation.

No alt text provided for this image
No alt text provided for this image

Set details and install wordpress.

Provide Password and login details.

No alt text provided for this image

We can see my wordpress is opened successfully and behind the scene it is storing all the information in the SQL database and I am going to write the blog.

No alt text provided for this image

Then just publish it.

No alt text provided for this image

Now done.

Your site is perfectly working !!

And thus, all the objectives of this task has been successfully completed. That's all from my side. I hope you will like my article and able to learn something new.

Thanks for Reading! ??

Deepak Shah

Terraform || Openshift(EX180) || AWS(CLF-CO2) || AWS(SAA-C03) Certified

4 年

Great prachika...??

回复
Udit Agarwal

Software Engineer | Python | GCP Cloud | Devops | Kubernetes | Grafana | AWS cloud | JAVA enthusiast | web developer | Docker | Rhel 8

4 年

Great Work

回复

要查看或添加评论,请登录

Prachika Kanodia的更多文章

社区洞察

其他会员也浏览了