Deploying Wordpress on top of Google Cloud Platform with Kubernetes
What is Cloud Computing?
Cloud computing is the delivery of computing services — including servers, storage, databases, networking, software, analytics, and intelligence — over the Internet (cloud) to offer faster innovation, flexible resources, and economies of scale. We only pay for cloud services you use, helping lower your operating costs, run your infrastructure more efficiently and scale as your business needs change.
Task Details :
- Create multiple projects namely developer and production
- Create VPC network for both the projects
- Create a link between both the VPC networks using VPC Peering
- Create a Kubernetes Cluster in developer project and launch any web application with the Load balancer
- Create a SQL server in the production project and create a database
- Connect the SQL database to the web application launched in the Kubernetes cluster
I completed this project using Google Qwiklab and since I use single project for both development and production . Qwiklab gives you temporary credentials(200 credits) to Google Cloud Platform so you can learn the cloud over duration of 30–50 minute labs per session. 1 session costs you 1 credit.
Google Cloud Platform
Google Cloud Platform is a 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.
The core cloud computing products in Google Cloud Platform include:
- 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 (PASS) 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.
So lets begin,
- Go to Qwiklabs and login/create an account if you don’t already.Once logged in, you will see “Baseline: Deploy & Develop” quest. Click on the blue button “Enroll in the quest”.Once enrolled, go to the first lab and click on Start Lab. You can use either 30 min or 50 min lab each cost you 1 credit.
2. Click on Open Google Console and enter the username and password provided . And you will be directed to following screen.
3. Under these project we have to create two VPC ( Virtual Private Cloud ) one for WordPress deployment and second for MySQL Database Instance .
4. Click on Create VPC Network … Here, I’m going to create developervpc in Singapore region
5. In the same way, create another VPC in OREGON region
6. For connecting these VPC’s we have to use VPC Peering service of GCP . For peering the VPC’S we have to create VPC peer for both VPC1 and VPC2 as peer1 and peer2 .
7. Create peering connection in developervpcand productionvpc
8. Now create Kubernetes Cluster in developervpc.To enable Compute Engine Api ,Click on Api’s & Services,library,Compute and then Compute Engine Api.
9. Now create Kubernetes Cluster in developervpc and Click on create button .
10. Connect to the Cluster using CLI(google shell) by clicking on Connect.
11. You can see the nodes in the cluster using this cmd kubectl get nodes
12. Now in one pod of the cluster we will launch docker image called WordPress.
kubectl create deployment mywordpress --image=wordpress
13. After creation of pod we will expose the pod using LoadBalancer which will be used to balances the traffic load on port number 80 to access the application. It will take some time to expose the pod.
kubectl expose deployment mywordpress --type=LoadBalancer --port=80
14. Now our front end of WordPress application got ready. To create the back end means to store the user data of WordPress application we use MySQL database by Google Cloud .
So,we have to launch these MySQL Database instance using SQL service of Google Cloud in production environment and add firewall to it.
15. To heck everything is working smoothly use command
Eg mysql -h IP -u root -p
mysql -h 220.127.116.11 -u root -p
16. Create a database through wordpress will connect
17. Now connect to the WordPress instance that we have launched in Kubernetes cluster and copy the IP adress of wordpress instance and open it in browser.
kubectl get all