Skip to content

Instantly share code, notes, and snippets.

@Arka111
Created June 25, 2022 07:44
Show Gist options
  • Save Arka111/6bf2a0bdcabe94b3f5f8fef3577ebea6 to your computer and use it in GitHub Desktop.
Save Arka111/6bf2a0bdcabe94b3f5f8fef3577ebea6 to your computer and use it in GitHub Desktop.
Install EKS using eksctl
Pre-requistes:
You need to create an IAM role with Administrator Access policy and attach that IAM role to EC2 instance while you provision.
Click on Advanced Details and under user data:
Script for setting up Jenkins, Docker and setting EKS cluster using eksctl command:
#!/bin/bash
# Shell script for installing Java, Maven, Jenkins, EKS Cluster in Ubuntu EC2 instance
# Command for installing Java 11
sudo apt-get update
sudo apt-get install default-jdk -y
# Command for installing maven
sudo apt-get install maven -y
# Script for Jenkins installation
#Add Repository key to the system
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
# Append debian package repo address to the system
echo deb http://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list
sudo apt-get update
# Install Jenkins
sudo apt-get install jenkins -y
echo "Jenkins installed successfully.."
#Install Docker
sudo apt-get update
#Install the below packages
sudo apt install gnupg2 pass -y
#Install docker
sudo apt install docker.io -y
#Add Ubuntu user to Docker group
sudo usermod -aG docker $USER
# start Docker
sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker
sudo usermod -a -G docker jenkins
sudo service jenkins restart
#Reload system daemon files
sudo systemctl daemon-reload
#Restart Docker service as well
sudo service docker stop
sudo service docker start
# Install AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
sudo apt install unzip
sudo unzip awscliv2.zip
sudo ./aws/install
aws --version
#Install eksctl on Linux
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
#Move the extracted binary to /usr/local/bin.
sudo mv /tmp/eksctl /usr/local/bin
eksctl version
# Install Kubectl
sudo curl --silent --location -o /usr/local/bin/kubectl https://s3.us-west-2.amazonaws.com/amazon-eks/1.22.6/2022-03-09/bin/linux/amd64/kubectl
sudo chmod +x /usr/local/bin/kubectl
kubectl version --short --client
# Install HELM
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
sudo chmod 700 get_helm.sh
sudo ./get_helm.sh
helm version --client
sudo su - jenkins
#Create EKS cluster using eksctl command
eksctl create cluster --name demo-eks --region us-east-2 --nodegroup-name my-nodes --node-type t3.small --managed --nodes 2
@Arka111
Copy link
Author

Arka111 commented Jun 25, 2022

eksctl get cluster --name demo-eks --region us-east-2

Update Kube config by entering below command:
aws eks update-kubeconfig --name demo-eks --region us-east-2

To view the list of worker nodes as part of EKS cluster.
kubectl get nodes
kubectl get ns

Deploy Nginx on a Kubernetes Cluster
kubectl create deployment nginx --image=nginx
kubectl get deployments

Delete EKS Cluster using eksctl
eksctl delete cluster --name demo-eks --region us-east-2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment