Call us
Digital

Kubernetes on AWS: A Step-by-Step Guide to Setting Up EKS

Discover how to deploy Kubernetes on AWS using EKS. Follow this step-by-step guide to set up and manage a scalable, secure container environment. Read the guide.


5 min readCpluz

Kubernetes on AWS: A Step-by-Step Guide to Setting Up EKS

As businesses continue to scale and their technological requirements evolve, managing infrastructure and applications efficiently has become increasingly complex. Kubernetes, an open-source container orchestration system, helps streamline and automate the process of deploying, scaling, and managing applications. AWS Elastic Container Service for Kubernetes (EKS) provides a managed service for running Kubernetes on AWS without the burden of managing the underlying infrastructure. In this comprehensive guide, we'll walk you through a step-by-step process for setting up EKS on AWS, empowering you to efficiently manage and scale your applications.

What is Kubernetes and Why EKS?

Think of Kubernetes as the "DNA" of your application deployment, defining the precise conditions and settings needed to bring your code to life. Kubernetes provides a robust framework for deploying, scaling, and managing applications. By automating many routine tasks, it allows you to focus on developing your application rather than worrying about the underlying infrastructure. EKS, as a managed service, eliminates the need for you to manage the control plane, freeing up resources to focus on your application development.

A Strategic Cpluz Perspective: Why Choose EKS over Self-Managed Kubernetes?

When deciding between self-managed Kubernetes and EKS, consider the following key points: EKS offers a cost-effective solution for running Kubernetes on AWS, leveraging the vast ecosystem of AWS services and the expertise of the AWS team for maintenance and updates. This allows you to focus on the core aspects of your business rather than the intricacies of Kubernetes management.

Prerequisites and Setting Up AWS Account

To begin with EKS, you need an AWS account. If you already have one, ensure you have the necessary permissions for creating and managing resources. If not, sign up for a free AWS account at aws.amazon.com.

  • Create an AWS IAM user with the necessary permissions to create EKS clusters.
  • Install the AWS CLI on your machine. You can download it from aws.amazon.com/cli/.
  • Configure your AWS CLI with the necessary credentials. You can do this by running aws configure in your terminal.

Step 1: Create a VPC and Subnets

Create a VPC and at least two subnets in different Availability Zones (AZs) in the AWS Management Console. This ensures high availability and scalability for your EKS cluster.

  • In the AWS Management Console, navigate to VPC and click on "Create VPC".
  • Choose the IPv4 CIDR block for your VPC. For example, you can choose 10.0.0.0/16.
  • Create at least two subnets in different AZs. For example, 10.0.101.0/20 in one AZ and 10.0.102.0/20 in another AZ.

Step 2: Create a Cluster Role and Cluster Role Binding

Create a cluster role and a cluster role binding to define the permissions for your EKS cluster. You can do this using the AWS CLI or the AWS Management Console.

  • Create a file named eks-cluster-role.yaml with the following content:

apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: ebs-csi-controller-role rules:

  • apiGroups:

      resources:

    • nodes
    • nodes/proxy verbs:
    • get
    • watch
    • list
  • apiGroups:

    • storage.k8s.io resources:
    • storageclasses verbs:
    • get
  • apiGroups:

    • storage.k8s.io resources:
    • csistoragecapacities verbs:
    • get
  • apiGroups:

    • storage.k8s.io resources:
    • csistoragecapacities/finalizers verbs:
    • update
  • Create a cluster role binding using the eks-cluster-role.yaml file:

aws eks update-cluster-iam-role --cluster-name --role-name

Step 3: Launch an EKS Cluster

Launch an EKS cluster using the AWS CLI or the AWS Management Console. Ensure you have the necessary VPC, subnets, and cluster role defined.

  • Run the following command in your terminal to create an EKS cluster:

aws eks create-cluster --name --role-arn --resources-vpc-config ,

Step 4: Install the EKSctl

Install the EKSctl, a simple, unified control plane for running Kubernetes applications on AWS. You can install it using the following command:

  • Run the following command to install EKSctl:

curl --silent --location "https://github.com/aws/eks-cluster/eksctl/releases/download/v0.78-0/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp sudo mv /tmp/eksctl /usr/local/bin/ sudo chmod 755 /usr/local/bin/eksctl eksctl version

Step 5: Create a Node Group

Create a node group for your EKS cluster using EKSctl. This will add worker nodes to your cluster and enable you to run your applications.

  • Run the following command to create a node group:

eksctl create nodegroup --cluster --name --node-type --num-of-nodes

Step 6: Verify Your EKS Cluster

Verify that your EKS cluster is running successfully. You can do this by checking the status of your nodes and pods.

  • Run the following command to check the status of your nodes:

kubectl get nodes

  • Run the following command to check the status of your pods:

kubectl get pods --all-namespaces

FAQs

Q: What is EKS and how does it differ from self-managed Kubernetes?

A: EKS is a managed service provided by AWS for running Kubernetes on AWS without the need for managing the underlying infrastructure. It eliminates the burden of managing the control plane and provides a cost-effective solution for running Kubernetes on AWS.

Q: How do I create a VPC and subnets for my EKS cluster?

A: You can create a VPC and subnets using the AWS Management Console. Ensure you create at least two subnets in different Availability Zones (AZs) for high availability and scalability.

Q: What is a cluster role and cluster role binding, and how do I create them?

A: A cluster role defines the permissions for your EKS cluster, while a cluster role binding assigns those permissions to a user or a service account. You can create a cluster role and a cluster role binding using the AWS CLI or the AWS Management Console.

About the Author

Rajendaran is the Lead Digital Strategist at Cpluz, where he helps businesses navigate the complex world of digital transformation and build seamless user experiences. With a deep understanding of the intersection of technology and business, Rajendaran is passionate about demystifying design and technology for businesses, making it easier for them to achieve their goals. In his free time, Rajendaran enjoys learning about the latest advancements in cloud computing and exploring new ways to apply them in real-world scenarios.


Ready to Elevate Your Brand?

At Cpluz, we've been building meaningful connections between brands and consumers through innovative design and technology since 1993. Whether you need a compelling logo, a high-performance website, or a robust digital marketing strategy, our team is here to help you achieve your business goals.

Let's discuss how we can bring your vision to life. Contact the Cpluz team today for a consultation.

Email: info@cpluz.com
Visit our website: cpluz.com