HYBRID MULTI CLOUD TASK 6 | | Deploy the word-press application on K8S and AWS using Terraform
Amit Sharma
CKA || 1xAWS || 4xGCP || 1xAzure || 2xRedHat Certified || DevOps Engineer [???????]@Searce Inc || Freelancer || Terraform || Ansible || GitLab || Jenkins || Kubernetes || Docker || Openshift || AWS || GCP || Azure
Hello Guys, back with another article. In this article you will find a word press application has been launched using Kubernetes on AWS using terraform.
So let's start this task. Launch a Minikube virtual machine on Oracle VM. Start the Minikube and do all the installation requirements.
Then you need to Install Kubernetes on Windows or linux. Here, i have installed Kubernetes on Windows.
After that write the write the below code to launch the Kubernetes pods.
provider "kubernetes"{ config_context_cluster = "minikube" } resource "kubernetes_deployment" "test1" { metadata { name="wordpress" labels={ test="wp" } } spec { replicas =3 selector { match_labels = { test = "wp" } } template{ metadata{ labels={ test = "wp" } } spec{ container{ image="wordpress:4.8-apache" name="wprdpress" } } } } } resource "kubernetes_service" "lb1"{ metadata{ name="lb" } spec { selector ={ test = "wp" } port{ node_port = 31000 port = 80 target_port = 80 } type= "NodePort" }
}
Then we have to run this code.
terraform apply
This will launch Wordpress on a pod launched by terraform.
As you can see we have launched, The wordpress.
Now, we have to launch the Amazon RDS. in which we have to launch MYSQL Data base.
provider "aws"{ region = "ap-south-1" profile = "Amit" } resource "aws_db_instance" "mydb"{ allocated_storage = 10 storage_type = "gp2" engine = "mysql" engine_version = "5.7" instance_class = "db.t2.micro" name = "RDS_db" username = "amit" password = "amit123" port = "3306" parameter_group_name = "default.mysql5.7" iam_database_authentication_enabled = true publicly_accessible = true skip_final_snapshot = true tags = { Name = "mydb" } }
We have to launch MYSQL database using terraform on AWS inside RDS.
Now as you can see the Amazon RDS is launched successfully.
As you can see that we have launched Wordpress successfully.
Hope you had liked my article. like and comment !!
Thank You !
SDE @Sarvaha Systems | Full Stack Web Developer | Angular | Node.js | Problem Solving | AWS
4 年Good work