Configure EKSCTL, KubeCTL & AWS CLI on Amazon Linux 2

Sarvar
6 min readFeb 16, 2023

--

Hey,

It’s Sarvar Nadaf again, a senior developer at Luxoft. I worked on several technologies like Cloud Ops (Azure and AWS), Data Ops, Serverless Analytics, and Dev Ops for various clients across the globe.

Today, we’ll look into AWS EKS’s fundamentals. This post will assist you in setting up the various command-line interfaces that will enable you to communicate with the AWS EKS cluster from a laptop or other Linux-based device. Today, we will configure ESKCTL, Kubectl, and the AWS CLI. With each Linux distribution, there are a few minimal requirements and differences. I’m setting up all of these command-line tools on an Amazon Linux 2 machine today. Simply, I’ll obtain a free tier Amazon Linux 2 server and let's begin configuring command-line interfaces.

AWS CLI -

The open-source AWS CLI is a really powerful resource. This enables our interaction with the entire AWS service. Just by doing a few simple steps, we may operate our AWS account from anywhere.

Prerequisite -

  1. AWS Account
  2. IAM User
  3. Access key ID and Secret access key

1. Use the following command to become the root user. so no extra sudo command for each step.

  • [ec2-user ~]$ sudo su -
Become a Root User

2. Use the following command to carry out a fast software update to make sure your instance’s software packages are up-to-date:

  • [root ~]$ sudo yum update –y
Updating the server

3. Currently, we are downloading the zip file containing the AWS CLI package. To download the AWS CLI package from the URL, we are using the curl command. As you can see below, we are converting the package into awscli.zip using the -o option.

  • [root ~]$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv.zip"
Downloading AWS CLI Package

4. Once the command has been executed successfully, we can use the ls command to view the awscli.zip file. We are now unzipping the zip file that is on our server.

  • [root ~]$ unzip -q awscli.zip
Checking package using ls command

5. As soon as the zip file is unzipped, the entire awscli package is installed. To run and execute the awscli package, we are using the following command.

  • [root ~]$ ./aws/install
Installing AWS CLI

6. After the AWS CLI has been successfully installed, we are just running the command below to see if it is functioning as expected or not. You have successfully configured the AWS CLI on your server if you can see the output similar to the one below.

  • [root ~]$ aws --version
Checking the AWS Version

7. At this time, your IAM user information is being configured in the AWS CLI. To obtain programmatic access to all AWS services, we must submit the access key and secret access key of the IAM user. With the AWS Configure command, we must supply all the necessary information, including the region and region code for the connection you want to make. The output format must always be JSON, so we will receive the output in JSON format. We will be able to access the service that the IAM user has granted us access to.

  • [root ~]$ aws configure
Setting up AWS IAM User

8. If you can see the result of the following command after setting up the AWS CLI, your server has been successfully set up for use with the AWS CLI.

  • [root ~]$ aws s3 ls

Kubectl -

The Kubernetes API server can be reached using the command line program kubectl. When we access our AWS EKS cluster from our system, Kubectl is a big help. We can use our machine to access all of Kubernete's resources. Many operating system package managers contain the kubectl binary. It’s frequently simpler to use a package manager for installation than to download and manually install everything.

1. Here, we’re setting up a Kubernetes repository. One file must be created in order to build a repository. The file’s repo extension contains information about the gpgkey and the kubenetes baseurl of kubectl. This file is located in the directory /etc/yum.repos.d.

  • [root ~]$ cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
    [kubernetes]
    name=Kubernetes
    baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
    enabled=1
    gpgcheck=1
    gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
    EOF
Updating Repo

2. Using the cat command, we are checking that everything appears to be as expected.

  • [root ~]$ cat /etc/yum.repos.d/kubernetes.repo
Checking Repo

3. Using the command below, we are installing the kubectl CLI right now.

  • [root ~]$ sudo yum install -y kubectl
Installing Kubectl

4. After the kubectl CLI has been installed successfully, we use the version command to determine whether kubectl has been installed correctly or not.

  • [root ~]$ kubectl version
Checking Version

EKSCTL -

The AWS EKS cluster can be interacted with using the tool EKSCTL. We’ll carry out the operations necessary to create, update, manage, and delete the AWS EKS cluster. This command line interface for communicating with the AWS EKS Cluster is highly useful.

1. Here, we’re using the curl command to download the most recent version of the eksctl package into a tar file, which we then untar under the tmp directory with the following command.

  • [root ~]$ curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
Installing and untar the eksctl

2. Data from the untar eksctl package is being transferred to the /usr/local/bin directory.

  • [root ~]$ sudo mv /tmp/eksctl /usr/local/bin
Moving from tmp directory to bin directory

3. After the eksctl CLI has been installed successfully, we use the version command to determine whether kubectl has been installed correctly or not.

  • [root ~]$ eksctl version
Checking the installation

congratulations! Kubectl, eksctl, and the AWS CLI you all have been installed successfully. We have witnessed the step-by-step installation process for all three CLIs. This CLI will undoubtedly be useful while using the AWS EKS cluster or learning about the AWS EKS. This personally helped me a lot since once you learn how to use the CLI, you won’t need a console user interface to see things; just a few commands will give you access to all the information in your Linux terminal. If you have any questions, please post a comment below.

— — — — — — — —

Here is the End!

I hope you like my article. I’m going to share my knowledge with you in order to make it easier for you to grasp AWS DevOps. I’ll be publishing more articles like this soon.

happy studying!

--

--

Sarvar
Sarvar

Responses (1)