Posts Setting up Kubectl for Amazon EKS
Post
Cancel

Setting up Kubectl for Amazon EKS

1. Install kubectl for Amazon EKS

Follow Kubernetes Documentation to install Kubectl

MacOS

1
2
3
4
5
6
7
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl

chmod +x ./kubectl

sudo mv ./kubectl /usr/local/bin/kubectl

kubectl version

Linux

1
2
3
4
5
6
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl

chmod +x ./kubectl

sudo mv ./kubectl /usr/local/bin/kubectl


2. Install the Latest AWS CLI

You will need version 1..16.156 or greater for working with kubectl for Amazon EKS

Prerequisites

Python v3 installed and the pip commands shown use the pip3 version.

Install AWS CLI using pip

1
pip3 install awscli --upgrade --user

Update $PATH (Add export PATH=/home/redux/.local/bin/:$PATH in bashrc)

Install Using the Bundled Installer

1
2
3
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws


3. Configure AWS CLI

Get Access Key and Secret Access Key for Production EKS Cluster user and configure aws cli by running

1
aws configure


4. Configure IAM Authenticator

Amazon EKS uses IAM to provide authentication to your Kubernetes cluster through the AWS IAM Authenticator for Kubernetes.

MacOS

1
2
3
4
5
6
7
8
9
10
curl -o aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.12.7/2019-03-27/bin/darwin/amd64/aws-iam-authenticator

chmod +x ./aws-iam-authenticator

mkdir -p $HOME/bin && cp ./aws-iam-authenticator $HOME/bin/aws-iam-authenticator && export PATH=$HOME/bin:$PATH

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

source  ~/.bash_profile

Linux

1
2
3
4
5
6
7
8
9
10
curl -o aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.12.7/2019-03-27/bin/linux/amd64/aws-iam-authenticator


chmod +x ./aws-iam-authenticator

mkdir -p $HOME/bin && cp ./aws-iam-authenticator $HOME/bin/aws-iam-authenticator && export PATH=$HOME/bin:$PATH


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


5. Create kubeconfig file

1
aws eks --region region update-kubeconfig --name cluster_name


6. Testing configuration

1
kubectl get svc
This post is licensed under CC BY 4.0 by the author.