This repository contains a demo project created as part of my DevOps studies in the TechWorld with Nana – DevOps Bootcamp.
Demo Project: CD - Deploy to EKS cluster from Jenkins Pipeline
Technologies used: Kubernetes, Jenkins, AWS EKS, Docker, Linux
Project Description:
- Install
kubectlandaws-iam-authenticatoron a Jenkins server - Create
kubeconfigfile to connect to EKS cluster and add it on Jenkins server - Add AWS credentials on Jenkins for AWS account authentication
- Extend and adjust
Jenkinsfileof the previous CI/CD pipeline to configure connection to EKS cluster
Before starting, complete the following setup modules:
- Jenkins on DigitalOcean: jenkins-module-8.1
- Build Tools (Maven, Node): jenkins-module-8.2
Note:
aws-iam-authenticatoris bundled witheksctland installed automatically when you use it.
Enter the Jenkins container as root:
docker ps
docker exec -it -u 0 <container_id> bashDownload and install kubectl:
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x ./kubectl
mv ./kubectl /usr/local/bin/kubectl
# Verify installation
kubectl version --clientStill inside the Jenkins container, run:
curl -Lo aws-iam-authenticator \
https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.6.11/aws-iam-authenticator_0.6.11_linux_amd64
chmod +x ./aws-iam-authenticator
mv ./aws-iam-authenticator /usr/local/bin
# Verify installation
aws-iam-authenticator versionSee the cluster config: cluster.yaml Reference: eks-module-11.3
eksctl create cluster -f cluster.yamlCopy the template: config-template.yaml
cp ./config-template.yaml config.yamlReplace <cluster-name> with demo-cluster, then fill in the cluster endpoint and certificate. Choose one option:
Option A — AWS Console
Navigate to EKS → Clusters → demo-cluster → Overview, then copy:
API server endpoint→cluster.serverCertificate authority→cluster.certificate-authority-data
Option B — Local kubeconfig
Pull the values from your local ~/.kube/config:
cluster.servercluster.certificate-authority-data
Transfer the file to your DigitalOcean droplet:
scp config.yaml root@<DROPLET_IP>:/rootCreate the .kube directory inside the Jenkins container:
docker ps
docker exec -it <container_id> bash -c "mkdir -p ~/.kube && exit"Copy the config into the container:
docker cp config.yaml <container_id>:/var/jenkins_home/.kube/config
# Verify the file was copied
docker exec -it <container_id> cat ~/.kube/config- Go to Dashboard → New Item
- Name it
java-maven-app, select Multibranch Pipeline, click OK
Branch Sources:
Click Add source → GitHub and fill in:
| Field | Value |
|---|---|
| Credentials | github |
| Repository HTTPS URL | https://github.com/explicit-logic/eks-module-11.4 |
Click Validate to confirm access.
Behaviors — click Add and enable:
Discover branches
Build Configuration:
- Script Path:
Jenkinsfile
- Click Save — Jenkins will scan the repository and create a job for each branch.
- Go to IAM → Users → Create user
- Name:
jenkins
- Name:
- Select Attach policies directly and attach the following managed policies:
AmazonEKSClusterPolicyAmazonEKSWorkerNodePolicyAmazonEC2ContainerRegistryFullAccess
- Complete user creation.
Find the user's ARN in the IAM console:
eksctl create iamidentitymapping \
--cluster demo-cluster \
--region <REGION> \
--arn arn:aws:iam::<ACCOUNT_ID>:user/jenkins \
--group system:masters \
--username jenkins- In IAM, open the
jenkinsuser → Security credentials → Create access key - Use case: Application running outside AWS
- Copy the Access key and Secret access key
Go to java-maven-app → Credentials → Global → Add Credentials
Add two Secret text credentials:
| ID | Secret |
|---|---|
AWS_ACCESS_KEY_ID |
<Access key> |
AWS_SECRET_ACCESS_KEY |
<Secret access key> |
Add a deploy stage to your Jenkinsfile:
stage('deploy') {
environment {
AWS_ACCESS_KEY_ID = credentials('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = credentials('AWS_SECRET_ACCESS_KEY')
}
steps {
script {
echo 'Deploying Docker image to EKS...'
sh 'kubectl create deployment nginx-deployment --image=nginx'
}
}
}




