Learn AWS EKS: Simple Guide for Beginners to Kubernetes on AWS

AnasAnas
5 min read

Amazon Web Services Elastic Kubernetes Service (EKS) is a managed container service that allows you to run Kubernetes on AWS without having to manage the underlying infrastructure. With EKS, you can focus on deploying and managing your containerized applications, while AWS handles the heavy lifting of managing the control plane.

What is AWS EKS?

AWS EKS is a managed service that provides a scalable, secure, and highly available way to deploy, manage, and scale containerized applications. With EKS, you can create and manage Kubernetes clusters, deploy and manage containerized applications, and integrate with other AWS services such as Amazon Elastic Container Registry (ECR), Amazon Elastic Load Balancer (ELB), and Amazon CloudWatch.

Key Features of AWS EKS

  • Managed Control Plane: With EKS, AWS manages the control plane components, such as the API server, scheduler, and controller manager. This means you can focus on deploying and managing your applications, without worrying about the underlying infrastructure.

  • Scalability: EKS allows you to scale your clusters up or down as needed, and supports both stateless and stateful applications.

  • Security: EKS provides network policies, secret management, and identity and access management (IAM) integration to ensure secure access to cluster resources.

Integration with AWS Services: EKS integrates tightly with other AWS services, providing a comprehensive container management solution.

Benefits of Using AWS EKS

  • Simplified Kubernetes Management: With EKS, you can focus on deploying and managing your applications, without worrying about the underlying infrastructure.

  • Improved Scalability: EKS provides scalable and highly available clusters, allowing you to handle large workloads and sudden spikes in traffic.

  • Enhanced Security: EKS provides robust security features, such as network policies and secret management, to ensure secure access to cluster resources.

Tight Integration with AWS Services: EKS integrates tightly with other AWS services, providing a comprehensive container management solution.

some basics before dive into eks:

cloud formation service that create and destroy the no of resources.

kubectl - control the k8s cluster

EKSCTL- control EKS cluster - create delete etc

containers are running in the pod

namespace - gives us isolation for other application resources which are running in same k8s cluster

everything in k8s done in manifest file

kubectl is a tool to communicate server to cluster

to make cluster on eks i need cloud formation which make master worker node VPC alb to make cloud formation i need eksctl it use cli

How to make EKS cluster

  1. create aws account

  2. install aws cli

    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. Create IAM user:

    go to aws iam console

    create a new iam user name eks-admin

    attach the “AdministratorAccess” Policy to user

    Create Security credentials:

    after creating user generate an access key and secret access key for their user

  4. install kubectl

     curl -o kubectl https://amazon-eks.s3.us-east-1.amazonaws.com/1.19.6/2021-01-05/bin/linux/amd64/kubectl
     chmod +x ./kubectl
     sudo mv ./kubectl /usr/local/bin
     kubectl version --short --client
    

    install eksctl:

     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 EKS cluster:

  • Create EKS Cluster

      eksctl create cluster --name=my-cluster \
                            --region=us-east-1 \
                            --version=1.30 \
                            --without-nodegroup
    

Associate IAM OIDC Provider

eksctl utils associate-iam-oidc-provider \
    --region us-east-1 \
    --cluster my-cluster \
    --approve

  • Create Nodegroup

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

    NOTE: use key and region as per u created in your account

Update Kubectl Context

    aws eks update-kubeconfig --region us-east-1 --name my-cluster

kubectl get pods

kubectl get namespace

Delete

Using manifest file

kubectl get pods -n nginx

for desired state used DEPLOYMENT - to create new replica set and adopt all their resources with new deployment.

we can also validate this

kubectl get pods -n nginx

use decribe for full information:

now if i try to acces by this link, i’m not able to access this deployment or nginx because our service port is missing

if i change 5 instead of 10

now create service file

vim service.yml

if i try to acces using this , let’s see

if i change in deployment and service file for phontiqe

now again change in my manifest file for notes app

kubectl apply -f deployment.yml

kubectl apply -f service,yml

kubectl get service -n nginx

access using link

to delete

TO delete EKS cluster

eksctl delete cluster --name=my-cluster --region=us-east-1

Conclusion

In this blog , we've covered the basics of AWS EKS, its features, and benefits. We've also walked through the steps to create an EKS cluster, including creating an IAM user, installing kubectl and eksctl, and configuring the cluster. Additionally, we've demonstrated how to deploy a simple application using a manifest file and access it using a service. Finally, we've shown how to delete the EKS cluster when it's no longer needed.

If you found this tutorial helpful, please follow me for more AWS, cloud, and DevOps content.

0
Subscribe to my newsletter

Read articles from Anas directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Anas
Anas