đź§ Overview
You’ll deploy Jenkins on Amazon Elastic Kubernetes Service (EKS), then configure it to run Jenkins Pipelines inside pods using Kubernetes agents.
This setup allows Jenkins to scale dynamically — spinning up pods for builds and destroying them automatically.
🚀 Step-by-Step Setup
Step 1: Prerequisites
Ensure you have:
AWS Account
IAM user/role with AdministratorAccess or EKS-related permissions
awscli, kubectl, eksctl, and helm installed
aws --version
kubectl version --client
eksctl version
helm version
Step 2: Create an Amazon EKS Cluster
Use eksctl for quick setup:
eksctl create cluster \
--name jenkins-cluster \
--region us-east-1 \
--nodegroup-name jenkins-nodes \
--node-type t3.medium \
--nodes 2
Once complete:
kubectl get nodes
You should see your nodes in Ready state.
Step 3: Create a Namespace for Jenkins
kubectl create namespace jenkins
Step 4: Install Jenkins via Helm
Add the official Jenkins Helm chart repository:
helm repo add jenkins https://charts.jenkins.io
helm repo update
Install Jenkins into the jenkins namespace:
helm install jenkins jenkins/jenkins \
--namespace jenkins \
--set controller.serviceType=LoadBalancer \
--set controller.adminUser=admin \
--set controller.adminPassword=admin123
Wait for Jenkins to be ready:
kubectl get pods -n jenkins
Step 5: Get Jenkins LoadBalancer URL
kubectl get svc -n jenkins
You’ll see something like:
jenkins LoadBalancer aabbccddeeff.us-east-1.elb.amazonaws.com 80:31000/TCP
Access Jenkins at:
http://aabbccddeeff.us-east-1.elb.amazonaws.com
Login with:
Username: admin
Password: admin123
Step 6: Install Jenkins Plugins
Inside Jenkins → Manage Jenkins → Plugins, install:
Kubernetes Plugin
Pipeline Plugin
Git Plugin
Docker Pipeline
Blue Ocean (optional)
Step 7: Configure Jenkins Kubernetes Cloud
Go to: Manage Jenkins → Manage Nodes and Clouds → Configure Clouds → Add a new cloud → Kubernetes
Set:
Kubernetes URL: https://kubernetes.default:443
Jenkins URL: http://jenkins:8080
Jenkins tunnel: jenkins-agent:50000
Check WebSocket if using Helm chart defaults.
Test connection → Save.
Step 8: Define a Kubernetes Pod Template
In Jenkins (under “Configure Clouds”): Add a Pod Template:
Name: jnlp-agent
Label: k8s
Container Template:
Name: jnlp
Image: jenkins/inbound-agent:latest
Command to run: left blank
Arguments: left blank
Save the configuration.
Step 9: Create a Jenkins Pipeline
Go to New Item → Pipeline → OK
Add this sample Jenkinsfile:
pipeline {
agent {
kubernetes {
label 'k8s'
yaml """
apiVersion: v1
kind: Pod
spec:
containers:
-
name: build
image: maven:3.9.5-eclipse-temurin-17
command:- cat tty: true """ } }
stages {
stage('Checkout') {
steps {
git branch: 'main', url: 'https://github.com/repouser/repo.git'
}
}stage('Build') { steps { container('build') { sh 'mvn clean package' } } } stage('Test') { steps { container('build') { sh 'mvn test' } } } stage('Deploy') { steps { echo "Deployment to EKS or staging can be added here..." } }}
}
Click Build Now → Jenkins will: ✅ Launch a pod on EKS
âś… Run Maven build inside that pod
âś… Destroy the pod after completion
Step 10: (Optional) Store Persistent Jenkins Data
Create a persistent volume:
kubectl get pvc -n jenkins
By default, the Helm chart creates one using EBS volumes.
đź§© Architecture Summary
Flow:
Jenkins Controller runs inside EKS.
When a pipeline runs → Kubernetes plugin requests a pod.
Jenkins Agent pod (with jnlp container) connects back to controller.
The build runs → pod deleted after job.
Benefits:
Dynamic scaling of build agents
Isolated build environments per job
No need for static Jenkins agents
đź§ Pro Tip for Production
Use Ingress + SSL for secure Jenkins access.
Enable RBAC and IAM Roles for Service Accounts (IRSA).
Store secrets in AWS Secrets Manager.
Monitor Jenkins pods with Prometheus + Grafana.
Top comments (0)