Amazon Elastic Kubernetes Service (EKS) simplifies the deployment of Kubernetes on AWS, eliminating the complexities of managing the control plane. Whether you’re just starting with Kubernetes or transitioning to a managed service, EKS provides a robust, scalable platform for running containerized applications in the cloud.

In this guide, we’ll walk you through setting up your first Amazon EKS cluster, covering essential topics such as prerequisites, tool installation, control plane setup, worker nodes, and cleanup.

Introduction to Amazon EKS: Simplifying Kubernetes Deployment

Amazon EKS is a fully managed Kubernetes service designed to help you deploy, manage, and scale containerized applications using Kubernetes. With EKS, AWS manages the Kubernetes control plane, enabling you to focus on the worker nodes and application workloads. EKS integrates seamlessly with other AWS services, providing a robust ecosystem to run Kubernetes workloads in production.

Prerequisites for Setting Up an EKS Cluster

Before diving into the setup, ensure you have the following prerequisites in place:

  1. AWS Account: You’ll need an AWS account with administrative privileges to create the necessary resources.
  2. IAM Permissions: Ensure your user or role has sufficient permissions to create EKS clusters, IAM roles, VPCs, and associated resources.
  3. AWS CLI: Install and configure the AWS Command Line Interface (CLI) with proper access credentials.
  4. kubectl: The Kubernetes command-line tool to interact with the EKS cluster.
  5. eksctl: A simple CLI tool specifically for creating and managing EKS clusters.

Installing Necessary Command Line Tools for EKS Management

You’ll need a few command-line tools to manage your EKS cluster:

  1. AWS CLI:

To install, use:
curl “https://awscli.amazonaws.com/AWSCLIV2.pkg” -o “AWSCLIV2.pkg”

sudo installer -pkg AWSCLIV2.pkg -target /

Then configure it:
aws configure

  1. kubectl:

Install kubectl using:
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

  1. eksctl:

To install eksctl, use:
curl -LO “https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz”

tar -xzf eksctl_$(uname -s)_amd64.tar.gz -C /usr/local/bin

Creating the EKS Control Plane

The control plane is the core of your Kubernetes cluster, managing nodes, API requests, and workloads.

Create the EKS cluster with eksctl:
eksctl create cluster \

–name my-first-cluster \

–version 1.25 \

–region us-west-2 \

–nodegroup-name standard-workers \

–node-type t3.medium \

–nodes 3 \

–nodes-min 1 \

–nodes-max 4 \

–managed

  1. This command creates a control plane, configures the networking, and launches the worker nodes. It typically takes a few minutes to complete.

After the cluster is created, configure your kubectl context:
aws eks –region us-west-2 update-kubeconfig –name my-first-cluster

Configuring Worker Nodes and Node Groups

Amazon EKS utilizes worker nodes (EC2 instances) that run Kubernetes pods. These nodes can be part of one or more node groups. You can manually create worker nodes or rely on eksctl to manage them.

  1. Node Groups:
    • When using the eksctl command above, a managed node group is automatically created. You can manage the node group’s capacity with scaling policies that dynamically adjust the number of nodes based on your cluster’s load.
  2. Scaling Node Groups:

To scale your node group manually:
eksctl scale nodegroup –cluster=my-first-cluster –nodes=5 –name=standard-workers

Testing and Verifying Your EKS Cluster

Once your EKS cluster is set up, verifying its functionality is essential.

  1. Check Cluster Nodes:

Use kubectl to verify that the nodes are connected to the cluster:
kubectl get nodes

  1. Deploy a Test Application:

Deploy a simple Nginx deployment to confirm your cluster is operational:
kubectl create deployment nginx –image=nginx

kubectl expose deployment nginx –port=80 –type=LoadBalancer

Get the external IP of the Nginx service:
kubectl get svc nginx

Cleaning Up: Deleting EKS Resources

Once you’ve completed your EKS cluster, cleaning up the resources is essential to avoid unnecessary charges.

  1. Delete the Cluster:

Use eksctl to delete the entire cluster:
eksctl delete cluster –name my-first-cluster

  1. Delete Associated Resources:
    • Verify that all the resources (VPCs, Security Groups, Load Balancers) created by the EKS cluster are cleaned up. AWS typically removes these when the cluster is deleted, but some might require manual intervention.

Conclusion

Congratulations! You’ve successfully set up your first Amazon EKS cluster, deployed a test application, and verified its functionality. With this robust foundation, you can now scale your applications, integrate other AWS services, and fully embrace the power of Kubernetes in the cloud.

References

Create an Amazon EKS cluster

Get started with Amazon EKS