Deploy the EKS Cluster using terraform then deploy a Spring Boot application in the EKS Cluster
We will do in a simple way:
At first we are going to deploy EKS Cluster with Terraform
Secondly we are going to deploy the Spring Boot Application on the EKS Cluster.
let's get our hands dirty
Clone the Github repo
Go to src folder then add your S3 bucket name, Dynamodb table name and region in the backend.tf file for remote terraform statefile.
Add your AWS account user access key and secret access key in the terraform.tfvars file. Other things are optional.
S3 bucket and DynamoDB table both should be in same Region.
Make sure below things:
Access and Secret keys Add in the .bashrc file
AWS Profile is configured on your linux machine or we can use the default account also.
We can see the S3 bucket and DynamoDB table in the below images
Run the below command:
$ terraform init
$ terraform plan
$ terraform apply
After deploying EKS cluster using terraform, the output will be like below.
We can see the terraform state file in the below image
We can see the EKS Cluster deployed successfully in the below image
Now configure the kubeconfig on your machine for access the EKS Cluster, following the below command
$ aws eks --region us-west-2 update-kubeconfig --name AscendionWorkshop-cluster
$ kubectl get nodes –o wide
$ kubectl get pods
Switch to eks directory then deploy the SprintBoot application by using the below commands
$ kubectl apply –f deployment.yaml
Check the deployment is successful or not
$ kubectl get deployment –l app=springboot
Then deploy the Service
$ kubectl apply –f service.yaml
$ kubectl get svc
Now we can see the SpringBoot application deployment successfully
Now access the SpringBoot app by entering the external address of the springboot LoadBalancer in any browser from the Outside