Step 1 : In this step we need to create aws ec2 instance and make sure you select t2.large instance type for this project.
Step 2 : In this step you need to install java(jdk) on your ec2 instance.
sudo apt update
sudo apt install openjdk-11-jre
Verify Java is Installed
java -version
Step 3 : In this step you need to install jenkins on your aws ec2 instance.
Now, you can proceed with installing Jenkins
curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
Note: By default, Jenkins will not be accessible to the external world due to the inbound traffic restriction by AWS. Open port 8080 in the inbound traffic rules as show below.
- EC2 > Instances > Click on
- In the bottom tabs -> Click on Security
- Security groups
- Add inbound traffic rules as shown in the image (you can just allow TCP 8080 as well, in my case, I allowed
All traffic
).
Step 3 : click on new item
Step 4 : You need to copy the the path whre your jenkins file is located.
Step 5 : Then you need to click on manage jenkins
Step 6 : Then go to the the plugin
and install docker pipeline
Then you need to install sonarqube plugin
Configure a Sonar Server locally
apt install unzip
adduser sonarqube
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.4.0.54424.zip
unzip *
chmod -R 755 /home/sonarqube/sonarqube-9.4.0.54424
chown -R sonarqube:sonarqube /home/sonarqube/sonarqube-9.4.0.54424
cd sonarqube-9.4.0.54424/bin/linux-x86-64/
./sonar.sh start
Hurray !! Now you can access the SonarQube Server
on http://<ip-address>:9000
Note : Login and password is : admin
Step 7 : Go to the sonar account click on my account
Then go to the security
Then click on generate tokens
Then go to the credentials
Then click on system
Then go to the global credentials
Then go to the add credentials
Note : then go to the root user and install docker on it
Docker Slave Configuration
Run the below command to Install Docker
sudo apt update
sudo apt install docker.io
Grant Jenkins user and Ubuntu user permission to docker deamon.
usermod -aG docker jenkins
usermod -aG docker ubuntu
systemctl restart docker
Step 8 : Then you need to install minikube on local system or you can install on your ec2 instance. I am installing on my local system because of storage issue.
Step 9 : Then you need to install Argo cd on your local machine using kubernetes operator .you can visit this site to install argo cd (operator.io)
Step 10 : Then you need to go to manage jenkins section and click on credentials
Then click on system
Then click on global credentials
Then click on add credentials
Then you need to add your username and password of your dockerhub account in credentials
Then you need to click on add credentials again and add your github credentials
IMP Note: Then you need to go to your jenkins file in that you will see static code analysis stage and in sonar url you need to add sonarqube server ip address otherwise you will get error.
Finally…….🤩🔥🔥🔥