AWS Workshops DIY — EKS Workshop — 2. Let’s Cluster with ‘eksctl’
Chapter 2— Getting EKS cluster up, running, and ready in 3 steps!

A good place to start after going through the AWS Workshops DIY — EKS Workshop — 1. Introduction and Scope Review chapter is to familiarize with the Introduction page below. It shouldn’t take more than a few minutes to read, plus watching the video is helpful to catch up on the basics of EKS design and workings. As a side tip, if you have the Video Speed Controller extension installed, speed up the video to save time as always.
Then we’ll jump straight to the In Your AWS Account setup page and dive into hands-on action. This whole chapter can be easily wrapped up in 3 steps, 4 including the cleanup step, ending with a fully functional EKS cluster created using the eksctl
tool, ready to host applications and workloads in the future.
NOTE: For visual screenshots throughout the hands-on activities, please refer to the workshop pages since they’re well represented and logically laid out. I am going to focus on the commands to conserve space and avoid redundancy.
STEP 1— Development IDE/Terminal Setup
Until this workshop, I’ve always done my work in my dedicated EC2 development server without using the CloudShell terminal and Cloud9 IDE. Through this workshop’s learnings, I am using them more than before as they do provide an additional level of convenience. For this workshop, I am not going to deviate too much from the commands and the presentation format, unless necessary. It’s best to stay at parity and keep everyone on the same page while learning.
# NOTE:
# You can copy/paste this whole block of code into the terminal prompt
# including the comments. Or choose to execute one by one or multiple.
# As long as the context of the terminal doesn't change (CloudShell vs. Cloud9)
# Ref: https://www.eksworkshop.com/docs/introduction/setup/your-account
# Open cloudshell on browser tab
# URL: https://console.aws.amazon.com/cloudshell/home
# Make sure to stay in the right region as appropriate (mine is us-east-1)
# Fire the Cloud9 IDE creation cloudformation command
# [cloudshell-user@ip-10-140-113-140 ~]$
wget -q https://raw.githubusercontent.com/aws-samples/eks-workshop-v2/stable/lab/cfn/eks-workshop-ide-cfn.yaml -O eks-workshop-ide-cfn.yaml
aws cloudformation deploy --stack-name eks-workshop-ide \
--template-file ./eks-workshop-ide-cfn.yaml \
--parameter-overrides RepositoryRef=stable \
--capabilities CAPABILITY_NAMED_IAM
# After a few minutes, after successful eks-workshop-ide stack creation
# Open the Cloud9 IDE, from console (see image below) or with URL below
aws cloudformation describe-stacks --stack-name eks-workshop-ide \
--query 'Stacks[0].Outputs[?OutputKey==`Cloud9Url`].OutputValue' \
--output text
# Finally open the Cloud9 IDE and test the terminal is ready for next steps
# cloud_user:~/environment $
aws sts get-caller-identity

STEP 2— Building Cluster using eksctl
This workshop features three ways to create a cluster, eksctl, Terraform, and CDK, of which the first one is ready and battle-tested. I’ll attempt the terraform way in a chapter of its own and CDK when they’re available. I agree with the workshop page assessment that eksctl
indeed is the easiest and recommended way to get started.
As I’ve mentioned below, sometimes we do have to change the code and scripts to suit our own AWS operating environment, constraints, and parameter customization. In the following code, I’ve replaced m5.large
with t3.medium
to save cost and have defined a few environment variables to control the corresponding parameters outside of the YAML script.
# Build Cluster Using eksctl
# https://www.eksworkshop.com/docs/introduction/setup/your-account/using-eksctl
#
# NOTE:
# The YAML below is different than the workshop page content
# It replaces some of the values captured in the env vars below.
#
# Important: set env var (AWS_REGION is already set)
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --output text --query 'Account')
export EKS_CLUSTER_NAME=eks-workshop
export K8S_VERSION=1.27
export NG_DESIRED_CAPACITY=3
export EKS_DEFAULT_MNG_MIN=3
export EKS_DEFAULT_MNG_MAX=6
export EKS_DEFAULT_MNG_DESIRED=3
export EKS_DEFAULT_MNG_NAME=default
export INSTANCE_TYPE=t3.medium
# Test env vars
echo "EKS_CLUSTER_NAME : [$EKS_CLUSTER_NAME]"
echo "AWS_REGION : [$AWS_REGION]"
echo "K8S_VERSION : [$K8S_VERSION]"
echo "NG_DESIRED_CAPACITY : [$NG_DESIRED_CAPACITY]"
echo "EKS_DEFAULT_MNG_MIN : [$EKS_DEFAULT_MNG_MIN]"
echo "EKS_DEFAULT_MNG_MAX : [$EKS_DEFAULT_MNG_MAX]"
echo "INSTANCE_TYPE : [$INSTANCE_TYPE]"
# Create the cluster YAML file in /tmp folder
# Good idea for have env vars for desiredCapacity, minSize, maxSize, instanceType
cat <<EOF | tee /tmp/eksctl-cluster.yaml
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
availabilityZones:
- ${AWS_REGION}a
- ${AWS_REGION}b
- ${AWS_REGION}c
metadata:
name: ${EKS_CLUSTER_NAME}
region: ${AWS_REGION}
version: '${K8S_VERSION}'
tags:
karpenter.sh/discovery: ${EKS_CLUSTER_NAME}
created-by: eks-workshop-v2
env: ${EKS_CLUSTER_NAME}
iam:
withOIDC: true
vpc:
cidr: 10.42.0.0/16
clusterEndpoints:
privateAccess: true
publicAccess: true
addons:
- name: vpc-cni
version: 1.14.1
configurationValues: "{\"env\":{\"ENABLE_PREFIX_DELEGATION\":\"true\", \"ENABLE_POD_ENI\":\"true\", \"POD_SECURITY_GROUP_ENFORCING_MODE\":\"standard\"},\"enableNetworkPolicy\": \"true\"}"
resolveConflicts: overwrite
managedNodeGroups:
- name: default
desiredCapacity: ${NG_DESIRED_CAPACITY}
minSize: ${EKS_DEFAULT_MNG_MIN}
maxSize: ${EKS_DEFAULT_MNG_MAX}
instanceType: ${INSTANCE_TYPE}
privateNetworking: true
releaseVersion: 1.27.3-20230816
updateConfig:
maxUnavailablePercentage: 50
labels:
workshop-default: 'yes'
EOF
# Fire cluster creation command
eksctl create cluster -f /tmp/eksctl-cluster.yaml
# We are in business
# Time to take a 15-20 minutes break while the cluster comes up
STEP 3— Testing Cluster Readiness
Let’s quickly verify that our Kubernetes cluster is up, running, and ready for application deployment that we’ll perform in future sessions. The following commands are not in the workshop but these are commonly used to test any cluster.
# Let's run a few commands to see if our cluster is up, running and ready
# Start by checking the nodes
kubectl get nodes -o wide
# Check if there are any pods running (none expected in default namespace)
kubectl get pods
# Check pods running across all namespaces
kubectl get pods -A
# Glean a little more information about the nodes (e.g. instance types)
kubectl get nodes --show-labels
# Cluster is looking good, functional and ready to handle workloads
STEP 4— Resource Cleanup
This chapter’s objective was to get the cluster up and running followed by testing a few commands to make sure it’s functional and ready for deployment. Having done all of that successfully, it’s time to clean up the resources.
# Ref: https://www.eksworkshop.com/docs/introduction/setup/your-account/using-eksctl/#cleaning-up-steps-once-you-are-done-with-the-workshop
# On Cloud9 terminal
# Delete the sample application and any left-over lab infrastructure is removed
delete-environment
# On Cloud9 terminal
# Delete cluster using eksctl
# NOTE: If not deployed any application or built any cluster resources yet
# just deleting the cluster is sufficient
eksctl delete cluster $EKS_CLUSTER_NAME --wait
# On CloudShell terminal
# Delete the cloudFormation stack
aws cloudformation delete-stack --stack-name eks-workshop-ide
# All done for this chapter!
Next Steps
Our cluster is up, running, and functional. The next chapter will target to deploy a microservices-based sample application to further our learning. It gets really exciting after this with everything this EKS workshop has in store to learn, both theory and hands-on practices.
Meanwhile, spend as much time as possible to play around with the ready cluster before deleting it and cleaning up the workshop resources. Mastering Kubernetes One Task at a Time — Know Thy Nodes! has a lot of hands-on ideas to learn more about Kubernetes nodes for the curious mind.
And if you want to get ahead on your own, the Sample Application page of the workshop is the place to visit.
See you soon in the next chapter, Chapter-3!
If you benefited from reading the post, please 👏 a few times before parting, and help others by sharing it; I highly appreciate that!
Please follow to stay in touch, track, and be the first to get notified of all future writings on AWS Cloud, Containers, Kubernetes, and Machine Learning. Also, check all my stories on The AWS Way publication.