Voiced by Amazon Polly |
Introduction
Amazon EKS (Elastic Kubernetes Service) has been used widely for running Kubernetes clusters on AWS. It is a managed service, so you don’t have to manage everything manually. When using Amazon EKS, AWS creates and manages control plane nodes for you and allows you to focus on your applications.
Maximize Performance and Minimize Throughput Costs with Amazon Dynamo DB
- Developer friendly
- Automatic backup and restore
- Cost effective
Architecture
The following diagram depicts important components involved while using EKS.
The EKS control plane comprises the Kubernetes API server nodes, etcd cluster. Kubernetes API server nodes that run components like the API server, scheduler, and kube-controller-manager run in an auto-scaling group. EKS runs a minimum of two API server nodes in distinct Availability Zones (AZs) within in AWS region. Likewise, for durability, the etcd server nodes also run in an auto-scaling group that spans three AZs. EKS runs a NAT Gateway in each AZ, and API servers and etcd servers run in a private subnet. This architecture ensures that an event in a single AZ doesn’t affect the EKS cluster’s availability. An elastic data plane ensures that Kubernetes can scale and heal your applications automatically. A resilient data plane consists of two or more worker nodes, can grow and shrink with the workload, and automatically recover from failures. You have two choices for worker nodes with EKS: EC2 instances and Fargate. If you choose EC2 instances, you can manage the worker nodes yourself or use EKS managed node groups. You can have a cluster with a mix of managed, self-managed worker nodes, and Fargate.
Setting up your AWS Environment for EKS
1. Installing the AWS CLI.
The AWS Command Line Interface (AWS CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.
2. Configuring AWS CLI Credentials using the access key ID and secret access key of the IAM user using the command ‘aws configure’.
3. Install kubectl.
Kubectl is a command line tool used to run commands against Kubernetes clusters. It does this by authenticating with the Master Node of your cluster and making API calls to do a variety of management actions. If you’re just getting started with Kubernetes, prepare to spend a lot of time with kubectl!
4. Configure kubectl for EKS.
Sample command:
1 |
curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl |
Launch AWS EKS
5. Create cluster
1 |
Sample command : eksctl create cluster --name ekscluster --region us-east-1 –fargate |
A Kubernetes (K8s) cluster is a group of computing nodes, or worker machines, that run containerized applications. Containerization is a software deployment and runtime process that bundles an application’s code with all the files and libraries it needs to run on any infrastructure.
6. Install eksctl
Sample command:
1 |
eksctl create fargateprofile --cluster ekscluster --region us-east-1 --name alb-sample-app --namespace application1 |
eksctl is a simple CLI tool for creating and managing clusters on EKS – Amazon’s managed Kubernetes service for EC2. It is written in Go, uses CloudFormation, was created by Weaveworks and it welcomes contributions from the community.
Launch Application
7. kubectl apply -f <path to the .yaml file of your application>
Sample yaml file — Run NGINX Containers using a YAML File
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
– name: nginx-container
image: nginx:latest
ports:
– containerPort: 80
Verify Application
8. kubectl get pods -n application1
Sample output
9. kubectl get svc -n application1
Sample output
Add Application Load Balancer
Once the application is up, one can additionally add load balancer using AWS Application Load Balancer. The steps involved
1. Download the IAM policy
1 |
curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.5.4/docs/install/iam_policy.json |
2. Create the IAM Policy
1 |
aws iam create-policy --policy-name AWSLoadBalancerControllerIAMPolicy --policy-document file://iam_policy.json |
3. Create IAM Role
1 |
eksctl create iamserviceaccount --cluster=ekscluster --namespace=application1 --name=aws-load-balancer-controller --role-name AmazonEKSLoadBalancerControllerRole --attach-policy-arn=arn:aws:iam::<your-aws-account-id>:policy/AWSLoadBalancerControllerIAMPolicy --approve |
4. Deploy Application Load Balancer controller
- Add the helm repository
Sample Command:
1 |
helm repo add eks https://aws.github.io/eks-charts |
- Update the repository
1 |
helm repo update eks |
- Install the load balancer
1 |
helm install aws-load-balancer-controller eks/aws-load-balancer-controller -n kube-system --set clusterName=ekscluster --set serviceAccount.create=false --set serviceAccount.name=aws-load-balancer-controller --set region=<region> --set vpcId=<your-vpc-id> |
- Verify the installation
1 |
kubectl get deployment -n kube-system aws-load-balancer-controller |
Conclusion
The step-by-step process helps in setting up all the entire end to end environment for launching your application using AWS EKS. The process starts with understanding the architecture, setting up the prerequisite, creating and configuring the cluster, launching the application and verifying the same. Additionally, one can make use of AWS Application Load balancer to serve as the single point of contact for the application.
Enable smarter efficient workflows through Amazon MLOps Eco-system
- Improve speed
- Reduce time
- Zero downtime
About CloudThat
CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.
CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 650k+ professionals in 500+ cloud certifications and completed 300+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training Partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, AWS GenAI Competency Partner, Amazon QuickSight Service Delivery Partner, Amazon EKS Service Delivery Partner, AWS Microsoft Workload Partners, Amazon EC2 Service Delivery Partner, Amazon ECS Service Delivery Partner, AWS Glue Service Delivery Partner, Amazon Redshift Service Delivery Partner, AWS Control Tower Service Delivery Partner, AWS WAF Service Delivery Partner and many more.
To get started, go through our Consultancy page and Managed Services Package, CloudThat’s offerings.
WRITTEN BY Vivek Kumar
Click to Comment