AWS INTEGRATION WITH MINIKUBE AND RDS
Hey!! Tech Enthusiasts looking for a persistent and self managed database and a site with no downtime.You are at the right place. I am going to create a WordPress site and connect it with the RDS service of the AWS cloud that provides various databases in which we can store the data and it will be fully managed by the AWS. All of the above I am going to integrate it with the Kubernetes which will help in making ZERO DOWNTIME and all the process through Terraform.
Let me introduce you with some of the terminologies which will help you in understanding the concepts :
KUBERNETES => Kubernetes is open source software that allows you to deploy and manage containerized applications at scale. Kubernetes manages clusters of Amazon EC2 compute instances and runs containers on those instances with processes for deployment, maintenance, and scaling. Using Kubernetes, you can run any type of containerized applications using the same toolset on-premises and in the cloud.
RDS(Relational Database Service) => Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate, and scale a relational database in the cloud. It provides cost-efficient and resizable capacity while automating time-consuming administration tasks such as hardware provisioning, database setup, patching and backups. It frees you to focus on your applications so you can give them the fast performance, high availability, security and compatibility they need.
DATABASE => A database is an organized collection of data, generally stored and accessed electronically from a computer system. Where databases are more complex they are often developed using formal design and modeling techniques.The database management system (DBMS) is the software that interacts with end users, applications, and the database itself to capture and analyze the data.
Terraform => It is an open-source infrastructure as code software tool created by HashiCorp. Users define and provision data center infrastructure using a declarative configuration language known as HashiCorp Configuration Language (HCL), or optionally JSON. HashiCorp maintains an extensive list of official providers, and can also integrate with community-developed providers.Users can interact with Terraform providers by declaring resources or by calling data sources.
If you are in the AWS Cloud you should first go through this blog.
Now let us move to create the setup. I will be providing the GitHub link at the end of this blog for your reference.
STEP-1 First of all we will be going to log in the AWS Cloud through CLI as shown here.
STEP-2 We will now create the WordPress through Terraform and integrate it with the Kubernetes as shown below.
CODE FOR KUBERNETES CLUSTER :
We will also be creating a service mainly for exposing this site to the Public World as shown below.
CODE FOR SERVICE :
Now once you have written the code save the file with the extension .tf
After saving the file do the following:
- terraform init
- terraform validate
- terraform apply or terraform apply -auto-approve
as shown below.
Now first confirm whether the deployment is created or not by
kubectl get deployment or kubectl get deploy as shown below.
You can also check for the pods as shown below by the command
kubectl get pods
To confirm it whether it is created or not you can check it by taking the IP of your Minikube and the public port that was generated.
Let me guide you for it.
For getting Minikibe IP :
You can use the command minikube ip as shown below.
When found it now get the public port at which our WordPress site is created.
For getting this use the command
kubectl get services or you can use kubectl get all
as shown below.
Now copy the port no. as shown below.
Now copy the Minikube IP and the port number which is highlighted above and paste it to the browser as shown below and you will see that your a WordPress site will be launched.
STEP-3 Now we will be going to create the database service with RDS in AWS Cloud through Terraform.
CODE FOR MYSQL :
After saving the file do the following:
- terraform init
- terraform validate
- terraform apply or terraform apply -auto-approve
as shown below.
You will see that a database will be created in the Cloud within RDS Service and will be automatically connected to the VPC and Security Groups in the Cloud.
STEP-4 Let us now go and connect it to the WordPress site which we launched.
For doing this go to the WordPress Site and after that Click on Continue as shown below.
Once clicked You will be landed to this Page as shown below.
Write the name of the Database , username and password used in the terraform code of MySQL.
Once it is done in the Database Host write the Endpoint of the RDS Database made in the cloud.
For doing this copy the Endpoint of the Database as shown below( You will be on this page after clicking the database page)
Go to the WordPress again and paste it in the database as shown below.
You will be landed to the page shown below.
The above picture shows that you are connected to the Database.
After that you will be asking for creating the ID and Password for WordPress just create it as shown below.
After this you will land to the Login Page as shown below. Login with your ID and Password.
Once logged in you will be on the Dashboard of the WordPress as shown below.
So, this was the whole setup. So easy and short.
Thanks a lot !! Hope you learned and enjoyed.
Here is the GitHub Link which consist of all the code used above.