AWS-Elastic Kubernetes Service
Amazon Elastic Kubernetes Service (Amazon EKS) is a managed Kubernetes service that makes it easy for you to run Kubernetes on AWS and on-premises.
Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.
Benefits of EKS
Scalability
High Availability
Easy management
EKS is not free click Pricing Calculator of EKS.
Prerequistics
- Ec2 Instance
- IAM
Eksctl is used to manage AWS resources (including the EKS cluster itself) and is AWS-specific. It talks to AWS API endpoints and is more of a replacement for the AWS CLI.
Kubectl is an official part of Kubernetes and is used to query and manipulate Kubernetes resources, so it works on any Kubernetes cluster
EKS cluster created three ways
1. Console of AWS
2. Eksctl
3. Terraform
Two type of node
- On demand
- Spot Instance
Setting up Amazon EKS
Launch Ec2 instance — US West (Oregon)us-west-2
Create a IAM user with Admin permission
Install aws cli
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
sudo apt install unzip
unzip awscliv2.zip
sudo ./aws/install
Check aws cli version aws — version
Configure the IAM user account — Goto IAM user — Security credentials — Create a access key — Comand line interface — Create
Install eksctl
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
eksctl version
Download kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
Install kubectl
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
Cluster create eksctl
eksctl create cluster --name ibbus-cluster --region us-west-2 --node-type t2.medium --nodes-min 2 --nodes-max 3
It will take more than 15 minutes created cluster
How many nodes run on EKS cluster
kubectl get nodes
kubectl get nodes
kubectl get pods
kubectl get pods -n kube-system
Pods like → container
Namespace means → group of pods running
Pod create
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
kubectl apply -f nginx-pod.yml
Pod running
kubectl get pods
Nginx where its running? Nodes
Kubectl running default namespace
kubectl get pods -n default
kubectl get all -n default
Open the web browser from the local machine and access type the Kubernetes node IP along with the Node port.
We are able to access the Nginx homepage successfully. It’s a containerized web server listening in the port 80 and we mapped it to 30080 in every node in the cluster.
First delete the pod
kubectl delete -f .
How to delete the EKS Cluster
eksctl delete cluster --name ibbus-cluster --region us-west-2