Introduction
I have written few posts on kubernetes and how to start with it. Today, we will see how to start with EKS, a managed kubernetes service from AWS. In this post, we will cover the very basics e.g. EKS introduction, what necessary tools need to be installed, we will also create a cluster and will see how to delete the cluster as well. In later posts on EKS, we will cover application deployments and other topics.
I am assuming you have basics understanding of AWS and Kubernetes in general. If you are new to these topics, I will suggest to read some earlier posts I have written on these topics. There are other many resources available online to give you the base information.
Amazon EKS is a managed service that makes it easy for you to use Kubernetes on AWS without needing to install and operate your own Kubernetes control plane. AWS create Master nodes and necessary software for cluster and we only create the worker nodes. This service also takes care of scaling (when needed) and doing backups as well. This way, we can focus more on deploying applications in kubernetes rather than worrying about much of the infrastructure.
Starting with EKS
Let’s say we want to deploy an application to EKS. First thing we need to do is to create a cluster. But before we start with this, we need to do some steps as a pre-requisite (setup) and then we will be able to create the cluster and worker nodes. Following list typical initial steps to create and start with a cluster.
- Setup
- Create AWS Account (e.g. free-tier)
- Create a VPC
- Create IAM Role with necessary permissions.
- Create Cluster
- Create Master Nodes (using IAM Role).
- Choose some basic info e.g. cluster name, K8 version, region, VPC, security for the cluster etc.
- We can create cluster either using AWS web-console or AWS CLI.
- Create Worker Nodes
- Create worker nodes and connect to cluster.
- Worker nodes will be some EC2 instances.
- We create these worker nodes as a Node Group (group of nodes) and not as separate EC2 instances. When you use a NodeGroup, you can choose a cluster, this node-group will join to.
- We also can select instance-type, security and other configurations for EC2 instances.
- For auto-scaling purposes, we can define the max and min number of nodes as well.
- Connect to Cluster from Local Machine
- Once we have cluster setup, we can connect to it with local machine and use kubectl CLI for various purposes e.g. deploying the application.
Now, this seems like a lot of work, if we do all that manually this surely will require some effort. Good news is that there is command line utility eksctl which simplifies the above mentioned process a lot.
So instead of creating the cluster, choosing various settings and connecting various pieces together manually, we can use one simple command to setup all that:
eksctl create cluster
Of course this is over simplification, the above mentioned command will create cluster with default settings, but we can also override parts where we want our custom changes over defaults.
Setup the Environment
Assuming you already have an AWS account setup, we will now see what tools needed to be installed.
For this part, you need to install following tools on your machine:
- aws cli
- kubectl
- eksctl
- aws-iam-authenticator
I have already covered installation of aws cli and kubectl in previous posts, please refer to those for the information.
One thing I want to say that its good idea to always refer to official online documentation for these tools and commands.
install eksctl
To install eksctl utility, if it is not already installed on your machine. Based on your OS, the setup will be different. You can find setup information as per your need from this link on AWS website.
The AWS documentation shows how to install it using chocolatey. I will however show you how to setup without chocolatey, kind of manual way.
First, we can download the eksctl software as zip file from the releases page on github. You will see list of releases and you can download zip file as shown below:
Once downloaded, unzip it then copy it to C:\Program Files as shown below:
Next, lets add the folder path to Environment Variables (System-> PATH) as shown below:
To test, open a Powershell window and execute following command:
eksctl version
and if utility is setup properly, you will see an output like below:
install aws-iam-authenticator
Amazon EKS uses IAM to provide authentication to your Kubernetes cluster through the AWS IAM authenticator for Kubernetes.
This is what we will use to pass the necessary information through kubectl, so it will be able to request the account resources it’ll need.
You can install it on your machine following steps on the official document here.
However, for windows, I will show how to setup it in manual way:
use the curl command using powershell to download the exe as shown below:
curl -o aws-iam-authenticator.exe https://amazon-eks.s3.us-west-2.amazonaws.com/1.21.2/2021-07-05/bin/windows/amd64/aws-iam-authenticator.exe
here is the exe file downloaded:
Next, I copied the downloaded file to a folder c:\bin and added this folder path to environment variable as we did earlier.
to test the setup, open a PowerShell window and execute following command:
aws-iam-authenticator version
With that, we are all setup and ready to roll.
Create an EKS Cluster
Lets start by checking if we have already any cluster by using following command:
eksctl get cluster
and following output shows that we do not have any cluster created yet:
Lets create an EKS Cluster by executing following command in PowerShell:
eksctl create cluster `
--name ab-cluster `
--nodegroup-name standard-workers `
--node-type t3.medium
Behind the scene a cloud formation stack will be created as shown below:
It will take few minutes to complete the progress and we will have following output on console:
the create cluster command is completed and we can now check some information about our cluster using following commands:
eksctl get cluster
kubectl get nodes
here is the output:
and we can also verify the same from the web console:
create cluster command also created a VPC, subnets, security groups and all other needed infrastructure for this cluster.
I will now delete this cluster as I am not going to use it for now and this way I will not be charged for this cluster. You can delete the cluster using following command:
eksctl delete cluster --name ab-cluster
Here is the command output:
and after couple of minutes, cluster will be deleted and you can confirm it using the commands mentioned above or using the AWS Web Console.
Summary
In this post, we learned that EKS is a managed kubernetes service and it manages a lot of the infrastructure work for us behind the scenes. we also learned that eksctl tool help us to use simple command to manage EKS and we created a very simple cluster quickly and then at the end learned that we can delete the cluster and corresponding infrastructure easily using eksctl delete command.
Let me know if you have some questions or comments. Till next time, Happy Coding.
Discover more from Hex Quote
Subscribe to get the latest posts sent to your email.
1 thought on “Elastic Kubernetes Service (EKS) – Getting Started”
Comments are closed.