Introduction:
Amazon Elastic Kubernetes Service (EKS) is a managed Kubernetes service that simplifies the process of running Kubernetes on Amazon Web Services (AWS). In this tutorial, we will walk through the steps to set up an EKS cluster from scratch, allowing you to deploy and manage containerized applications using the power of Kubernetes.
1. Set up AWS CLI and configure it with your AWS credentials:
Install AWS CLI by following the instructions in the AWS CLI User Guide.
Configure AWS CLI by running the `aws configure` command and providing your AWS Access Key ID, Secret Access Key, default region, and output format.
To install the latest version of AWS CLI on Linux x86 (64-bit), use the following commands:
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
To confirm successful installation, run:
$ aws --version
aws-cli/2.2.5 Python/3.8.8 Linux/4.14.133-113.105.amzn2.x86_64 botocore/2.0.0
For Windows
For a Windows install, AWS CLI v2 requires a Windows 64-bit version or later and admin rights for installation.
The latest Windows installation package can be downloaded from: https://awscli.amazonaws.com/AWSCLIV2.msi and launched with admin rights for installation to complete.
Alternatively, you can use misexec
in CLI to install on the command line as:
msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi
You can use aws --version
in a command prompt to verify the install.
C:\>aws --version
aws-cli/2.2.7 Python/3.8.8 Windows/10 exe/AMD64 prompt/off
2. Install and configure the AWS CLI for EKS:
Install eksctl by following the instructions in the official documentation: https://eksctl.io/.
Install kubectl, the Kubernetes command-line tool, by following the instructions in the Kubernetes documentation: https://kubernetes.io/docs/tasks/tools/install-kubectl/.
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
Move executable file to bin directory
sudo mv /tmp/eksctl /usr/local/bin
To check version, use
eksctl version
3. Create an EKS cluster using eksctl:
Run the following command to create an EKS cluster with the desired configuration:
eksctl create cluster --name <cluster-name> --version <kubernetes-version> --region <aws-region> --nodegroup-name <nodegroup-name> --node-type <instance-type> --nodes <number-of-nodes>
Replace <cluster-name> with a name of your choice, <kubernetes-version> with the desired Kubernetes version (e.g., 1.21), <aws-region> with your preferred AWS region (e.g., us-west-2), <nodegroup-name> with a name for the node group, <instance-type> with the EC2 instance type you want to use (e.g., t3.medium), and <number-of-nodes> with the desired number of worker nodes.
4. Configure kubectl to work with the newly created cluster:
Run the following command to update the kubectl configuration:
aws eks --region <aws-region> update-kubeconfig --name <cluster-name>
Replace <aws-region> with your AWS region and <cluster-name> with the name of your EKS cluster.
5. Verify the cluster setup:
kubectl get nodes
If the nodes are ready, you should see a list of worker nodes in the output.
Run the following command to check if the nodes are ready:
You have now set up an EKS cluster using eksctl and configured kubectl to interact with it. You can now deploy and manage your applications on the EKS cluster. Make sure to refer to the official AWS EKS documentation for more advanced configuration and management options: https://aws.amazon.com/eks/.
To delete EKS cluster, use following command
eksctl delete cluster --name <cluster-name>