Launch Your Kubernetes Cluster on AWS with Amazon EKS!


In today’s cloud-native world, containerized applications are everywhere and Kubernetes is the powerhouse orchestrating them. Kubernetes has become the go to container orchestration platform for deploying and managing scalable, resilient workloads. For teams building on AWS, Amazon Elastic Kubernetes Service (EKS) offers a fully managed Kubernetes control plane, reducing the operational burden and allowing developers to focus on shipping features, not infrastructure headaches.
If you've ever wondered how to set up an EKS cluster, you're in the right place. In this article, we’ll walk through deploying an Amazon EKS cluster, a clean, and scalable method that gives you control without chaos. You'll learn how to deploy this EKS cluster using the AWS Command Line Interface (AWS CLI) and then set up your workloads using the declarative method, that is defining your deployments and services with YAML configuration files. This approach gives you full control over your infrastructure setup while promoting consistency, scalability, and versioning. Let’s dive in.
STEP 1: The first step after signing into your AWS account is to create a new user in Identity and Access Management (IAM) and assign it administrative permissions. In your AWS console, search for IAM, open it and click on user on the left vertical pane, open and select “Create User“. When creating the user, assign it administrative permissions. After successful creation, select the user just created, open it and create an Access Key. Download the .csv file of the access key and save in your local machine. Refer to the images below for clarity on how to create a new user in IAM, give it administrative rights and also how to generate an Access key 👇🏻
STEP 2: The next step is to launch an EC2 Instance. To do that, from your AWS console, search for “EC2“ and select. When opened, click on launch instance. Give the Instance a name (eks-server), select an OS image. I am selecting “Amazon Linux“ as the OS image in this tutorial. Select your instance type, and create a new key pair. Generate the key pair by clicking on the “Create“ button right next to it and give it a name. All other settings are optional. You can now create your instance. Refer to the images below to create your EC2 instance successfully. 👇🏻
STEP 3: After successfully launching your EC2 Instance, connect to it via the EC2 Instance connect. Once you’re connected, in the terminal, check for the current awscli version you have by running the command: aws --version. 👇🏻
STEP 4: You can update your awscli to a more recent version by downloading and installing the recent version. To do that, run: curl “https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip“ -o “awscliv2.zip“
This command download the awscli recent version in zip format from the exact url provided.
Note: Ensure to run the following command immediately its downloaded: unzip awscliv2.zip
It make sure the file can be accessed since it was downloaded in zip format. 👇🏻
STEP 5: Now you can update your awscli. Run: which aws
This command shows the path to the executable file for the aws command that the terminal will use. The output will typically be /usr/bin/aws or a similar path depending on your system.
Now you can run: sudo ./aws/install --bin-dir /usr/bin --install-dir /usr/bin/aws-cli --update to update the awscli by installing it in the correct system directories.
You can now run aws --version to confirm your newly updated version.👇🏻
STEP 6: The next step is to configure your instance by running: aws configure You’ll be prompted to enter your Access Key ID, Secret Access Key, AWS Region, and Default Output Format. If you recall, you created an access key for the IAM user earlier and downloaded a .csv file. Open that file to copy and paste your Access Key ID and Secret Access Key when prompted. Next, confirm the region where your EC2 instance is located by checking your AWS console. For this tutorial, we used json as the default output format. 👇🏻
STEP 7: Now you need to download the official Kubernetes command-line tool, kubectl, to your EC2 instance. Run: curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.16.8/2020-04-16/bin/linux/amd64/kubectl
After downloading, give it the executable permission. Run: chmod +x ./kubectl
Then move the binary to a directory included in the EC2 Instance path. To do that, run: mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH:$PATH:$HOME/bin
After moving the binary to a directory in the EC2Instance path, you can also verify your installation by checking: kubectl version --short --client 👇🏻
STEP 8: You also need to download eksctl, the command-line tool for for creating and managing EKS clusters, to your EC2 instance. Run: curl --silent --location “https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz“ | tar xz -C /tmp
This downloads the official cli, eksctl. Now you can move binary to your system path. Run: sudo mv /tmp/eksctl /usr/bin
Confirm your installation by running eksctl version 👇🏻
STEP 9: Congratulations on your set up!!! Now you can provision an EKS cluster! You’ll be needing the zones of the region your EC2 instance is in. To get that, run: aws ec2 describe-availability-zones
To provision your cluster, run the command: eksctl create cluster --name mercury --region eu-north-1 --zones eu-north-1a,eu-north-1b --nodegroup-name worker --node-type t3.medium --nodes 3 --nodes-min 1 --nodes-max 4 --managed
This commands specifies that you want to create an eks cluster named mercury in the region eu-north-1 and zones eu-north-1a,eu-north-1b. You’re specifying the nodegroup name to be worker and you want 3 nodes, minimum of 1 and maximum of 3. 👇🏻
STEP 10: Confirm that you’ve created your cluster from your AWS console, search for cloud formation and confirm your stacks. Also from Elastic Kubernetes Service, confirm your mercury cluster. You will also see that your instances have been increased to four as you’ve specified that three worker nodes be created when you were creating your cluster. Refer to the images below 👇🏻
STEP 11: Now, reconnect to your instance using the EC2 Instance Connect and check your cluster by running: eksctl get cluster
Enable EC2 to connect to the cluster. Run: aws eks update-kube-config --name mercury --region eu-north-1
STEP 12: This is where it gets interesting! You can now create deployments and services. In this tutorial, we’ll be using pre-written .yaml files (declarative approach), which we'll clone from a GitHub repository. But first, we need to install Git on our instance.
To Install git, run: sudo install -y git
Clone/Download the Github Repo by running: git clone https://github.com/ACloudGuru-Resources/Course_EKS-Basics
Now enter the folder you’ve downloaded from github to access the yaml files. Run: cd Course_EKS-Basics
Run: ls to confirm we have just two .yaml files in the directory, these which are nginx.deployment.yaml and nginx-svc.yaml
Open the nginx.deployment.yaml and nginx-svc.yaml to view them by running cat nginx.deployment.yaml and cat nginx-svc.yaml
Now you can create a deployment by running kubectl appy -f ./niginx-deployment.yaml
Create a service by running kubectl appy -f ./niginx-svc.yaml
Get the External IP of your service by running kubectl get service. Copy and paste the external IP of your service in a browser to view the service.
👇🏻
As you can see, we can access our service from a browser, in the image below 👇🏻
STEP 13: Now, let’s test the high availability feature of the EKS Cluster. In the AWS console, on the EC2 instance page, select one of the worker node instance and stop the instance. After a few minutes, you should see EKS launching another instance automatically for you. That is to explain that the EKS automatically launches new instances if one or two of the node(s) is down to keep the services running. However, it doesn’t exceed the maximum number of node specified for the cluster. From the images below, you can see that another instance was launched by the EKS as soon as one of the instance was stopped.
Congratulations! You’ve just taken a big step into the world of Kubernetes by successfully deploying your very own Elastic Kubernetes Service (EKS) cluster on AWS. Are you exploring container orchestration for the first time? or just scaling up your cloud expertise? This is a very powerful foundation to build on.
If you found this guide helpful, don’t forget to like, comment, and share it with others who might benefit too. Feel free to reach out, if you’ve got any questions or need a bit of clarity on any step, I’d love to hear from you. Let’s keep learning and growing together.
Subscribe to my newsletter
Read articles from Damilola Linda Olowookere directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
