VirtualPrivate Networks using Network Peering|Deployment of WebApplication with Cloud SQL and GKE|GCP
Kalla Kruparaju
DevOps Engineer at DataGrokr | ?? 1X AWS, 2X Google Cloud, and 3X Azure Certified | Cloud Architect | Infrastructure Automation Enthusiast | Docker | Kubernetes | Terraform | Ansible | Jenkins | Gitlab
?Task Details ?
1.Create two Virtual Private Cloud (VPC) networks namely developervpc and productionvpc
2.Connecting both vpc networks using vpc peering
3.Create a Kubernetes Cluster in the project and launch a web application with the LoadBalancer
4.Create A SQL server in the project and create a database
5.connect the SQL database to the web application launched in the kubernetes cluster
Virtual Private Cloud (VPC)
The Google Cloud Platform makes it possible to connect instances hosted in separate Virtual Private Clouds (VPCs), even if those instances belong to different projects or are hosted in different regions.
By default network with a series of default subnets will be deployed ready for immediate use. VM instances can be deployed on the default subnets without any network configuration
Each VM instance in gcp will have an internal Ip address and typically an external IP address.The internal IP address is used to communicate between instances in the same VPC network, while the external IP address is used to communicate with instances in other network or the internet
VPC network Peering
The Google Cloud Platform makes it possible to connect instances hosted in separate Virtual Private Clouds (VPCs), even if those instances belong to different projects or are hosted in different regions. This feature, known as VPC Network Peering, can result in better security (as services do not need to be exposed on public IP addresses) and performance (due to use of private, rather than public, networks and IP addresses).
Google Cloud VPC Network Peering allows internal IP Address connectivity across two Virtual Private Cloud (VPC) networks regardless of whether they belong to the same project or the same organization.
You have two separate VPC networks without overlapping subnet IP address ranges
Kubernetes
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.
Each node in the pool has a Kubernetes node label, which has the node pool's name as its value. A node pool can contain only a single node or many nodes.
When you create a cluster, the number and type of nodes that you specify becomes the default node pool.
Cloud SQL :
Cloud SQL to host your MySQL database in Google's cloud, and let Google Cloud handle administrative duties like replication, patch management, and database management. Cloud Marketplace provides a simple click-to-deploy interface that makes it easy to install MySQL onto a Compute Engine instance.
Step 1: Creating the VPC networks
From the left navigation menu
select the -> VPC network -> VPC networks ->create vpc network
creating devloper vpc network as vpcdevproject with subnet lab1 within the ip address range 10.0.1.0/24 asia-southeast1
creating production vpc network as vpcprodproject with subnet lab2 within the ip address range 10.0.2.0/24 in region us-east1
Step 2: Connecting both devloper vpc network and production vpc network with vpc peering
From the left navigation menu, select the Networking-> VPC network -> VPC network peering.
Click the create connection button and Read the warning message and click the Continue button
Creating vpc peering with developer vpc network to peer with production vpc network
The Peering connection will be created and should display the status as Inactive
Repeat the above process and create a second peering connection, with production vpc network to peer with developer vpc network
The second peering connection will now be created. Once created, the two networks will automatically connect to each other with status active.
Step 3: Creating a Kubernetes Cluster in the project and launch a web application with the Load balancer
From the left navigation menu, select the kubernetes and create cluster
Creating a Kubernetes Cluster with location type as regional in the region us-central with size of one default pool node
once created the Kubernetes Cluster we get kubectl command line access by running the command
launching a web application word press with name myweb with the LoadBalancer on port 80 which default webserver is running.
Step 4:Creating a SQL server and a database in the project
From the left navigation menu, select the SQL and create instance
GCP providing three types of database engines
Creating SQL instance as mysqlservice with root user and password in region us-east1 and in zone us-east1-b
Adding the network as to access by every ip and every node but it is not good for security
creating a database with database name mysqlservice
we can connect sql instance with public ip address(database host) root user and password
Step 5:connect the SQL database to the web application launched in the kubernetes cluster
Accessing the external ip address of the web application launched in the kubernetes cluster
Connecting the web application using external ip address with port 80
Done this task under guidance of Vimal Daga Sir.In training of GCP Workshop by Linux World Informatics Pvt Ltd.