Friday, May 20, 2022

Automate EKS Cluster using Bootstrap Script | Bootstrap script for setting up Jenkins, Docker and EKS Cluster in AWS cloud


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:


# 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 - | sudo apt-key add -

#  Append debian package repo address to the system

echo deb 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 -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 "" -o "" 

sudo apt install unzip

sudo unzip  

sudo ./aws/install

aws --version

#Install eksctl on Linux

curl --silent --location "$(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

sudo chmod +x /usr/local/bin/kubectl

kubectl version --short --client

# Install Helm

curl -fsSL -o

sudo chmod 700

sudo ./

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 

No comments:

Post a Comment

How to create regular Artifactory Admin user in JFrog Artifactory? | How to create admin user in JFrog Artifactory?

Login to Artifactory server Click on Tools--> User Management --> Users Click on New user Create an admin user  Make sure you follow p...