Overview
Amazon Elastic Kubernetes Service (Amazon EKS) is a managed service that you can use to run Kubernetes on AWS without needing to install, operate, and maintain your own Kubernetes control plane or nodes. Kubernetes is an open-source system for automating the deployment, scaling, and management of containerized applications. In this post, I will be taking you through the steps to create a Kubernetes cluster on Amazon EKS.
Install AWS CLI, Kubectl
In this section, Install the required CLI’s in your local machine which will be used to connect to EKS clusters once deployed.
- Download and install the aws command line tool at its install page. It will help you create and communicate with EKS cluster. Once cli is successfully installed, configure the same using below steps:
- Install kubectl (reads kube control), it is a tool for controlling Kubernetes clusters in general.
Create Cluster Service Role
- Login to AWS management console > IAM > Access Management > Roles > Create Role
- Select AWS Service
- Under select a service to view its use cases , select EKS
- Select your use case > EKS Cluster and click on Next Permissions
- Leave AmazonEKSClusterPolicy to default and click on Next: Tags
- Add Tag (Optional) and click on Next: Review
- Give a name and click on Create role.
Create Node IAM Role
- Login to AWS management console > IAM > Access Management > Roles > Create Role
- Select AWS Service > EC2 and click on Next:Permissions
- Under Attach Permissions, select below policies and click on Next:Tags
-
-
- AmazonEKSWorkerNodePolicy
- AmazonEC2ContainerRegistryReadOnly
- AmazonEKS_CNI_Policy
-
-
- Tags (Optional) and click Next: Review
- Give a Name and Create role.
Create EKS Cluster
- Login to AWS management console > Elastic Kubernetes Service > Add Cluster > Create
- Click Next
- Under Specify networking section, leave the values to default and click Next
- Under Configure logging section, leave the values to default and click Next
- Click Create
Cluster creation should take a while to complete, upon successful completion, status should show Active
Create Node group in EKS cluster
- Click on newly created EKS cluster > Configuration > Compute > Add Node group
- Name: Give a Name
- Node IAM Role: Select the node role created in previous step
Note: There are various fields which can be used like launch templates, Labels, Taints etc .. In this demo, I sticked to default values.
- Next
- Node group compute configuration: For this demo, I have used t3.xlarge and 30 GiB disk size. You can use a smaller instance type in your environment which is not a problem.
- Node Group scaling configuration: I preferred to choose min and max size as 2, you can certainly have more nodes based on requirement.
- Node Group update configuration: Leave as default and click Next
- Node Group network configuration: Leave as default (To be able to take ssh to worker nodes, enable the option Configure SSH access to nodes) and click Next
- Review and Create
Node creation takes 5-10 mins based on the region selected, upon successful completion, status should turn Active.
Create Amazon ECR(Optional):
In this demo, I will be using ECR (Elastic Container Registry) to store the images. You can deploy the application with images located in any registry of your choice.
- Login to AWS Management console > search for Elastic Container Registry > Create a repository (Get Started) > Enter name > Create repository
- Click on Repo name > View push commands to get the authentication token and authenticate Docker client to your registry.
- Check the uploaded images in repository.
Deploy Application
- Access the load balancer from your browser: