Deployment of WordPress on Kubernetes and SQL Database through GCP
Google Cloud Platform [GCP]
Google Cloud Platform is a suite of public cloud computing services offered by Google. The platform includes a range of hosted services for compute, storage and application development that run on Google hardware. Google Cloud Platform services can be accessed by software developers, cloud administrators and other enterprise IT professionals over the public internet or through a dedicated network connection.
Google Cloud Platform is a suite of public cloud computing services offered by Google. The platform includes a range of hosted services for compute, storage and application development that run on Google hardware. Google Cloud Platform services can be accessed by software developers, cloud administrators and other enterprise IT professionals over the public internet or through a dedicated network connection.
- Google Compute Engine, which is an infrastructure-as-a-service (IaaS) offering that provides users with virtual machine instances for workload hosting.
- Google App Engine, which is a platform-as-a-service (PaaS) offering that gives software developers access to Google’s scalable hosting. Developers can also use a software developer kit (SDK) to develop software products that run on App Engine.
- Google Cloud Storage, which is a cloud storage platform designed to store large, unstructured data sets. Google also offers database storage options, including Cloud Datastore for NoSQL nonrelational storage, Cloud SQL for MySQL fully relational storage and Google’s native Cloud Bigtable database.
- Google Container Engine, which is a management and orchestration system for Docker containers that runs within Google’s public cloud. Google Container Engine is based on the Google Kubernetes container orchestration engine.
Addition to this Google also offer Google Cloud Endpoints which allows developers to create services based on RESTful API’s, Any cast DNS servers, Direct interconnection, LOAD BALANCING, monitoring and logging services.
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.
A load balancer distributes user traffic across multiple instances of your applications. By spreading the load, load balancing reduces the risk that your applications experience performance issues. A load balancer distribute your load-balanced compute resources in single or multiple regions — close to your users — and to meet your high availability requirements. Cloud Load Balancing can put your resources behind a single any cast IP and scale your resources up or down with intelligent auto scaling.
A Virtual Private Cloud (VPC) is a global private isolated virtual network partition that provides managed networking functionality for your Google Cloud Platform (GCP) resources. In this diagram, you can see the default VPC network spanning multiple regions and zones, and subnets within various parts of the network servicing VMs. All of these subnets can natively route to each other, and as long as the firewalls permit it, VMs can reach one another within this VPC. The instances within the VPC have internal IP addresses and can communicate privately with each other across the globe.
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. … Traffic stays within Google’s network and doesn’t traverse the public internet.
POD : A pod is a collection of containers and its storage inside a node of Kubernetes cluster . It is possible to create a pod with multiple container’s inside it. Eg- one container for Data Base Management and one container for Wordpress in the same POD.
Using the above discussed services provided by Google, I have tried to perform a task of configuring two nodes in different regions, On one of the node I launched a Kubernetes services with load balancing to run WordPress and on another node which I launched in America data base center, On this I created a database for WordPress.
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
Now, As We all have gathered required Information for doing the task.
<Lets Get started Now>
- Creating two Projects devproject & prodproject
2. VPC network setup for the projects we created and peering [connecting] these network.
Now creating VPC network for project- “devproject” in the region us-central1
Creating Subnets inside the above network
The Range of IP will only be used in above network for assigning to the subnets.
Firewall for lab1
Right Now I have zero firewall and allowed all the IP, the firewall I created is totally unsecure but here we can create one for our lab whenever required.
Similarly, We did the same for the prodproject, The VPC network for this project I have made a setup in region “asia-southeast1” i.e. Singapore.
Creating Subnets in this VPC network with IP range as shown
Firewall “prodfirewall” is being setup
The above firewall is similar to that of above so I must reveal there is zero security for secure network we must use a good firewall setup but for now I will go with this only.
→ As we have made VPC for both the network now let us peer these networks.
Peering from devproject to prodproject and then did the same from prodproject to devproject.
We need to setup this from both side so as to give approval to devproject from prodproject that they can connect to prodproject and vice versa.
3. Launching instances in devproject using command
4. Launching Instance in Prodproject
Checking VPC Peering b/w the two projects
As you can see the VPC peering of networks was successful
5. Launching Kubernetes Cluster in devproject
Command which can also be used if we want to launch using CLI mode
Command Used to install kubernetes engine for using it on GCP through command prompt of windows.
6. Launching Kubernetes cluster
7. On Kubernetes-cluster Launching deployment of image “wordpress” which kubernetes install as container from docker hub.
Using the command “ kubectl.exe create deployment myos1 — image=wordpress ”
then I have replicated the image myos1 using command →
## kubectl.exe scale deployment myos1 — replicas=5 ##
8. launching Load balancer
Since all things are set . Therefore, Let’s connect the database to wordpress
So, for that we will the external IP of load balancer and get to login page of wordpress
Connection of database “wordpressdb” created in Singapore with image containing “Wordpress” already installed which is launched in US
The image used in this context was installed/pulled from docker hub
So, I successfully connected the database and wordpress.
#######TASK COMPLETED#######