How to Deploy a Wordpress site on a Kubernetes Clusters with Load Balancer Implementation upon Google Cloud Platform(GCP)
Hello Connections, here i have posted an article on how to use Google Cloud Platform , to deploy our Webserver inside Kuberenetes Clusters, where these clusters are connected with load balancer ,and at last we connected our database with this Webserver . This article include all the process & prerequisite to perform this task.
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 we will start the task & i will discuss all the step by step process or method to perform this task.
Step 1: Create two projects one for developer & another for production.
Create one project for the developer from where developer can work in their our own projects.
Create one project for the production department from where production guys can work in their our own projects.
Step 2: Create a VPC network for both the projects.
Vpc network is available in GCP inside Networking Section
After clicking on the create VPC network, we will create the network according to our requirements.First we will create for Dev Project and after that prod project.
Now you can see that vpc peering for the Dev project has been created but it is in inactive mode as the peering connection will be established only when both of the vpc network connected with each other, so similar kind of peering we have to create for Prod project also.
We can download the software from the given link: https://cloud.google.com/sdk/docs/quickstart-windows
Once you click on the google cloud SDK installer the software will downloaded and just we have to install it & use it.
Now we can do the further things that is related to the kubernetes like launching a pods , deployment , exposing the server etc. So before that we need one more command to use the kubernetes from the command line i.e; kubectl so we have to install these command in your system Command : gcloud components install kubectl.
So now i am going to create a deployment to launch a wordpress server inside the nodes of cluster that we created upon GCP, so to create a deployment we need the image name of the wordpress.
So to create the deployment we have to use a command :
kubectl create deployment word-press --image=wordpressAs you can see that we have created a deployment successfully & we can also check that our pods & deployments are successfully launched or not with the help of command i.e:
kubectl get deployments/deploy ( to know about the deployment )kubectl get pods ( to know about the pods )
we can also check the status or details of nodes that we have launched inside our kubernetes cluster , with the help of command
kubectl get nodes -o wide kubectl scale deployment word-press --replicas=3
So here we can see that number pods has been increased and all the pods are running , for more information about the pods we can use command:
kubectl get pods -o wideWe can see the service running currently inside kubernetes cluster with the command:
kubectl get svc/serviceskubectl expose deployment word-press --type=LoadBalancer --port=80Here you can see that the load balancer has also created on the top of the google cloud , so now you can use this load balancer to expose our IP, so that anyone from public world can use our web server or our website.
Step 5: Create a SQL server in the production project and create a database.
Now we have to create the a database server so that we can integrate it with the our wordpress server.
So here we will create a database instance on gcp cloud , so we use the production project to create the database server. So when we launched or create the database then in a parallel way it will create a MySQL instances.
As you can see that i have done some changes in my connections, allowed all the IP address to access my instance, it's not a good practise to do so because of certain security purposes, but since we are doing the testing we can consider this. Now we will create a user for our database so that we can use it.
As you can see that there is new user has been created with the name himalaya, so now we can use the same user for other things.
As you can see that in the above image we had connect our MySQL instances with the help of cloud shell & we had also shown the database of the instances.
Now we have to launched the wordpress on any of the web browser with the help of load balancer that we had use for the worpress pods , so we can connect it the that external ip, that was pending but now if you check it will provide you an external ip just type the ip in browser and your wordpress site will be running on.
Step 6: Connect the SQL database to the web application launched in the Kubernetes cluster.
This is all about this article , means how to deploy wordpress as a web server or as a frontend site , how to create a database on the top of GCP cloud , & how to connect both of them .
I hope you like this article, if you have any queries regarding this article or any or error while performing these task, you can contact me .
Thank You so much for reading my article.
Author: Himalaya Sahu (www.linkedin.com/in/himalaya-sahu-1982a2185/)



















































Comments
Post a Comment