DevSecOps Project Setup
Create an Ubuntu Virtual Machine in AWS/Azure cloud.
1. Login on AWS Cloud
2. Click on Instances option in left hand side menu.
3. Click Launch instances
Enter Name and tag of the system.
Under Application and OS Images (Amazon Machine Image) Select an Ubuntu operating
system.
In Instance type select [Link] machine.
In key pair (login), select an existing key pair or you can connect a new pair.
Once you create a new pair it will download the key with .pem extension.
Increase volume space as 20 GB
Click Launch instance.
Install software’s on Ubuntu VM
1. Install Jenkins on Ubuntu machine.
In order to install Jenkins, first we need to install Java on Ubuntu VM.
Run below command to install Java on Ubuntu VM.
sudo apt update
sudo apt install openjdk-17-jre
java -version
Once the Java is installed, please use below command to install Jenkins.
curl -fsSL [Link] | sudo tee \
/usr/share/keyrings/[Link] > /dev/null
echo deb [signed-by=/usr/share/keyrings/[Link]] \
[Link] binary/ | sudo tee \
/etc/apt/[Link].d/[Link] > /dev/null
sudo apt-get update
sudo apt-get install jenkins
You can start the Jenkins service with the command:
sudo systemctl start jenkins
Use the below URL to access the Jenkins.
[Link]
2. Install SonarQube-Scanner.
Login on newly created Ubuntu VM with Jenkins user.
Su - jenkins
Open windows terminal or any other client to access the Ubuntu VM (ex. – Putty, git
bash, terminal)
Once you connect the VM, install Sonarqube-Scanner.
Open below URL in your local Machine and get the download link
[Link]
sonarscanner/
As we are using Linux VM, so you can copy the download link by right click on Linux 64-
bit.
Now in Ubuntu VM type below command to download the SonarQube-Scanner.
wget [Link]
[Link]?
_gl=1*95pkq8*_gcl_au*MTg4OTYzODk1Ny4xNjkyNjgxNDQz*_ga*MjEwNjk3MDk0LjE2OTI2ODE0
NDM.*_ga_9JZ0GZ5TC6*MTY5Mzc5NDUwMi4xMy4xLjE2OTM4MDEzNTMuNjAuMC4w
Check the downloaded file using ls command.
Rename the downloaded file.
mv [Link]\?_gl\=1\*47vsl3\*_gcl_au\
*MTg4OTYzODk1Ny4xNjkyNjgxNDQz\*_ga\*MjEwNjk3MDk0LjE2OTI2ODE0NDM.\
*_ga_9JZ0GZ5TC6\*MTY5Mzc5NDUwMi4xMy4xLjE2OTM3OTY3MTguNjAuMC4w sonar-scanner-
[Link]
Now install unzip package to extract the downloaded file.
apt-get update && apt-get install -y unzip
unzip the Sonarqube-Scanner zip file, using this command.
unzip [Link]
3. Install kubectl to access google cloud Kubernetes cluster.
Login with root user and enter the below commands.
You can use below link to install kubectl : -
[Link]
curl -LO [Link] -L -s
[Link]
curl -LO [Link]
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl
4. Helm install on Ubuntu VM
To install Helm, you can use below link for step by step guide.
[Link]
curl [Link] | gpg --dearmor | sudo tee
/usr/share/keyrings/[Link] > /dev/null
sudo apt-get install apt-transport-https --yes
echo "deb [arch=$(dpkg --print-architecture)
signed-by=/usr/share/keyrings/[Link]]
[Link] all main" | sudo tee
/etc/apt/[Link].d/[Link]
sudo apt-get update
sudo apt-get install helm
5. Install the gcloud CLI on ubuntu.
Please use the below link to install google cloud CLI.
Login with the root user on Ubuntu VM and run below commands.
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates gnupg curl sudo
echo "deb [signed-by=/usr/share/keyrings/[Link]]
[Link] cloud-sdk main" | sudo tee -a
/etc/apt/[Link].d/[Link]
curl [Link] | sudo apt-key --
keyring /usr/share/keyrings/[Link] add –
sudo apt-get update && sudo apt-get install google-cloud-cli
sudo apt-get install google-cloud-sdk-gke-gcloud-auth-plugin
Now login with jenkin user on Ubuntu VM
Run google init command.
gcloud init
It will ask you to log in to continue.
Copy the output URL and open in a browser.
Once you login with the google account it will generate the authorization code.
Copy the authorization code and paste in console.
Now it will ask you to select the project.
Once you select the project it will ask you to set the default region.
You can can configure the region you press Y option, otherwise you can type N.
Now you to get credentials to access Gcloud Kubernetes cluster.
Open Kubernetes clusters page in browser and click on highlighted option.
Click on Connect option.
Copy the generated command and paste in console.
6. Install npm and maven, use below command to install NPM and Maven
apt-get update && apt-get install -y npm maven
7. Install Trivy
Use below link to install Trivy
[Link]
Go to latest release link and select the appropriate version.
Right the highlighted link and copy link address.
Use wget command to download trivy in ubuntu vm
wget
[Link]
[Link]
Now extract the downloaded file using below command
tar -xzvf trivy_0.45.0_Linux-[Link]
Now set the path variable for trivy.
mv trivy /usr/local/bin/
8. Install Cosign
Download cosign from below link.
[Link]
Use the below command to download Cosign on Ubuntu machine.
wget [Link]
amd64
Type ls to check the downloaded binary file.
Assign executable permission to execute the file.
chmod 755 cosign-linux-amd64
Rename the Cosign file name from “cosign-linux-amd64” to cosign.
mv cosign-linux-amd64 cosign
Move the binary file to /usr/local/bin to default path variable.
mv cosign /usr/local/bin/
Now you can run cosign command to check successfully installed or not.
9. Install docker.
Please use the below article to download and install docker on Ubuntu VM.
[Link]
run the following commands to install docker.
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL [Link] | sudo gpg --dearmor -
o /etc/apt/keyrings/[Link]
sudo chmod a+r /etc/apt/keyrings/[Link]
echo \
"deb [arch="$(dpkg --print-architecture)"
signed-by=/etc/apt/keyrings/[Link]]
[Link] \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/[Link].d/[Link] > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli [Link] docker-buildx-
plugin docker-compose-plugin
Add Jenkins user to docker group on your linux system group.
adduser jenkins docker
Restart Jenkins service.
service jenkins restart
10. Install Sonarqube on Google Kubernetes cluster.
Use the below URL to setup Sonarqube on Google Kubernetes cluster.
[Link]
on-kubernetes/
Use the below command to install Sonarqube.
helm repo add sonarqube [Link]
helm repo update kubectl create namespace sonarqube-lts helm upgrade --install
-n sonarqube-lts sonarqube sonarqube/sonarqube-lts
helm upgrade --install -n sonarqube-lts sonarqube sonarqube/sonarqube-lts --
set [Link]=LoadBalancer
Get the Sonarqube LoadBalancer public IP
kubectl get services -n sonarqube-lts
Use the below url to access Sonarqube.
[Link]