DEV Community

Cover image for "🚀 Streamlining Kubernetes Deployment: Setting Up EKSCTL, Kubectl, and AWS CLI on Amazon Linux 2 🛠️"

"🚀 Streamlining Kubernetes Deployment: Setting Up EKSCTL, Kubectl, and AWS CLI on Amazon Linux 2 🛠️"

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 -

  • AWS Account
  • IAM User
  • 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 -
Enter fullscreen mode Exit fullscreen mode

2.Become a Root User 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
Enter fullscreen mode Exit fullscreen mode

3.Updating the server. 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"
Enter fullscreen mode Exit fullscreen mode

4.Downloading AWS CLI Package 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
Enter fullscreen mode Exit fullscreen mode

5.Checking package using ls command 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
Enter fullscreen mode Exit fullscreen mode

6.Installing AWS CLI 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
Enter fullscreen mode Exit fullscreen mode

7.Checking the AWS Version 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
Enter fullscreen mode Exit fullscreen mode

8.Setting up AWS IAM User 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

[root ~]$ cat /etc/yum.repos.d/kubernetes.repo
Enter fullscreen mode Exit fullscreen mode

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

[root ~]$ sudo yum install -y kubectl
Enter fullscreen mode Exit fullscreen mode

4.Installing Kubectl 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

[root ~]$ sudo mv /tmp/eksctl /usr/local/bin
Enter fullscreen mode Exit fullscreen mode

3.Moving from tmp directory to bin directory 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
Enter fullscreen mode Exit fullscreen mode

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!

Thank you for taking the time to read my article. I hope you found this article informative and helpful. As I continue to explore the latest developments in technology, I look forward to sharing my insights with you. Stay tuned for more articles like this one that break down complex concepts and make them easier to understand.

Remember, learning is a lifelong journey, and it’s important to keep up with the latest trends and developments to stay ahead of the curve. Thank you again for reading, and I hope to see you in the next article!

Happy Learning!

Top comments (0)