Skip to content

FouL06/jenkins-terraform-eks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Jenkins AWS EKS Cluster Deployment

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.

Prerequisites

Before starting, ensure that you have the following tools installed:

Infrastructure Setup

  1. Initialize Terraform: Run the following command to initialize Terraform:

    terraform init
  2. Configure Variables:

    • Modify the custom.tfvars.TEMPLATE file to suite your environment.
    • Rename it to custom.tfvars after making your changes
  3. 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.
  4. 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.
  5. 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

Jenkins Installation

  1. Verify Kubernetes Service: Check that your Kubernetes service is funning with:

    kubectl get svc
  2. 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"
  3. Navigate to Jenkins Deployment Directory: Change to the Kubernetes Jenkins deployment folder:

    cd ../k8s/jenkins-pv
  4. 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
  5. Verify PV and PVC Status: Ensure that the Persistent Volumes and Claims are properly created:

    kubectl get sc,pv,pvc
  6. Update Helm Repository: Update your Helm repositories:

    helm repo add stable https://charts.helm.sh/stable
    helm repo update
  7. 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
  8. Get Jenkins External IP: Retrieve the external IP for Jenkins to access the UI:

    kubectl get svc jenkins

Cleanup

  1. Delete Jenkins Service: Remove the Jenkins service from Kubernetes:

    kubectl delete svc jenkins
  2. Delete Persistent Volumes: Delete the Persistent Volume resources:

    kubectl delete -f cluster-efs-claim.yaml,cluster-efs-pv.yaml,cluster-efs-sc.yaml
  3. Navigate Back to Terraform Directory: Change to the Terraform directory:

    cd ../../terraform/
  4. Destroy Infrastructure: Run the following Terraform command to destroy the infrastructure:

    terraform destroy

Documentation Refrences

EKS Cluster Setup Using Terraform: EKS-cluster

EKS Cluster Walkthrough Video: EKS-cluster-walkthrough-video

Jenkins Deployment on EKS with EFS: Jenkins-Deployment

About

Terraform module code to deploy and start a jenkins server hosted on and AWS EKS cluster.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages