Setting Up and Managing an Amazon EKS Cluster on Ubuntu: A Comprehensive Guide

Subham Pradhan
4 min read2 days ago

--

Introduction:

Deploying applications on Kubernetes offers scalability and flexibility, and Amazon EKS (Elastic Kubernetes Service) simplifies Kubernetes management in the AWS cloud environment. This guide provides a step-by-step approach to setting up an Amazon EKS cluster on Ubuntu. From installing necessary tools to configuring IAM roles and creating the cluster, you’ll learn how to efficiently manage your Kubernetes infrastructure using best practices.

Steps to Setting Up EKS Cluster:

Create an EC2 IAM Role for EKS cluster Access
Attach Policies to that Role
Update IAM role to the EC2 instance

Install AWS CLI:

sudo apt update
sudo apt install -y unzip curl
sudo apt install -y unzip curl
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
aws --version

Install Docker:

apt-get install docker.io 
usermod -aG docker $USER
newgrp docker
sudo chmod 777 /var/run/docker.sock
docker --version
sudo apt update
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version --client

Installing eksctl:

sudo curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | sudo tar xz -C /usr/local/bin
eksctl version

Create Kubernetes Cluster on Amazon EKS:

eksctl create cluster --name my-new-cluster --region us-east-1 --node-type t2.medium --nodes 3 --nodes-min 1 --nodes-max 4 --managed --zones us-east-1a,us-east-1b,us-east-1c
eksctl get clusters --region us-east-1
kubectl get nodes
kubectl get pods
kubectl get svc
aws eks update-kubeconfig --name my-new-cluster --region us-east-1

This command is used to update the Kubernetes configuration (kubeconfig) file for an Amazon Elastic Kubernetes Service (EKS) cluster named “my-new-cluster” in the “us-east-1” region, allowing you to interact with the cluster using kubectl.

Delete the Kubernetes resources within the cluster:

kubectl delete deployment my-app kubectl delete service my-app

You can also delete all resources in the default namespace with:

kubectl delete all --all

Delete the EKS cluster using eksctl:

eksctl delete cluster --name my-new-cluster --region us-east-1
aws cloudformation delete-stack — stack-name eksctl-my-cluster-cluster — region us-east-1

Conclusion:

In conclusion, setting up an Amazon EKS cluster on Ubuntu involves several crucial steps, from preparing IAM roles and installing necessary tools like AWS CLI, Docker, kubectl, eksctl, to creating and managing your Kubernetes environment. By following this guide, you've gained the foundational knowledge to deploy and scale applications on Amazon EKS, leveraging the power of Kubernetes in a seamless AWS-managed environment. Embrace the scalability and reliability that Amazon EKS offers, and continue exploring advanced Kubernetes features to optimize your cloud infrastructure further.

--

--

Subham Pradhan

DevOps Engineer | CI/CD | K8S | Docker | Jenkins | Ansible | Git | Terraform | ArgoCD |Helm|Prometheus|Grafana|SonarQube|Trivy|Data Engineer | Azure |DevSecOps|