Logo

dev-resources.site

for different kinds of informations.

Simple steps to create AWS EKS Cluster and Nodes

Published at
4/14/2024
Categories
aws
cloud
cloudformation
kubernetes
Author
ershubham
Author
9 person written this
ershubham
open
Simple steps to create AWS EKS Cluster and Nodes

Amazon Elastic Kubernetes Service (EKS):

Kubernetes is a set of open source tools that automates deployment , management and scaling of containerized applications. AWS EKS is a wrapper around Kubernetes that provides managed service to maintain Kubernetes control plane. As it is managed by AWS you do not need to install , scale , maintain and operate control plane.

Since cloudformation templates are the simplest approach to describe and deliver infrastructure declaratively while utilising maintainability and reusability, I have used them to create Clusters and Nodes.

Prerequisites:

  • An active AWS account.
  • Basic knowledge of AWS services specifically IAM,EKS and CloudFormation.
  • AWS CLI and Kubectl installed and configured on local machine.

1. Create EKS Cluster

Here is the CloudFormation template for EKS cluster creation. This comprises 3 sections Template Version, Parameters and Resources.

AWSTemplateFormatVersion:

Version of the CloudFormation template.

Parameters:

Required values that we will pass dynamically while creating stack using AWS CLI

Resources:

AWS resources required for the EKS cluster.

Image description

Save this file as AWS-EKSClusterTemplate.yml in your local machine and replace default values in Parameters sections and run below command that will create CloudFormation Stack and EKS Cluster.

Please do not forget to replace default values with your AWS services as these values are specific to my AWS account and will give error. You can use default VPC, Subnet and EC2 key pair from your AWS account.

aws cloudformation create-stack --stack-name myClusterStack --template-body file://AWS-EKSClusterTemplate.yml --capabilities CAPABILITY_NAMED_IAM
Enter fullscreen mode Exit fullscreen mode

2. Create EKS Nodes:

Here is the cf template for EKC Nodes creation.

Image description
Image description

Save this file as AWS-EKSNodesTemplate.yml in your local machine and replace default values in Parameters section and run below command to create CloudFormation Stack and EKS Nodes.

aws cloudformation create-stack --stack-name myNodeStack --template-body file://AWS-EKSNodesTemplate.yml --capabilities CAPABILITY_NAMED_IAM
Enter fullscreen mode Exit fullscreen mode

Login to AWS account and check stack status. This process might take sever minutes. Once its complete stack status must show completed as below.

Image description

3. Use kubectl to check nodes in cluster and deploy first docker image.

Run kubectl get nodes command in your terminal, it will show 1 node in ready state.

Image description

If you have not configured kubectl to connect to newly created EKS cluster then run below command.

aws eks update-kubeconfig --name MyWebCluster

Now our environment is ready for deployment. Let's deploy and test nginx webserver using below command.

kubectl run nginx --image=nginx

Image description

Now, the port-forward feature of kubectl simply tunnels the traffic from a specified port at your localhost machine to the specified port on the pod.

Image description

Finally, pod is running and serving at port 8080. You can test application by visiting (http://localhost:8080) in web browser.

Image description

4. Clean Up

Cleaning up all the resources that were created above is crucial; failing to do so will result in significant expenses.

aws cloudformation delete-stack --stack-name myNodeStack
aws cloudformation delete-stack --stack-name myClusterStack

Conclusion:

AWS EKS simplifies managing containerized applications by offering a scalable, secure, and Kubernetes-based platform. If you're looking for agility and a focus on development, EKS lets you offload cluster management to AWS. Consider EKS for your next containerized project!

cloudformation Article's
30 articles in total
Favicon
Thrilled to Announce the Launch of My Book "Mastering Infrastructure as Code with AWS CloudFormation"
Favicon
[Solved] AWS Resource limit exceeded
Favicon
A Comparative Analysis of Terraform and CloudFormation
Favicon
AWS CDK Typescript Simple Project for Cloud Formation of Resources Required for Kubernetes Study
Favicon
Customize VPCs with CloudFormation Conditions
Favicon
AWS CloudFormation: Infrastructure as Code for Efficient Cloud Management
Favicon
Using CloudFormation to deploy a web app with HA
Favicon
Automated Control Rollout in AWS Control Tower
Favicon
Launch an EC2 instance in a custom-made VPC using cloud formation
Favicon
AWS Automatically Accept Transit Gateway Attachments for allowed CIDR and Account pairs
Favicon
AWS CloudFormation Git sync now allows you to review your stack changes via Pull Request (PR)
Favicon
Terraform vs. AWS CloudFormation: A Detailed Comparison
Favicon
Terraform vs CloudFormation: Choosing the Best IaC Tool
Favicon
Automating AWS Cost and Usage Report with CloudFormation
Favicon
Calling All Senior DevOps Trailblazers!
Favicon
Move aws resources from one stack to another cloudformation stack
Favicon
Amazon CloudFormation Custom Resources Best Practices with CDK and Python Examples
Favicon
Domesticate AWS nested stacks in Java: doing the chores Cloudformation doesn't do (w/ code samples)
Favicon
Please stop publishing AWS S3 buckets as static websites! Read here for a secure, fast, and free-ish approach [1st episode]
Favicon
App runner with CloudFormation AWS (json, nodejs, java )
Favicon
Introducing AWS CloudFormation
Favicon
Simple steps to create AWS EKS Cluster and Nodes
Favicon
Deep Dive on Amazon Managed Workflows for Apache Airflow Using CloudFormation
Favicon
Importing CloudFormation Resources to help fix deployments to Production
Favicon
Update Github token in Codepipeline with Cloudformation
Favicon
Integration of Chatbot(Amazon Lex) in a static website (Hosted on S3 and cloud front)
Favicon
AWS CloudFormation - Automating Cloud Infrastructure
Favicon
Creating an AWS Auto Scaling Architecture with a monitoring dashboard
Favicon
Terraform vs. AWS CloudFormation
Favicon
Use AWS StepFunctions for SSM Patching Alerts

Featured ones: