GCP WordPress Infrastructure

Neeraj Singh Negi
4 min readOct 9, 2020

VPC Network Peering | Load Balancer | Kubernetes|Wordpress |MySQL

  1. Create multiple projects namely Developer and Production.
  2. Create a 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.

Project

GCP manages the resources and services by Projects although without project we are not able to use any of the resources or services of GCP. If in the future, if you want to delete the whole project that it's easy for you to delete it in one click.

VPC Network Peering

Created a VPC (Virtual Private Network) in both the project. Also with the help of the VPC Network Peering, we connected both the VPCs together. Now, we are able to use a private network of GCP i.e reliable, secure, and very fast.

developer-vpc is in Singapore and another production-vpc is in US.

Firewall

A firewall is a way to secure the instance from unwanted vulnerabilities.

Created a VPC firewall that allows all IPs (0.0.0.0/0) and ports.

Load Balancer

Load Balancer Keeps on monitoring the Cluster Nodes if any of the nodes go down than it automatically launches the same instance in another node.

Created a Load Balancer with 3 Cluster Nodes and provide 1 IP.

This IP is mature if your instance goes down and launched a new instance although it never changes the IP that is connecting to the client. Behind the scene, it will continuously do the load balancing for the client i.e Reverse Proxy.

Kubernetes Cluster

Kubernetes is the container-orchestration tool. Kubernetes works on the top of the Docker container technology.

K8s helps to monitor the pods with the help of deployment that is very intelligent or mature. If the pods get down it will automatically launch the same pod in a second.

Docker Image

Docker image is like a bootable DVD that is used for the installation of an operating system.

Why I used the WordPress image?

WordPress Image is customized for the WordPress application.

hub.docker.com

MySQL

Created wordpressdb for the WordPress application.

Mysql by default has a root user that has unlimited permissions to the database. Also, we can create our own multiple users for different applications with limited permissions.

WordPress

WordPress

Here is the output that we configured in the GCP cloud. As you see the highlighted IP that is given by the load balancer.

Commands

Thank you :)

Soon coming with another blog :)

--

--

Neeraj Singh Negi

AWS | Openstack | GCP | Ansible | Redhat 8 Linux | Docker | Jenkins | Kubernetes | Hadoop | Python | Machine Learning