Amazon Elastic Kubernetes Service (Amazon EKS) is a managed service that makes it easy for you to run Kubernetes on AWS without needing to stand up or maintain your own Kubernetes control plane. Kubernetes is an open-source system for automating the deployment, scaling, and management of containerized applications.

eksctl is a simple CLI tool for creating clusters on EKS - Amazon's new managed Kubernetes service for EC2. It uses CloudFormation service to do everything and make stack over there. eksctl get authentified autmatically if we have configured aws-cli otherwise it will show error.

I have configured aws-cli already now how to set up eksctl cluster???

Now after downloading eksctl command and setting up environment variable for it, we will create yaml file for creating cluster. Here’s my yaml file:-

Here, I have created one node group in which 3 slave nodes of t2.micro instance type are there and 1 master eks will set up and i have used ssh if in case we want to go inside the slave node.

Now, with just one single command we can create eks-cluster:-

eksctl create cluster -f cluster.yml

We can see in above screenshot that cluster has been successfully set up after taking some 8–10 minutes and after it has been setup we have to update the config file for kubectl by the this command:-

aws eks update-kubeconfig — name myk8scluster

It will automatically detect where .kube folder is and then it will update config file for kubectl.

In above screenshot we can clearly see 3 slave nodes have been successfully set up. Now we all ready to use eks-cluster created by kubectl command.

In AWS, we can see eks created vpc, ebs, security-group, CloudFormation Stack:-

vpc created
subnets created
ebs created
security-group created

Now with one yaml file for jenkins, we will create one pod over one slave node. Inside jenkins-pod.yml:-

apiVersion: v1
kind: PersistentVolumeClaim
name: jenkins-pvc
name: dev
— ReadWriteOnce
storage: 2Gi

— -

apiVersion: v1
kind: Pod
name: jenkins
env: testing
region: IN
— name: myweb-con
image: mansi1709/myk8sjenk:v1
— name: web-vol1
mountPath: /root/.jenkins
— name: web-vol1
claimName: jenkins-pvc

— -

apiVersion: v1
kind: Service
name: my-service
app: myweb-service
env: testing
type: LoadBalancer
— nodePort: 31000
port: 80
targetPort: 8080

kubectl now provides one url for jenkins at port 80 which we can see on kubectl get all command.

Now we can access our jenkins in browser and i have downloaded github plugin for integrating github and jenkins.

Now i have made one job in jenkins, pulling some code from jenkins then deploy it into it’s own web server:-

Now we will create one more service for exposing web server:-

This service will provide one url for accessing this webserver at port 81.

Here, one more thing when we create service to expose jenkins and webserver by using loadbalancer, it will create two loadbalancers in aws by default .

Also when we create pvc to store data persistent in eks-cluster it will automatically creates ebs and storage class which internally contacts to ebs when pod claims for pvc.

In below screenshot you can see there are 4 ebs volumes, 3 ebs for 3 slave nodes and one for pvc.

Now you all can see, we have successfully created our eks-cluster and deploy webapp over the cluster as shown above.

One more thing, there is a concept of Fargate profile :-

AWS Fargate is a serverless compute engine for containers that works with both Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS). Fargate makes it easy for you to focus on building your applications. Fargate removes the need to provision and manage servers, lets you specify and pay for resources per application, and improves security through application isolation by design.

One last thing that when you delete the cluster, always delete it with a command:-

eksctl delete cluster -f cluster.yml

Otherwise, you will get charged very high if you have deleted cluster from directly aws console and you forgot to delete cloudformation stack. So, it’s recommended that always delete it with a file you have initially created the cluster by eksctl command.

Thank You :))))