This project is purely intended as a sandbox demonstration environment for creating a containerised CI/CD pipeline with Jenkins for a sample Java app. Nothing in here should be used anywhere other than in a local testing environment for educational purposes.
A simple Jenkins pipeline for a sample Java app.
Specifications
- Log files saved to persistent storage.
- SSL termination inside the container with self-signed certificates
- Application to be accessible over both http and https.
- Use Jenkins to poll Git every 15m for changes
Toolset
- Github for source control (this repo)
- Minikube (shown using integrated version of Docker for Windows on WSL2)
- Azure DevOps Public Project jenkins-java-techdemo for work tracking band backlog.
- Typora for markdown formatting
Assumptions
- Tomcat Sample app is expected to run unmodified.
Fork this project ..
Assuming Powershell is available, with a kubectl context set to local Kubernetes
cd .\build
.\run-jenkins-in-kubernetes.ps1 # Builds Dockerfile and deploy to k8s
Once completed, and the pod is running, you can connect to http://localhost:30808 to get to Jenkins Interface
In Jenkins, add a github ssh credential to your forked repo
Create a new Pipeline, using the contents of the Jenkinsfile in this repo, and update to your forked repo address.
Jenkins builds and deploys the ./src/Dockerfile and updates a k8s deployment in the local cluster which can be accessed through https://localhost:30810/sample/
- The original goal was to set up a ephemeral Jenkins builder job that would run as a k8s cronjob with everything defined from source. Moved to backlog for now.
- The hardcoded self-signed certificate is unsecure. An attempt was made to have this automatically generated during the Docker build process. For local environment testing demonstration purposes the hardcoded keystorepass is deemed to acceptable low risk.
- Dockerfiles should included automated test suites - there's little to test at this stage.
- Snyk Docker security scans should be included as part of the Docker build process.
.. nobody asked for, but still fun to do ..
- Added Powershell Core to the Jenkins Docker image (I just prefer it for scripting, although it turned out I didn't use)
- A publicly visible Azure DevOps Project jenkins-java-techdemo was created for this demo. (Using project management tools saves more time in the long run)