Understanding EKS and How to Set Up an EKS Cluster

 Raees Qazi | DevOps Engineer | Learner | Mentor | Creator | Briller Technologies


Kubernetes Basics

  • Scheduler: Decides which Docker container runs on which pod within a worker node.
  • kubectl: A command-line tool to control and manage the Kubernetes (K8s) cluster.
  • eksctl: A tool specifically designed to manage Amazon EKS (Elastic Kubernetes Service) environments.

Key AWS Components

  • ALB (Application Load Balancer): Manages incoming traffic and directs it to available worker nodes. If all worker nodes are busy, the master node will create a new worker node.
  • VPC (Virtual Private Cloud): The environment where both worker nodes and the master node reside.
  • IAM (Identity and Access Management): Controls access and permissions for users and resources.
  • CF (CloudFormation): Automates the creation and deletion of AWS resources, including EKS clusters.

How AWS Services Work Together

The process of setting up an EKS cluster follows this hierarchy:

  1. EC2 (Instance where tools are installed)
  2. EKSCTL (A CLI tool to manage EKS)
  3. CloudFormation (Handles resource provisioning)
  4. EKS Cluster (Managed Kubernetes cluster)

We install AWS CLI and EKSCTL on an EC2 instance and then use eksctl to instruct CloudFormation to create an EKS cluster.

Setting Up an EKS Cluster Using eksctl

Pre-requisites:

  1. IAM User with access keys and secret keys.
  2. AWS CLI Installed and Configured:
  • curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
  • sudo apt install unzip
  • unzip awscliv2.zip
  • sudo ./aws/install
  • aws configure

3. Install kubectl (for managing Kubernetes clusters):

4. Install eksctl (for managing EKS clusters):

  • 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

Steps to Create an EKS Cluster

  1. Create the EKS Cluster:
  • eksctl create cluster --name=my-cluster \
  • --region=us-west-2 \
  • --version=1.30 \
  • --without-nodegroup

2. Associate IAM OIDC Provider:

  • eksctl utils associate-iam-oidc-provider \
  • --region us-west-2 \
  • --cluster my-cluster \
  • --approve

3. Create a Node Group:

  • eksctl create nodegroup --cluster=my-cluster \
  • --region=us-west-2 \
  • --name=my-cluster \
  • --node-type=t2.medium \
  • --nodes=2 \
  • --nodes-min=2 \
  • --nodes-max=2 \
  • --node-volume-size=29 \
  • --ssh-access \
  • --ssh-public-key=eks-nodegroup-key

Note: Ensure that the SSH public key eks-nodegroup-key is available in your AWS account.

4. Update kubectl Context:

  • aws eks update-kubeconfig
  • --region us-west-2
  • --name my-cluster

5. Delete the EKS Cluster (if needed):

  • eksctl delete cluster --name=my-cluster
  • --region=us-west-2

This guide simplifies setting up an EKS cluster step by step. By following these steps, you can deploy and manage Kubernetes clusters efficiently on AWS.

Comments

Popular posts from this blog

📘 Understanding Prometheus in a Simple Way-Part 3 (For DevOps Beginners)

Grafana Setup & Dashboard Creation (Part-5)— Explained by Raees Yaqoob Qazi

My First Python Program: A Simple Calculator