Deployed Java application using Maven, Sonarqube, Jfrog Artifactor, Jenkins, ArgoCD and finally…

Deployed Java application using Maven, Sonarqube, Jfrog Artifactor, Jenkins, ArgoCD and finally…

High Overview

Jenkins Server Setup

  1. We have to configure Jenkins, For that We are going to create an EC2 server where Jenkins will be installed. Also, We are going to install some other tools as well such as Sonarqube and Docker so, we need more RAM and CPU.

Configurations: t2.large, Ubuntu22.04, Security Group Port Open- 22, 9000, 8080, 8081, and 8082, Storage: 30GB gp2.

2. After creating EC2 Instance, log in to the created machine using ssh.

3. Install Jenkins, You can refer to the Github Repo where you just need to run the script or follow the command to install it on your machine.

GitHub Repository: https://github.com/AmanPathak-DevOps/Scripts-Installation.git

You can see below Jenkins has been installed.

4. Now, browse the Jenkins server with the help of public_ip:8080. Make sure, you have opened port number 8080 in the instance’s security group.

5. Get the password using the command /var/lib/jenkins/secrets/initialAdminPassword.

6. After entering the password, Click on Continue.

7. Click on “Install suggested plugins”

8. For now, you can proceed by clicking on the “skip and continue as admin”

9. The setup is completed.

10. Install the Docker Pipeline plugin

Sonarqube Server Setup

11. Install the Sonarqube Scanner plugin

12. Install Sonarqube on your EC2 Instance or the local machine.

You can refer to the Github Repo where you just need to run the script or follow the command to install it on your machine.

GitHub Repository: https://github.com/AmanPathak-DevOps/Scripts-Installation.git

apt install unzip

adduser sonarqube

wget binaries.sonarsource.com/Distribution/sonar..

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

13. Set up the Sonarqube for the EC2/Local server.

Username and password: admin

In the next step, you have to reset your password.

14. Your Sonarqube server is up and running which will look like this.

15. Now, We have to connect the Jenkins Sonarqube scanner with this Sonarqube server. To do that, click on the profile which is right of the search box, and go to My Account.

16. To generate the toke for connecting with Jenkins Sonarqube Scanner with the Sonarqube Server. Click on the Security tab, give the names to the token, and click on Generate.

17. Now, Add the Generated Token in Jenkins. By Dashboard -> Manage Jenkins -> Credentials -> System -> Global credentials.

Jfrog-Artifactory Server Setup

18. Create a new EC2 Instance t2.medium and install jfrog-artifactory.

You can refer to the Github Repo in which there is a script called Install-Jfrog-Artifactory.sh and run it which installed Jfrog Artifactory on your machine or you can just copy and paste.

GitHub Repository: https://github.com/AmanPathak-DevOps/Scripts-Installation.git

You can also refer youtube video link to integrate Jfrog Artifactory with Jenkins How to Configure Artifactory in Jenkins

19. Now, set up the Artifactory, to upload the artifacts after Code Analysis Successfully completed.

Click on Get Started.

20. Enter the new password and click on next.

21. Click on Skip

22. Click on Skip.

23. Create the repo by giving the name to it, make sure the repo should be generic or maven as we have to upload the artifacts for the java.

24. Name the repo and click on save and finish.

25. To integrate Jfrog-Artifactory with Jenkins, we have to generate token in the Jfrog-Artifactory.

Click on Generate Access token.

26. Click on Generate.

27. Copy the token.

28.Go to Jenkins and Dashboard-> Manage Jenkins -> Credentials and paste the token that you have copied from the Jfrog-Artifactory and do the rest thing as per the below screenshot and click on Create.

29.Install Docker on EC2 Server where Jenkins is Installed. You can refer to the below command or You can refer to the Github Repo where you just need to run the script and install it on your machine.

GitHub Repository: https://github.com/AmanPathak-DevOps/Scripts-Installation.git

sudo apt update

sudo apt install docker.io

sudo su -

usermod -aG docker jenkins

usermod -aG docker ubuntu

systemctl restart docker

30. Install minikube on your local machine.

Refer to the given link: https://minikube.sigs.k8s.io/docs/start/

You can refer to the Github Repo where you just need to run the script or follow the command to install it on your machine.

GitHub Repository*: [github.com/AmanPathak-DevOps/Scripts-Instal..

sudo apt update

sudo apt upgrade

wget storage.googleapis.com/minikube/releases/la..

chmod +x minikube-linux-amd64

sudo mv minikube-linux-amd64 /usr/local/bin/minikube

31. Install ArgoCD by going on to https://operatorhub.io/operator/argocd-operator and clicking on install. You will get the commands that you have to use to install on your local machine where minikube is installed.

32. Command ran and argoCD operator has been installed

33. Store Docker credentials.

34. Store Github Credentials as well(Personal access token).

Deploy on Kubernetes cluster

35. Go to operatorhub.io and enter on argoCD then click the operator Documentation link

36. Click on usage -> basics and copy the selected script.

37. Create a yml file and paste the script into the file.

38. We are using this script to download the argoCD controller.

Now, the last step to download the argoCD controller which will done by the help of command: kubectl apply -f argocd-basics.yml

39. Here, you can see that the argoCD controller has been created.

40. We need the fourth controller because this is responsible for argoCD UI.

41. We want to run this controller on our local machine. So, to do that I will edit the fourth controller where I will change Type: ClusterIP to NodePort.

42. We are running the same command to get the services but this time there is a difference where we can see the NodePort.

Now, to generate the browser URL, write the command minikube service argocd-server.

And to get the browser URL, write the command minikube service list, which you can check in the below screenshot.

43. I have clicked on the link and you will get this UI, click on advance and then click on

44. You can see the ArgoCD UI login Page.

45. Here, you have to enter the username and password.

The username will be admin and to get the password, refer to the below screenshots.

46. I have got the encrypted password and will copy it.

Now, I have decrypted the password by using the below command

47. Now, I have entered the username and password and logged the argoCD UI.

48. Click on CREATE APPLICATION. You can see this in the above screenshot.

Now, To create the application, you have to enter some configurations, you can check it out in below screenshot and in the end click on CREATE.

49. Now, wait for some minutes. argoCD will deploy the application automatically.

50. Here, I was getting an error because I have written the namespace in the namespace parameter which should be the default.

51. So, let’s correct it.

Final Configuration.

52. After clicking on Save, click on Refresh, and it will start the process again to deploy the application.

And My application has deployed successfully, as you can see in the below screenshot.

53. If you run the command, kubectl get pods. You can see the last two pods that are running which ensures that deployment is successful.

54. So, there were some issues that I have faced and resolved as well.

Final Output of Every Service and tool

The Jenkins Pipeline

Sonarqube Code Analysis

Uploaded Artifacts to Jfrog Artifactory

Deployment using argoCD Controller on Kubernetes Cluster

References:
GitHub Link:

Jenkins Pipeline script, deployment file, Docker file, and the source code link are given below: End-to-End-CICD-Project

Youtube Video Link

youtu.be/JGQI5pkK82w

If you have any queries on your mind, feel free to ask, whether they are related to Jenkins Pipeline scripts or any other process. Follow me for projects and more content on DevOps.

Happy Learning