Deployment of webapp with database connectivity by integrating Google cloud platform with kubernetes and sql

1. GCP — Google Cloud Platform is a product of Google that provides or act as Public cloud computing .
2. GCP consists variety of services like GCE, VPC,GAE,IAM,GKE and many more.
3. GCE- Google Compute Engine
GCE is one service of GCP that provides Compute As A Service.Compute means Launch a OS with some RAM and CPU.
4. VPC is one service in GCP that will provide NAAS- Networking As A Service .
5. Projects in GCP
Projects is just a way to manage the things. In Project we can set some limit and quotas of services that is used by project members.Attach billing account to the project so that members of project can use services that are set for this project.
6. API in GCP
Every Service in GCP is a API. so for using the servives of GCP we have to connect to API.
7. There are 3 ways to connnect to GCP for using theirs services
a. WebUI
b. CLI
c. Some programming language like python,java…
8. cloud shell
GCP is giving command shell to connect to GCP through CLI by launching one VM on GCP.
9. VPC peering
If a instance is running in some region in a specific availability zone wants to connect to with the instance running in some region in their specific availability zone with the private IP then what we have to do is “VPC Peering”. Now the OS can ping or connect to OS running in some VPC in some region in some availability zone using private IP with the network created by Google between it’s different data centers. All the data centers of Google across various regions in the world are connected together via some network or fiber cable that is created and owned by Google.
10. Gcloud
For connecting to GCP for using its services through CLI in ours base OS we require one SDK that is known as “gcloud” . This “gcloud” program helps to connect to GCP through CLI.
11. GKE- Google Kubernetes Engine
GKE provides managed Kubernetes As A Service. It means there is no need to manage the kubermetes cluster by our own. GKE is the one who will manage the entire cluster,manage connection between master and slave node and many more things. we just have to tell some requirements for cluster like how many slaves we want, machine type for master and slave , where we to launch the cluster in a region or in a particular zone.
12. Kubectl
It is a client program from which client can connect to master node of kubernetes or kubernetes cluster for getting the demands to be fulfill.
13. when we demand for load balancer from kubernetes (that is managed by GKE )for managing the traffic and load between pods running on kubernetes cluster , then in this case because kubernetes cluster is running on top of GCP so GCP provide its load balancer to kubernetes for managing the load between pods on kubernetes cluster.
GCP has Load balancer As A service that is used by kubernetes if it is managed by GKE.
14. In AWS like for Database As A Service they have RDS, same in GCP fo Database As A Service they have SQL.
15. IAM- Identity Access Managment
In a project there might be multiple members are working. so what we can do we can set some powers to a particular member like he/she have power to see/view the services included in that project. other project member have power to edit the services in that particular project. These access or power that we assign to project member are known as ROLE. So basically we are managing the access for project for project members according to Role that is known as IAM.
16. GAE- Google App Engine
Suppose there is one code or application written in some programming language. Now GAE will fetch the code and launch the OS with all the requirements that are needed to run the code after this whatever output will come GAE will create version of it. Now again if we demand for execution of this code again GAE will launch one OS with all the requirements needed and again store the output with some new version.
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.
Lets start the process -
Step 1.-
Creating two VPC “developer” and “production” in a project that is already being created .
In each VPC creating one subnet.

“Developer” VPC have one subnet named as “dev” in asia-east-1 region.


“Production” VPC have one subnet named as “prod” in US-central-1 region.

As you can see both Developer and production VPC have created successfully.

STEP-2
Now we will do VPC Peering between both the VPC’s and connect the VPC’s together.
VPC peering from developer VPC to production VPC.

VPC peering from productionVPC to developer VPC

So now we have done the VPC peering successfully between developer and production VPC

Step 3
Create a Kubernetes Cluster in developer project . For this we have to use GKE- Google Kubernetes Engine.
Currently we haven’t any kubernetes cluster . we haveto create it.

Launching Kubernetes cluster using GKE. specify in which region you wan to launch. Here we want to launch in developer VPC region.

Tell how many no. of slave nodes we want in kubernetes cluster .
Here I specify 1 node per zone . means in total 3 nodes will launch.

Specify Machine family and disk size for slave nodes


Now here is most crucial part. here we have to specify in which VPC/network we want to launch kubernetes cluster. our requirement is to launch in the VPC named as “developer”.


So we have successfully launch the kubernetes cluster by usin GKE of GCP in “developer” vpc.

Now we are trying to connect to kubernetes cluster by using the cloud shell of GCP.

As you can see we have currently 3 nodes that are slave nodes .

Now launching the Wordpress on one of the slave of kubernetes cluster. Kubernetes behind the scene using docker for launching the wordpress.

So wordpress has been launched successfully in one of the slave node of kubernetes cluster.

Expose the wordpress by creating LoadBalancer. So that client can connect to wordpress from outside world.


Kubernetes cluster is created on top of GCP so when we demand for Load balancer from Kubernetes , it forward this demand to GCP and the Load balncer is provided by GCP for wordpress.
Kubernetes not using it’s internal Load Balancer.
So that’s why you see one Load Balancer . That is launched on top of GCP for wordpress.


Step-4
Creating a SQL server in the production VPC and create a database.
SQL is the service in GCP who provides Database.

Launching one SQL instance in the production VPC.

As you can see SQL instance / database has been launched successfully.

Now create one database with any name you want to give.

Database with name “mydatabse” has been created successfully.

Step — 5
Now Connecting the SQL database to the web application launched in the Kubernetes cluster.

As you can see wordpress site is visible.
It means there is proper connectivity between wordpress and Databse.

Task has been completed.
Give a clap , if you like it