Launching Wordpress on minikube with its database connection to RDS on Amazon Cloud ..

khushi thareja
4 min readSep 6, 2020

--

What is MINIKUBE ?? Minikube is a tool that makes it easy to run Kubernetes locally. Minikube runs a single-node Kubernetes cluster inside a Virtual Machine (VM) on your laptop for users looking to try out Kubernetes or develop with it day-to-day.

What is RDS ?? Amazon Ralation Database service is a DBAAS( Database as a service) provided by the Amazon. It makes it easy to set up, operate, and scale a relational database onthe cloud. It provides cost-efficiency and automates the time consumption tasks such as hardware provisioning, database setup, patching and backups. Managing the database on the cloud lets you focus on your applications and invest your time on fast performance, high availability, security and compatibility they need.

So, here I created an infrastructure where I launch a wordpress application on minikube in my local system and connected it to the database service provided by Amazon.

Let’s start by building the code.

First, we set up the provider for downloading the plugins required for the Kubernetes set up & AWS Cloud Platform.

We need to set the profile before hand if we dont want to provide the credentials at the time of building code. The profile can be set using the command aws configure — profile profilename

Next, I have set a data source for the availability zone

Creating RDS

When we ask Amazon for the database services, Amazon too launches the database in an instance itself, but with extra security, amazing network connectivity as well as within a fault tolerant environment. and therefore, we need to set the vpc, subnets, security groups etc. Here I have used the default VPC and default subnet groups.

So, let us configure the security group next.

A security group acts as a virtual firewall for your EC2 instances to control incoming and outgoing traffic. Inbound rules control the incoming traffic to your instance, and outbound rules control the outgoing traffic from your instance. My ingress settings are to only allow traffic to come to port 3306 while the egress settings are to allow all the traffic.

Creating Subnet Groups and instance.

Options used here to create a database instance can be explained as :

  • engine & engine version — Engine specifies The name of the database engine to be used for the RDS instance. whereas the engine version is the The database engine version.
  • identifier — The name of the RDS instance.
  • username & password — This is the username and password for the Database to login to. For further security, set the password in a secure file.
  • instance class — The instance type of the RDS instance.
  • storage type — Standard GP2: General Purpose SSD storage offers cost-effective storage that is acceptable for most database workloads.
  • allocated storage — Specified the amount of allocated storage.
  • publicly accessible — This is set true because I want it to be accessed by the pod launched in Minikube. If EC2 instance would have been used then it could be set to false.
  • name — This is the name of the first database that will be created. If not specified, then no database will be created initially.
  • parameter group name — Name of the DB parameter group to associate.
  • skip final snapshot — I have set this value false, so no snapshot will be created while deleting the DB instance. If you have set this to true then specify the name of the snapshot.

Launching Wordpress on Minikube

Here i have created the deployment using the latest wordpress image. Since this wordpress is going to connect our RDS database we need to pass information like the database name, username , password in the form of environment variables.

Creating service

Finally created the Service for the WordPress pod. Here I have specified the node_port = 31002. This will allow the client to hit on a fixed URL.

Also, i am creating an extra resource which will pick the ip and open it up over the browser for us and we can directly see the output

Minikube Output

So, to confirm that the wordpress we just launched uses our RDS database only we match the endpoint of RDS and the database the wordpress is using..

Endpoint of RDS
Database host used by Wordpress

All the codes are available on my GitHub as well.

That’s all. Do leave your valuable feedbacks !!

--

--