This guide provides an automated deployment process for an AWS EKS cluster with EFS CSI driver pre-configured for Jenkins deployment on the EKS cluster. The steps include setting up the required infrastructure, deploying Jenkins, and cleaning up the environment.
Before starting, ensure that you have the following tools installed:
-
Initialize Terraform: Run the following command to initialize Terraform:
terraform init
-
Configure Variables:
- Modify the
custom.tfvars.TEMPLATE
file to suite your environment. - Rename it to
custom.tfvars
after making your changes
- Modify the
-
Deploy Infastructure: Run the following commands to apply the configuration:
terraform plan --var-file="custom.tfvars"
- If everything looks correct then run the following.
terraform apply --var-file="custom.tfvars"
- This will take approximately 25 minutes to deploy the infastructure.
-
Update Persistent Volumne Configuration:
- After Terraform ahs completed the deployment, open the
cluster-efs-pv.yaml
file. - Apply your Access PointID and EFS File System ID as shown in the example.
- After Terraform ahs completed the deployment, open the
-
Update Kubernetes Context:
- Once the infastructure is deployed, update your Kubernetes context using the following command:
aws eks --region us-east-1 update-kubeconfig --name jenkins_playground
-
Verify Kubernetes Service: Check that your Kubernetes service is funning with:
kubectl get svc
-
Deploy Amazon EFS CSI Driver: Apply the Amazon EFS CSI driver to the cluster:
kubectl apply -k "github.com/kubernetes-sigs/aws-efs-csi-driver/deploy/kubernetes/overlays/stable/?ref=master"
-
Navigate to Jenkins Deployment Directory: Change to the Kubernetes Jenkins deployment folder:
cd ../k8s/jenkins-pv
-
Apply Persistent Volume Files: Apply the Persistent Volume (PV) configuration files to the cluster:
kubectl apply -f cluster-efs-claim.yaml,cluster-efs-pv.yaml,cluster-efs-sc.yaml
-
Verify PV and PVC Status: Ensure that the Persistent Volumes and Claims are properly created:
kubectl get sc,pv,pvc
-
Update Helm Repository: Update your Helm repositories:
helm repo add stable https://charts.helm.sh/stable helm repo update
-
Install Jenkins: Install Jenkins using Helm with the EFS volume claim:
helm install jenkins stable/jenkins --set rbac.create=true,master.servicePort=80,master.serviceType=LoadBalancer,persistence.existingClaim=efs-claim
-
Get Jenkins External IP: Retrieve the external IP for Jenkins to access the UI:
kubectl get svc jenkins
-
Delete Jenkins Service: Remove the Jenkins service from Kubernetes:
kubectl delete svc jenkins
-
Delete Persistent Volumes: Delete the Persistent Volume resources:
kubectl delete -f cluster-efs-claim.yaml,cluster-efs-pv.yaml,cluster-efs-sc.yaml
-
Navigate Back to Terraform Directory: Change to the Terraform directory:
cd ../../terraform/
-
Destroy Infrastructure: Run the following Terraform command to destroy the infrastructure:
terraform destroy
EKS Cluster Setup Using Terraform: EKS-cluster
EKS Cluster Walkthrough Video: EKS-cluster-walkthrough-video
Jenkins Deployment on EKS with EFS: Jenkins-Deployment