CAPSTONE PROJECT

End-to-End DevOps Capstone Pipeline

Validate toolchains configurations, link Jenkins CI automation engines with Docker builds, provision AWS resources via Terraform, and deploy applications to Kubernetes.

Environment
Jenkins / K8s / Terraform
Difficulty
Capstone
Course Module
Chapter 12: Capstone
Deliverables
Integrated Pipeline Run Logs
1. System Architecture & Workflow

The diagram below displays the end-to-end DevOps pipeline, showing the workflow from code commits on GitHub, to automated builds, resource provisioning, and container deployment.

1. Commit git push Developer commits to GitHub repo 2. Jenkins CI Maven Build Run Unit Tests Docker Package Jenkinsfile Orchestrator 3. Registry Docker Hub Pushes container image to registry 4. IaC Terraform Provisions target cloud infrastructure 5. Deploy (K8s) Helm Chart Pods Running Exposed on NodePort
2. Part 1: Step-by-Step Action Items & Key Execution Steps
STEP 1

Validate the Complete DevOps Toolchain

Run diagnostic checks to verify that all compilers, package managers, and container runtimes are installed and configured.

$ git --version && java -version && mvn -version && docker version
This command queries version information to verify that the Git client, Java SDK, Maven compile engine, and Docker daemon are ready for builds.
$ kubectl get nodes && helm version && terraform version && aws sts get-caller-identity
This command verifies target connections, checking cluster nodes, Helm charts, Terraform versions, and AWS CLI profile credentials.
$ ansible localhost -m ping
This command runs the Ansible ping module against your local workstation, verifying loopback connectivity.
STEP 2

Configure Jenkins Agent Socket Permissions

Add the Jenkins execution user to the docker system group, allowing Jenkins to build and push container images.

$ sudo usermod -aG docker jenkins && sudo systemctl restart jenkins
This command appends the jenkins user to the docker group and restarts the service, enabling Jenkins pipelines to build images.
STEP 3

Provision Target Infrastructure using Terraform

Navigate to your Terraform project folder and apply configurations to provision your target cloud environment.

$ cd ~/Projects/terraform-lab && terraform apply -auto-approve
This command runs the Terraform provisioning pipeline, creating resources on AWS and writing network layouts automatically.
STEP 4

Deploy the Application to Kubernetes via Helm

Use the Helm package manager to install your application package, setting container image tags to deployment endpoints.

$ helm install devops-app ~/Projects/helm-chart --set image.tag=latest
This command installs the application package to the cluster, setting configuration parameters dynamically using the latest image tag.
STEP 5

Verify Service Endpoints and Check System Logs

Forward ports to connect to your service locally and check cluster logs to verify deployment health.

$ kubectl port-forward svc/devops-app-service 8080:80
This command maps local port 8080 to the application service inside Kubernetes, enabling host system browser testing.
$ kubectl get pods --all-namespaces && kubectl logs -l app=devops-app
This command queries the cluster status and outputs container logs to verify that the application started successfully.
3. Operational Pipeline Architecture

The diagram below traces the stages of the Jenkinsfile pipeline, from code checkout to compilation, containerization, and Kubernetes rollout.

1. Checkout Pull source code from GitHub repo git checkout 2. Build & Test Compile Java and execute unit tests mvn clean test 3. Docker Push Package and push image to hub docker build & push 4. Helm Deploy Deploy app and monitor status helm upgrade --install
4. Part 2: Complete Deliverable Assets & Production Templates

To automate the continuous delivery of the Capstone project, we will write a declarative Jenkinsfile that links compile, test, package, containerization, infrastructure, and Kubernetes rollout stages. Below is a step-by-step breakdown of how this pipeline is built, followed by the final combined script.

Step-by-Step Script Construction

Step 1

Define Environment Parameters

Setup environment variables to reference credentials, container tags, and configuration paths.

pipeline { agent any environment { DOCKER_HUB_CRED = 'docker-hub-credentials' DOCKER_IMAGE = 'yourusername/devops-capstone-app' HELM_RELEASE = 'devops-app' CHART_PATH = './helm-chart' } }
This boots the pipeline block on any agent and sets environment variables mapping your Docker Hub credentials, image name, Helm release label, and chart folder paths.
Step 2

Add Source Checkout and Compile Stages

Implement source retrieval and unit test verification scripts.

stages { stage('Source Checkout') { steps { checkout scm } } stage('Maven Compile & Test') { steps { sh 'mvn clean test' } post { always { junit '**/target/surefire-reports/*.xml' } } } }
This checks out files from your SCM repository, runs compile/unit tests with Maven, and logs XML test outputs to Jenkins.
Step 3

Package Application and Dockerize

Build Java binary archives, authenticate against Docker Hub, and build/push container images.

stage('Package Artifact') { steps { sh 'mvn package -DskipTests' } } stage('Dockerize & Publish') { steps { script { docker.withRegistry('', DOCKER_HUB_CRED) { def img = docker.build("${DOCKER_IMAGE}:${BUILD_NUMBER}") img.push() img.push('latest') } } } }
This stage packages source libraries into a JAR file, log into Docker Hub using credentials, builds a container tagged with the build number, and pushes the image.
Step 4

Provision Infrastructure via Terraform

Initialize and apply local security parameters and AWS EC2 resources automatically.

stage('Terraform Plan / Apply') { steps { sh 'cd ./terraform && terraform init && terraform apply -auto-approve' } }
This changes directory to your Terraform files, initializes regional provider plug-ins, and applies changes automatically without prompt blocks.
Step 5

Deploy to Kubernetes Cluster using Helm Charts

Deploy application container revisions using Helm upgrade commands.

stage('Deploy via Helm') { steps { sh 'helm upgrade --install ${HELM_RELEASE} ${CHART_PATH} --set image.tag=${BUILD_NUMBER}' } }
This command invokes Helm to install or upgrade the release chart, dynamically setting the container image tag parameters to match the latest build.

Combined Complete Configuration File

Save the consolidated blocks above as Jenkinsfile in the root folder of your project repository, commit it, and push it to trigger the capstone pipeline:

pipeline { agent any environment { DOCKER_HUB_CRED = 'docker-hub-credentials' // Jenkins Credentials ID for Docker Hub DOCKER_IMAGE = 'yourusername/devops-capstone-app' HELM_RELEASE = 'devops-app' CHART_PATH = './helm-chart' } stages { stage('Source Checkout') { steps { checkout scm } } stage('Maven Compile & Test') { steps { sh 'mvn clean test' } post { always { junit '**/target/surefire-reports/*.xml' } } } stage('Package Artifact') { steps { sh 'mvn package -DskipTests' } } stage('Dockerize & Publish') { steps { script { docker.withRegistry('', DOCKER_HUB_CRED) { def customImage = docker.build("${DOCKER_IMAGE}:${BUILD_NUMBER}") customImage.push() customImage.push('latest') } } } } stage('Terraform Plan / Apply') { steps { sh 'cd ./terraform && terraform init && terraform apply -auto-approve' } } stage('Deploy via Helm') { steps { sh 'helm upgrade --install ${HELM_RELEASE} ${CHART_PATH} --set image.tag=${BUILD_NUMBER}' } } } }
5. Deliverables Summary

Verify that the following configurations and outputs exist inside your workstation environment.

Created Files / Templates

  • /home/devops/Projects/capstone/Jenkinsfile - Integrated multi-stage build, container, and deploy pipeline script.
  • /home/devops/Projects/capstone/terraform/main.tf - Infrastructure manifests.
  • /home/devops/Projects/capstone/helm-chart/values.yaml - Helm chart configuration values file.

Verification Artifacts / Execution Proof

  • Integrated Jenkins pipeline dashboard run showing successful build status.
  • Image registry metadata showing uploaded docker images.
  • Console prints of kubectl get services showing exposed NodePort IPs.
6. Closing Explanation: Why We Did This & What It Accomplishes

Architectural Intent & Operational Impact

Why We Did This

What This Accomplishes