- Provision an EC2 instance on AWS, opting for the t2.large configuration that supports 2 CPUs and 8GB of RAM. This ensures ample computational power and memory resources to support our Jenkins project's requirements effectively.
- Clone the repository from its Git source located at https://github.com/bharatrajtj/jenkins.
- Install Java, a prerequisite for Jenkins' operation. This ensures the availability of the Java Runtime Environment (JRE), essential for executing Jenkins and its associated processes smoothly.
- Execute the Jenkins installation script to commence the setup process. This script initiates the installation procedure, configuring Jenkins' core components and preparing the environment for subsequent configuration steps.
- By default, Jenkins operates its HTTP service on port 8080. This configuration allows for access to the Jenkins web interface.
- Establish inbound traffic rules within the AWS security group associated with your EC2 instance to facilitate communication on port 8080.
- Access the initial administrative password for Jenkins by executing the command cat /var/lib/jenkins/secrets/initialAdminPassword within your EC2 terminal. This step retrieves the required credential, enabling you to proceed with the initial setup and configuration of your Jenkins instance.
- Upon completing the installation of the required plugins and finalizing the setup process, you will be directed to the Jenkins Dashboard. This central hub serves as the control panel for managing your Jenkins environment, offering access to various features and functionalities essential for orchestrating automation tasks and pipelines effectively.
- Navigate to the "New Item" option within the Jenkins interface to initiate the creation of a new Jenkins Pipeline. Opt for the Pipeline project type to configure and manage your pipeline's workflow, facilitating streamlined automation and continuous integration within your development environment.
- Choose "Pipeline script from SCM" as the configuration option for your Jenkins Pipeline. Given that Git serves as our Source Code Manager (SCM) for this project, specify the repository URL as https://github.com/bharatrajtj/jenkins.
- Specify the "Script Path" as the directory path within the repository where the Jenkinsfile is located.
- Navigate to "Manage Jenkins" > "Manage Plugins" > "Available" tab, and search for the "Docker Pipeline" plugin. Proceed to install this plugin to enable the utilization of Docker containers as agents within your Jenkins environment.
- Navigate to "Manage Jenkins" > "Manage Plugins" > "Available" tab, and search for the "SonarQube Scanner" plugin. Install this plugin to enable seamless integration of SonarQube for code quality inspection within your Jenkins environment.
- Add new user named SonarQube in the EC2 instance and switch to the new user
- Download the sonar zip file wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.4.0.54424.zip
- To unzip the downloaded SonarQube zip file, you'll need to have the unzip utility installed on your system. You can install it using the apt package manager.
- Switch to sonarqube user and run unzip *
- Grant permission to the folders
- Go to the path depending upon your instance architecture
- Run ./sonar.sh start to execute your SonarQube server
- Configure inbound rules within your EC2 instance's security group to allow traffic from port 9000, the default port for SonarQube. This step ensures that incoming traffic on port 9000 is permitted, enabling access to the SonarQube application.
- Access the SonarQube server page by entering your EC2 instance's IP address followed by ":9000" in your web browser's address bar. Upon reaching the SonarQube server page, use the default credentials to log in:
Username: admin
Password: admin
- In the SonarQube web interface, navigate to "My Account" and then to "Security" settings. Locate the option to generate an access token, found within the user profile or security settings.
This token will be used to configure the integration between SonarQube and Jenkins. Ensure you securely store the token as it grants access to SonarQube resources.
- In Jenkins Page go to ManageJenkins>Credentials>System>GlobalCredentials>AddCredentials to enter sonarqube token
- Install Docker in root user in your EC2 terminal
- Grant Jenkins and Ubuntu user permission to access docker daemon and restart docker
- Restart Jenkins to make sure the plugins installed will function properly. To restart jenkins after port number enter /restart
- Run Minikube on your local machine through docker as the driver
- Install the ArgoCD operator to streamline the lifecycle management of the Kubernetes controller, ArgoCD, within your Minikube environment. Utilize the resources available at https://operatorhub.io/operator/argocd-operator to access and deploy the operator.
- Configure DockerHub and GitHub credentials within Jenkins to facilitate seamless integration with these platforms.
- For GitHub, navigate to "Settings," then "Personal access tokens," and proceed to "Generate New token (classic)" to create a new token. This token will serve as the authentication mechanism for Jenkins to interact with your GitHub repositories securely.
- Within Jenkins, employ the "Secret text" type to configure GitHub credentials securely. After creating the credentials, ensure to restart Jenkins to enact the changes and enable seamless authentication for GitHub interactions within your Jenkins environment.
- Build the Jenkins Pipeline
- SonarQube report for code analysis
- Docker registry where the image generated has been pushed
- Update the docker image name in the deployment yml
- Create a yml file in your local machine and apply this content to install ArgoCD controller
- Make sure the argocd operator pods are created in MiniKube
- Edit the service type from Cluster IP to NodePort for example-argocd-server
- Get URL to access the service through web
- Get the password to argocd account by getting into argocd-cluster secret
- Decode your base 64 encrypted secret
- Enter the credentials in ArgoCD web interface
- Create application in argocd and configure required information
- The spring boot application has been deployed in our minikube cluster through argocd
- Edit the deployment image to nginx in the minikube
- ArgoCD recognize that the image in manifest yml is different from the image executing on minikube cluster it starts to rollback to image mentioned in the manifest
Top comments (0)