Deploying a Multi-Tier Web Application on Kubernetes with AWS

Deploying a Multi-Tier Web Application on Kubernetes with AWS

As I progress on my DevOps journey, I recently completed a significant project: deploying a multi-tier web application on a Kubernetes cluster using AWS. This project incorporated various technologies such as nginx, tomcat, mysql, rabbitmq, and memcached. Here's a detailed overview of the project, the steps I took, and how it all came together.

Project Overview

In this project, I aimed to deploy a robust, multi-tier web application on a Kubernetes cluster hosted on AWS. The key components and technologies used in the application included:

  • nginx: for web traffic handling and load balancing.

  • tomcat: to serve Java web applications.

  • mysql: as the database server.

  • rabbitmq: for messaging between services.

  • memcached: to provide caching for faster application performance.

Additionally, I used AWS Route53 for DNS management to map my application to a personal domain from GoDaddy. I also created an S3 bucket for storing Kubernetes cluster configuration files and an EBS volume for the database pod. The Docker images used were created and imported from my DockerHub account, and I labeled the nodes with zone names to ensure optimal resource distribution.

Step-by-Step Deployment Process

1. Setting Up the EC2 Instance for Kubernetes

The first step was to set up an EC2 instance to host the Kubernetes cluster. This instance was configured with the necessary security groups and IAM roles to facilitate Kubernetes operations.

2. Installing Kops for Cluster Management

Next, I installed Kops (Kubernetes Operations) to manage the Kubernetes cluster. Kops simplifies the process of creating, updating, and maintaining production-grade Kubernetes clusters.

3. Configuring DNS with Route53 and GoDaddy

To ensure my application was accessible via a personal domain, I set up Route53 hosted zones and configured the DNS records on GoDaddy to point to these hosted zones.

4. Creating an S3 Bucket for Configuration Storage

An S3 bucket was created to store the Kubernetes cluster configuration files. This central storage ensures that configuration files are easily accessible and manageable.

5. Validating DNS Configuration with Nslookup

Using the nslookup command from the EC2 instance, I validated the nameserver records to ensure that the DNS settings were correctly configured and functional.

6. Creating an EBS Volume for the Database Pod

To provide persistent storage for the MySQL database pod, I created an EBS volume using the AWS CLI. This step ensures data durability and persistence across pod restarts.

7. Building and Importing Docker Images

I created Docker images for each component of the application (nginx, tomcat, mysql, rabbitmq, and memcached) and imported them into my DockerHub account. These images were then pulled into the Kubernetes cluster for deployment.

8. Labeling Kubernetes Nodes

For better resource management and high availability, I labeled the Kubernetes nodes with their respective zone names. This labeling helps in distributing the application components across different availability zones.

9. Deploying the Application on Kubernetes

With everything set up, I used the kubectl create command to deploy the application components defined in the Kubernetes definition files. These files, which are available in my GitHub repository, include the necessary configurations for deploying the multi-tier application.

10. Accessing the Deployed Application

After successfully deploying the application, I accessed it through the web to ensure all components were functioning as expected. The final home page of the deployed web app confirmed the successful deployment.

Conclusion

Completing this project was a significant milestone in my DevOps journey. It demonstrated my ability to deploy complex, multi-tier applications on Kubernetes using AWS infrastructure. The experience gained from configuring DNS, managing Kubernetes with Kops, handling Docker images, and ensuring data persistence with EBS volumes has been invaluable. For detailed configuration files and more insights, you can check out my GitHub repository.


Screenshots

  1. EC2 Instance for Kubernetes Cluster

  2. Route53 Hosted Zone on AWS

  3. DNS Records from GoDaddy

  4. S3 Bucket Configuration on AWS

  5. Nameserver Validation using Nslookup

  6. Kops Installation for Cluster Management

  7. EBS Volume Creation using AWS CLI

  8. Node Labeling with Zone Names

  9. Application Deployment using kubectl create

  10. Final Home Page of the Deployed Web App