Launching WebApp Using GKE and SQL services of GCP

project of launching webapp on cloud,

project details...

1. Multiple projects namely developer and production.

2. VPC network for both the projects.

3. Link between both the VPC networks using VPC Peering.

4. Kubernetes Cluster in developer project and launching WordPress with the Load balancer.

5 SQL server in the production project and create a database.

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

---------------------------------------------------------------------------------------------------------------

Let's start the practical part.

1) You must have the GCP account or GCP IAM account.

2) Create a Development project and the Production project as shown.

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

3 . Now create the VPC in both projects in different region as you want, we have created as.

-In Production Project VPC is created in the asia-southeast1(Singapore) with 1 subnet.

-In Development Project VPC is created in the us-east1 (USA) with 1 subnet.

NOTE: You can create VPC in any region as you want with as many subnet, here we were created the 1 subnet for each vpc as we required only 1.

No alt text provided for this image

process for another vpc.

No alt text provided for this image

4) Then we have to connect the both VPC internally, as private ip can only connect to private if they are in same network or connected with LAN so here we are connecting with LAN refer this for more, here we are not making SQL database public that's why we need to make internal connection of the both VPC, so that all the instances in both VPC can interact with each other using private ip, but here we are allowing all ip to connect to sql instance either publicly or privately. Peering should be from both side means we have to do connection/peering from both VPC as shown.

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

5) Create database from SQL service as shown.

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

After creation you will see this dashboard as above.

Here you can create Database and user also as shown, but here we are going to use root user and as we are installing the WordPress so we don't need to create database WordPress will create database automatically, though we have shown how to create database and user.

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

Also you can create the database and user from the cli, cloud shell or from your CMD if you knows the quries of SQl, we have shown below how to connect with sql instance using cloud shell.

No alt text provided for this image

6) Now we have to create the Kubernetes cluster using GKE(Google Kubernetes Engine) as shown. In the Gcp kubernetes is the fully managed service by the GCP.

No alt text provided for this image

In cluster basics you can select any region as you want, hare we have selected us-east1 because our VPC from project with name development is in same region and we have selected 3 subnets so our instance will launch in three subnets and also selects the version of the master node of the K8S's master-slave cluster.

No alt text provided for this image

Next is Node pool details here we have to mention the information about the slave node of the K8S's master-slave cluster like name of cluster, which version you want, no of node per Zone, zone means subnet, if you knows scaling then you can mention the minimum and the maximum number of instance or pod.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
Commands to run for deployment :


//To connect to master slave from url 

#gcloud container clusters ger-credentials k8s-for-wordpress --region us-east1 --project sswprod417752




//To get pods

#kubectl get pods




//To get Nodes

#kubectl get nodes




//To get services

#kubectl get service




//To deploy the instance

#kunectl create deployment ssw-wp --image=wprdpress




//To expose the deployment or to attache a load balancer to master node

#kunectl expose deployment ssw-wp --type=LoadBalancer --port=80




//To get services also you will get the ip of loadbalancer

#kubectl get service
No alt text provided for this image

And finally the WordPress is launched. So here is the complete environment for the webapp.





Shyam Sulbhewar

Software Engineer At BUSINESSNEXT

4 年

Nice job

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

Chirag Deepak Ratvekar的更多文章

社区洞察

其他会员也浏览了