Hosting WordPress on GCP K8s Cluster With MySQL Database on AWS- Using Terraform
We are going to deploy a WordPress application on top of Kubernetes cluster using Kubernetes service of Google Cloud Platform (GCP) along with Load Balancer and for database, we will be creating a MySQL db instance using RDS of Amazon Web Services (AWS). All of these using Terraform.
So, these are the steps -
- Creating a VPC, subnet and firewall rule inside a project on GCP.
- Create a Kubernetes cluster, deploy WordPress on top of it with LoadBalancer service.
- Using Relational Database Service (RDS) of AWS and creating a MySQL db instance for connecting it to the WordPress site.
Every resource on GCP needs to be created inside a project, so first we should have a project.
Screenshots of the output:
First we do terraform init to download all the providers used (google, terraform and aws)
Now, terraform plan to see what resources will be created actually after apply
Finally, apply to create all the resources.
We can go to GCP console and see all the resourecs are created there (VPC, kubernetes cluster, wordpress deployment, Load balancer)
Also, in AWS our MySQL database instance is created
Let’s connect to our WordPress site using the load balancer ip address, connect to the database and complete the setup.
This is how we can create a complete WordPress-MySQL architecture using two different cloud platforms.
Github url for the code: