Tech Blog

Technology

How to Get Started With Kubernetes In AWS effortlessly?

By Sai Nandhan5 min read
← Back to blog

Hi there!!! Before diving into the process of creating and setting up a kubernetes cluster, Let’s try to briefly understand what kubernetes is and why it is used.
Brief introduction to kubernetes:
Kubernetes is a container orchestration tool that helps in automating the various steps involved in deployment, Scaling and managing the containerized applications.
In simple terms, it eliminates lot of steps involved in manual process of deployment and makes the whole deployment easier with the ease of scalability and management.
A Kubernetes cluster consists of two types of resources:- Master node (or) Control plane and Worker node. The master node manages the cluster. It coordinates all of the activities in the cluster. Whereas a worker node is a virtual machine like ec2 in which the containerized applications run.
After understanding the architecture of kubernetes, one wants to get their hands-on with it. But starting it up might be challenging for beginners especially when they have chosen to start in cloud platform like aws. Here I will explain how to spin up a functional cluster in aws using an aws service called as EKS.

What is EKS?
Amazon Elastic kubernetes cluster(EKS) is a managed kubernetes service provided by AWS in which master node (or)Control plane is completely managed by AWS itself.
Creation of eks cluster in aws can be done either by using aws management console or using a command tool called as ‘eksctl‘.
Creating eks cluster using the aws management console is a bit difficult process as it requires the following things to be already existing such as 2 IAM roles with specific permissions, a vpc , subnets with specific tags, few cloud formation stacks, dedicated security groups, launch templates for configuring the instances etc.
For beginners who don’t have sound knowledge in aws, To follow all these steps would be a tedious job. Even if a small thing goes wrong, lot of rework has to be done and it becomes very difficult to troubleshoot. So, it’s better to somehow easily get started with setting up a functional cluster and then understand the complete process and steps behind it.
The solution is ‘eksctl’. It is a command line tool that is used to create and manage Kubernetes clusters on Amazon EKS. 
There are few prerequisites before creating a cluster using eksctl and they are as follows.

Prerequisites:
1)kubectl – A command line tool for running the commands against kubernetes clusters. 
2)eksctl – A command line tool for creating, deleting and working with EKS clusters that automates all the manual steps involved in cluster creation process.
3)The following IAM permissions are needed to the user who is creating fully functional cluster.
1)AmazonEC2FullAccess (AWS Managed Policy)
2)AWSCloudFormationFullAccess (AWS Managed Policy)
3)EksAllAccess
4)IamLimitedAccess

How to use eksctl?
To create a basic cluster, run the following command in command prompt.
eksctl create cluster –name=devcluster –nodes=3
With the above command, you can create a functional cluster named ‘devcluster’ with 3 nodes, a new dedicated vpc and new subnets. However, If you want to give more details while creating cluster such as instance type, volume type, An existing vpc and subnets, ssh access, key pair etc. It is better to have a configuration file rather than giving all these information in a single command.
You can use a yaml file with kind:Clusterconfig which can store these details.
Example 1:
If you want to create a cluster with 2 managed node groups with different instance types. Then you can use a config file as given below.
cluster.yaml:-

apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: firstcluster
region: us-east-1
managednodeGroups:
– name: ng-1
instanceType: t3.small
desiredCapacity: 2
volumeSize: 80
volumeType: standard
– name: ng-2
instanceType: t3.medium
desiredCapacity: 2
volumeSize: 100
availabilityZones: [‘us-east-1a’, ‘us-east-1b’, ‘us-east-1c’, ‘us-east-1d’]

Example 2:
Sometimes, you want to create a cluster in the existing vpc and subnets rather than using a new one. You can create it using the config as given below:
cluster.yaml:-

apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: mycluster3
region: us-east-1
version: “1.18”
vpc:
id: <vpc_id>
subnets:
private:
us-east-1a:
id: “<subnet-id>”
us-east-1b:
id: “<subnet-id>”
us-east-1c:
id: “<subnet-id>”
managedNodeGroups:
– name: node-group1
instanceType: t3a.small
desiredCapacity: 2
minSize: 1
maxSize: 3
volumeSize: 80
volumeType: standard

This file creates cluster by making use of existing vpc and creates the worker nodes in the given private subnets. If you want your worker nodes to be in a public subnet, You can mention ‘public’ instead of ‘private’. Minimum of 2 availability zones should be mentioned while creating a cluster. In metadata, we give the cluster name, region and kubernetes version. If we don’t mention values for few fields, default values are considered and cluster will be created accordingly.
The command used to create the cluster is “eksctl create -f cluster.yaml“.
eksctl creates the cluster with all the required resources such as security groups, cloud formation templates, node groups, autoscaling groups etc.

Conclusion:
‘eksctl‘ tool creates a fully functional eks cluster with all the required resources in aws, thus reducing the complexity in creating lot of aws resources manually. It is simple and easy tool to be used. However, creating the cluster and the resources manually gives more knowledge and understanding on how the kubernetes architecture works and the workflow of it.

References:
1)For more information on cluster creation using eksctl, refer https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html
2)For information on creating cluster using aws management console, refer https://docs.aws.amazon.com/eks/latest/userguide/getting-started-console.html

Keep reading

You may be interested in

Browse all articles →
Using SCEP Certificates with Okta and SureMDM for Zero Trust Security
August 5, 20257 min read

Using SCEP Certificates with Okta and SureMDM for Zero Trust Security

For businesses embracing zero-trust principles, secure certificate-based authentication isn’t just nice to have—it’s a necessity. With Okta as your Identity Provider (IdP) and SureMDM as your unified endpoint management solution, you can now seamlessly distribute and manage device certificates using Simple Certificate Enrollment Protocol (SCEP). This blog will guide you through: Why Use SCEP with […]

By Sunny KumarRead More →
How to Use mc CLI for Bucket Management and Credential Setup
June 12, 20252 min read

How to Use mc CLI for Bucket Management and Credential Setup

MinIO client The MinIO Client, commonly known as mc, is a command-line tool used to interact with MinIO, a high-performance object storage system. The mc client allows users to manage buckets and objects on the MinIO storage service.

By Malkeet SinghRead More →
How to Setup Passwordless SSH Login for ADE
March 18, 20253 min read

How to Setup Passwordless SSH Login for ADE

To set up a passwordless SSH login in Linux all you need to do is to generate a public authentication key and append it to the remote hosts ~/.ssh/authorized_keys file. The following steps will describe the process for configuring passwordless SSH login: 1. Check for existing SSH key pair Before generating a new SSH key […]

By Mohan Kumar KMRead More →