Table of Contents
Introduction
Prerequisites
Step-by-Step Deployment Process
Step 1: Creating AWS EKS Cluster
Step 2: Adding Amazon EBS CSI Driver
Step 3: Launching EC2 Instance
Step 4: Installing Necessary Tools
Step 5: Adding Node Group to Cluster
Step 6: Configuring Kubeconfig
Step 7: Configuring aws-auth ConfigMap
Step 8: Applying Manifest Files
Step 9: Setting up MongoDB Replica Set and Loading Data
Testing the Application
Conclusion
1. Introduction
In this guide, we will walk through the deployment process of a cloud-native voting application on Amazon Elastic Kubernetes Service (EKS). The application consists of three tiers: web tier (frontend), application tier (API), and data tier (MongoDB). We will deploy each component of the application and ensure its functionality within the Kubernetes cluster.
2. Prerequisites
Before proceeding with the deployment, ensure you have the following prerequisites:
An AWS account with appropriate permissions to create EKS clusters and EC2 instances.
AWS CLI installed and configured with appropriate access credentials.
kubectl installed on your local machine.
Access to clone the Git repository containing the application code.
3. Step-by-Step Deployment Process
Step 1: Creating AWS EKS Cluster
To create an EKS cluster named cluster-1
, follow these steps:
Sure, here's a step-by-step guide to creating an Amazon EKS cluster:
1: Sign in to the AWS Management Console
Visit the AWS Management Console at https://console.aws.amazon.com/ and sign in with your AWS account credentials.
2: Open the Amazon EKS Console
Navigate to the Amazon EKS console by typing "EKS" in the search bar or selecting it from the list of services.
3: Choose "Create Cluster"
Click on the "Add Cluster" button to begin the cluster creation process.
4: Configure Cluster Basics
Cluster Name: Enter a unique name for your cluster, such as "my-eks-cluster".
Kubernetes Version: Choose the desired Kubernetes version for your cluster. It's recommended to select the latest stable version.
Role ARN: Select or create an IAM role that has permissions to create and manage resources for your EKS cluster.
Add:
5: Configure Networking
VPC: Choose an existing VPC or create a new one for your EKS cluster.
Subnets: Select one or more subnets within the chosen VPC. Ensure that these subnets have outbound internet access and can communicate with other AWS services.
6: Configure Cluster Scaling
Node Group: Choose the type of compute resources (EC2 instances) for your EKS cluster. You can either create a new node group or use an existing one.
Instance Types: Select the instance types and desired number of nodes for your node group.
SSH Key Pair: Specify an existing EC2 key pair to enable SSH access to your nodes for troubleshooting purposes.
7: Configure Add-ons (Optional)
Enable or disable cluster add-ons such as Amazon EBS CSI Driver, Amazon CloudWatch Container Insights, and AWS Load Balancer Controller based on your requirements.
8: Review and Create
Review the configuration settings for your EKS cluster and make any necessary adjustments. Once you're satisfied, click on the "Create" button to initiate the cluster creation process
9: Wait for Cluster Creation
The cluster creation process may take several minutes to complete. Monitor the progress in the Amazon EKS console until the status changes to "Active" for your newly created cluster.
10: Access and Manage Your Cluster
Once the cluster is active, you can access and manage it using tools like kubectl
or through the Amazon EKS console. You can also integrate the cluster with other AWS services and deploy applications onto it.
That's it! You've successfully created an Amazon EKS cluster. You can now start deploying and managing your containerized applications on this cluster.
Step 2: Adding Amazon EBS CSI Driver
Add the Amazon EBS CSI driver to the created cluster to enable EBS volumes for storage.
Click on Get more add-ons
Step 3: Launching EC2 Instance
Launch an EC2 instance with Ubuntu AMI, t2.micro instance type, and attach necessary IAM role (ec2-eksaccess-Role
).
Create Role:
Attach That role to Ec2 instance:
Step 4: Installing Necessary Tools
Connect to the EC2 instance via SSH and install kubectl
, aws cli
, and clone the Git repository containing the application code.
Step 5: Adding Node Group to Cluster
Add a node group (NodeGroup
) to the existing EKS cluster (cluster-1
) to provide compute capacity for Kubernetes pods.
Cluster is Active :
Scroll down select on "comput" and click on "Add node group"
Give a name to node group
Select Role , if you don't have a role create one.
Permissions to that role:
Attach here
Compute configuration:
Review and Create:
It will take couple of minutes to create node:
Step 6: Configuring Kubeconfig
Update kubeconfig
on the EC2 instance to interact with the EKS cluster by running aws eks update-kubeconfig
command.
Step 7: Configuring aws-auth ConfigMap
Edit the configmap aws-auth
within the kube-system
namespace to allow EC2 instances to join the EKS cluster.
Step 8: Applying Manifest Files
Apply manifest files related to deployment, including MongoDB statefulset, services, and secrets. Before applying create "cloudchamp " namespace :
Step 9: Setting up MongoDB Replica Set and Loading Data
Initialize the MongoDB replica set and load sample data into the database.
Click Here for complete step by step process.
4. Testing the Application
Test the API endpoints using
curl
commands to ensure proper functionality.Create frontend deployment and expose it through a LoadBalancer service.
Confirm the frontend ELB is ready to receive traffic.
Test the end-to-end functionality of the application by browsing to the frontend URL, voting, and observing data changes in MongoDB.
5. Conclusion
In this guide, we have successfully deployed a cloud-native voting application on AWS EKS. By following the step-by-step deployment process, you can deploy similar applications on your own EKS clusters. Ensure to test thoroughly and monitor the application for any issues. Happy deploying!