AWS Elastic Kubernetes Service (EKS) is a managed Kubernetes service offered by Amazon Web Services (AWS). Kubernetes itself is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. EKS simplifies the process of deploying, managing, and scaling Kubernetes clusters in the AWS cloud environment. Let's explore why AWS EKS is valuable through a real-time example.
Scenario: Building a Microservices-Based E-Commerce Platform
Imagine you're part of a team tasked with developing an e-commerce platform for a rapidly growing online retailer. The platform is expected to handle a large volume of traffic, and the architecture must be highly scalable, resilient, and efficient. The team decides to implement a microservices architecture using containers orchestrated by Kubernetes, and they choose AWS EKS as their managed Kubernetes service.
1. Infrastructure Provisioning: Initially, the team sets up the infrastructure for the platform. With AWS EKS, they can easily provision Kubernetes clusters without worrying about the underlying infrastructure. They use the AWS Management Console, AWS CLI, or Infrastructure as Code (IaC) tools like AWS CloudFormation or Terraform to create and manage EKS clusters. This eliminates the need to manually configure servers, networking, and other components, saving time and reducing the risk of human error.
2. Scalability: As the e-commerce platform gains popularity, the traffic load increases rapidly. With AWS EKS, the team can scale their Kubernetes clusters horizontally to handle the growing workload. Autoscaling features provided by EKS automatically adjust the number of nodes in the cluster based on resource utilization metrics such as CPU and memory usage. This ensures that the application remains responsive and available even during peak traffic periods, without the need for manual intervention.
3. High Availability and Fault Tolerance: High availability is critical for an e-commerce platform to prevent downtime and ensure a seamless shopping experience for customers. AWS EKS simplifies the implementation of high availability by distributing Kubernetes worker nodes across multiple Availability Zones (AZs) within an AWS Region. In the event of a hardware failure or AZ outage, the workload is automatically shifted to healthy nodes in other AZs, minimizing disruption and ensuring continuous service availability.
4. Application Deployment: With Kubernetes and EKS, the team can deploy containerized microservices independently, enabling faster release cycles and continuous delivery. They use Kubernetes Deployment objects to define the desired state of their applications, including the number of replicas, container images, and resource requirements. EKS manages the deployment process, ensuring that the desired state is maintained and automatically restarting containers if they fail or become unresponsive.
5. Service Discovery and Load Balancing: In a microservices architecture, services need to discover and communicate with each other dynamically. Kubernetes provides built-in service discovery through DNS, allowing services to be accessed using a consistent hostname. Additionally, AWS EKS integrates with Elastic Load Balancing (ELB) services such as Application Load Balancer (ALB) and Network Load Balancer (NLB) to distribute incoming traffic across multiple pods within the cluster. This ensures efficient load balancing and optimal performance for the e-commerce platform.
6. Monitoring and Logging: To ensure the health and performance of the platform, the team leverages Kubernetes monitoring and logging capabilities integrated with AWS services. They use tools like Amazon CloudWatch and AWS CloudTrail to collect metrics, monitor resource utilization, and detect anomalies in the Kubernetes clusters. EKS also integrates with third-party monitoring solutions such as Prometheus and Grafana for advanced monitoring and visualization of cluster metrics and application logs.
7. Security: Security is a top priority for the e-commerce platform, especially considering the sensitive customer data involved. AWS EKS provides several security features to protect the Kubernetes clusters and containerized workloads. These include IAM authentication for controlling access to EKS clusters, network policies for controlling traffic between pods, and integration with AWS Key Management Service (KMS) for encrypting sensitive data at rest and in transit.
Conclusion:
In summary, AWS Elastic Kubernetes Service (EKS) is a powerful tool for deploying, managing, and scaling containerized applications in the AWS cloud environment. By leveraging EKS, teams can build highly scalable, resilient, and efficient microservices architectures like the e-commerce platform described above. With features such as infrastructure provisioning, scalability, high availability, application deployment, service discovery, monitoring, logging, and security, EKS simplifies the complexities of Kubernetes orchestration, allowing developers to focus on building and delivering innovative applications to their customers.
Project 2-tier Application:
Now First we need to go create the EC2 Machine using Ubuntu.
Go to the AWS Management Console (https://aws.amazon.com/).
Sign in with your AWS account.
Navigate to EC2:
In the AWS Management Console, navigate to the EC2 service.
Launch an Instance:
Click on the "Instances" in the left navigation pane.
Click the "Launch Instances" button.
Choose an Amazon Machine Image (AMI):
In the "Step 1: Choose an Amazon Machine Image (AMI)" section, select an Ubuntu AMI. You can search for "Ubuntu" in the search bar and choose an appropriate version (e.g., Ubuntu Server 20.04 LTS).
Choose an Instance Type:
In the "Step 2: Choose an Instance Type" section, select "t2.medium" as the instance type.
Click "Next: Configure Instance Details."
Network Setting:
In the "Step 3: choose network setting" and click to edit button and add the vpc1 cloud
Configure Security Group:
In the "Step 4: Configure Security Group" section:
Create a new security group or use an existing one.
Add inbound rules to allow HTTP (port 80), HTTPS (port 443), and SSH (port 22) traffic.
after that go to the advance network configuration and add automatically assign secondary IP.
Add Storage:
In the "Step 5: Add Storage" section, you can leave the default storage settings or adjust as needed.
Click "Next: Add Tags."
Add Tags:
In the "Step 6: Add Tags" section, click "Add Tag."
For "Key," enter "Name" and for "Value," enter "Jenkins" (or your preferred name).
Click "Next: Configure Security Group."
Click "Review and Launch."
Review and Launch:
Review your configuration settings.
Click "Launch."
Select Key Pair:
In the key pair dialog, select "Choose an existing key pair" and choose the "minikube" key pair.
Acknowledge that you have access to the private key.
Click "Launch Instances."
View Instances:
Once the instance is launched, you can view it in the EC2 dashboard.
Wait for the instance to reach the "running" state.
Now Connect with ec2 machine.After that go to IAM And Create a USER.
Now click to Next button.
Need to set the permissions that is attach policies that is AdministratorAccess.
Now we have user that is kubectl-user. Now go to kubectl-user and go to security credentials, Attach the access keys.
Now we have access key go to the terminal that is ec2 machine using ubuntu so go to the ubuntu and install aws cli and attach the Access key
Install AWS Cli:
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" sudo apt-get install unzip unzip awscliv2.zip sudo ./aws/install
loggin to kuber-ctl user using access-key
Now After that need to install eksctl for creating cluster.
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
eksctl version
After that need to install kubectl .
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
Now need to create a cluster.
eksctl create cluster --name my-cluster --region us-west-2 --node-type t2.medium --nodes-min 2 --nodes-max 3
No we have ready cluster it take 20 Minutes.
Now we need to project that is available on internet you can search use any project we will use Londheshubham153 projects.
Project Code:
Need to clone this file .
Now need to update your cluster.
aws eks update-kubeconfig --name my-cluster --region us-west-2
Now need to go to eks branch first go to two-tier-flask-app and type the commnd.
git checkout eks
If we need to isolated this project so create a namespace.yaml file.
namespace.yaml:
apiVersion: v1
kind: Namespace
metadata:
name: two-tier-ns
Now apply namespace.yaml file. so the command is
kubectl apply -f namspace.yaml
Now we have created two-tier-ns namespace. Using this name space we run every file.
Now we need to run all the files.
now for checking pod running or not
You can see pods are running
you can see pod,service and deployment running.
Now we need to run flask-app. so run the all the file starting to flask.
Now fo check all.
Now you can check everything is running.
Now copy the load balancer (EXTERNAL-IP)and paste another browser.
Now you can see project is running, Now it i time to delete everything that is one command you can use
eksctl delete cluster --name my-cluster --region us-west-2
Now every service is delete, It take 10 Minutes.