Build an End-to-End DevSecOps CI/CD Pipeline and deploy it to EKS

Goals & Objectives:

What is DevSecOps:

Requirements

Pipeline Architecture

Pipeline Architecture

Section 1: Build, test and push java dockerized application to Docker registry :

1. Setting up Jenkins

docker network
docker-compose-jenkins.yaml
error with user Jenkins
Jenkins dashboard

SCM Stage

Blue Ocean jenkins dashboard

Compile Stage

compile stage with docker agent

Checkstyle Stage

$ mvn checkstyle:checkstyle
checkstyle-result.xml

Integration of Jenkins and Checkstyle:

Unit Test Stage

Integration Tests Stage

Code Quality Analysis stage

PMD:

PMD

FindBugs:

FINDBUGS

JavaDocs

SonarQube

$ docker-compose up -d sonarqube
$ mvn sonar:sonar -Dsonar.host.url=http://192.168.99.100:9000
$ mvn sonar:sonar -Dsonar.host.url=http://192.168.99.100:9000

Integration of SonarQube with Jenkins

$ docker-machine ip
$ 192.168.99.100
Jenkins Blue Ocean pipeline Dashboard
SonarQube Dashboard

Building and scanning Docker images:

stage('Building and scanning image') {
steps {
script {
sh """trivy image --format template --template "@html.tpl" --output trivy_report.html IMAGE_NAME
"""

}

}
}
post {
always {
archiveArtifacts artifacts: "trivy_report.html", fingerprint: true

publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: '.',
reportFiles: 'trivy_report.html',
reportName: 'Trivy Scan',
])
}
}

Nexus 3 Repository

Nexus integration with Jenkins

Ansible

Staging Server

echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGHBsoki/RIm9uMwp+c1LcxHOo46YWYNjypGWpNWlsVB7S+Kibh+73LiPRRxwFRhSCkUwYyi4EEG6cstd8vELA4Mggv5A2uS/siciNcMCmF7Lr28yPfJMt3yX9LjDkHRDz9W28ncaeTLE0vuGphjx8kKG8h+zc5maLEcFwzbMv31ULbd3qCqhK35rgBP/OQT/bww4TikUprgdYX6+wkx5f3QflmaVTsM1jtmeTm8ME+XqWml8Nm8mZlxmzos2Pz84F3ilxrc41eStQk/FXaGaxlLihd8LFoFoqiYO4KlIdszOTd3jq6oMrj6Fy0HSE1gqe6hW+RQqN69mH3SRPDbwX root@7aecbf9c557f" > /home/ansible/.ssh/authorized_keys
ssh-copy-id -i ~/.ssh/id_rsa.pub ansible@ip_machine_ansible_target
java inside java target container

Deploy to AWS EKS Cluster using Helm charts and Terraform

provision EKS via Terraform

Use of EC2 instances via node groups

Changes made to the AWS provider example

Jenkins pipeline

terraform tool installation:

IAM roles required

What is HELM?

Deploy the application as a deployment

Resources

--

--

I build and break stuff, preferably in the cloud

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store