Install and configure AWS CLI and kubectl in a EC2 Client machine for AWS EKS

Install and configure AWS CLI and kubectl

 

Introduction

·         Install AWS CLI

·         Install kubectl CLI

 

Install AWS CLI for Ubuntu Linux

 

·         Reference-1: https://docs.aws.amazon.com/cli/latest/userguide/install-linux.html

 

I am using pip to install aws cli v1, you may follow the above link and use any other method as you like

 

Install pip and then install AWS CLI using pip3 install

 

·         $ curl -O https://bootstrap.pypa.io/get-pip.py

 

·         $ python3 get-pip.py --user

 

Ensure the directory that contains pip is part of your PATH variable.

Find your shell's profile script in your user folder. If you're not sure which shell you have, run echo $SHELL.

 

·         $ ls -a ~

.  ..  .bash_logout  .profile  .bashrc  Desktop

 

·         $ export PATH=~/.local/bin:$PATH

·         $ source ~/.profile

·         $ pip3 --version

·         $ pip3 install awscli --upgrade --user

·         $  aws --version

aws-cli/1.20.58 Python/3.8.10 Linux/5.11.0-1019-aws botocore/1.21.58

 

Configure AWS Command Line using Security Credentials

 

·         Go to AWS Management Console --> Services --> IAM --> User --> Select user : abushad

·         Click on Security credentials tab

·         Click on Create access key

·         Copy Access ID and Secret access key

·         Go to command line and use $aws configure

 

·     $ aws configure

       AWS Access Key ID [None]: ABCDEFGxxxxx  (Replace your creds when prompted)

       AWS Secret Access Key [None]: xxxxxxxxxxx  (Replace your creds when prompted)

       Default region name [None]: us-east-1

       Default output format [None]: json

 

 

·         Test if AWS CLI is working after configuring the above

 

·  $ aws eks list-clusters

{

    "clusters": [

        "abushad-eks"

    ]

}

 

 

 

Install kubectl CLI 

 

    Depends on the version of eks cluster, kubectl can be one version up or one version down as per best practice , I am installing v 1.21 , My EKS is 1.20

 

 

·         Reference: https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html

 

·        $ curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.21.2/2021-07-05/bin/linux/amd64/kubectl

 

·        $ chmod +x ./kubectl

 

·       $ mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$PATH:$HOME/bin

 

·       $ echo 'export PATH=$PATH:$HOME/bin' >> ~/.bashrc

  

·       $ kubectl version --short --client

              Client Version: v1.21.2-13+d2965f0db10712

 

Update the kube config for kubectl to access the EKS cluster

 

·         $ aws eks update-kubeconfig --name abushad-eks --region us-east-1

 

Now we will be able to get the kubectl to display outputs

 

·         ubuntu@ip-172-31-93-142:~$ kubectl get nodes

             NAME                           STATUS   ROLES    AGE   VERSION

             ip-172-31-88-84.ec2.internal   Ready    <none>   18m   v1.20.10-eks-3bcdcd

             ubuntu@ip-172-31-93-142:~$

 

 

Comments

Popular posts from this blog

Deploying the custom docker image as POD/container in kubernetes and creating LB to access the services

Building a custom docker container image and pushing it to Docker Hub – Docker Compose