<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Ritik Ranjan's blog]]></title><description><![CDATA[Ritik Ranjan's blog]]></description><link>https://ritik3311.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 18:14:44 GMT</lastBuildDate><atom:link href="https://ritik3311.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Deployed Django Todo List on Kubernetes]]></title><description><![CDATA[Deployments in Kubernetes | Deploy a Django Todo application on Kubernetes
A Deployment provides declarative updates for Pods and ReplicaSets.a Deployment is an object that manages the deployment and scaling of a set of pods.
Steps:

Create EC2 insta...]]></description><link>https://ritik3311.hashnode.dev/deployed-django-todo-list-on-kubernetes</link><guid isPermaLink="true">https://ritik3311.hashnode.dev/deployed-django-todo-list-on-kubernetes</guid><category><![CDATA[#kubernetes #container ]]></category><dc:creator><![CDATA[Ritik Ranjan]]></dc:creator><pubDate>Wed, 01 May 2024 13:16:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1714568149557/0abc89d0-3ce0-4cda-ae32-06d3dd1ad8da.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Deployments in Kubernetes | Deploy a Django Todo application on Kubernetes</p>
<p>A Deployment provides declarative updates for Pods and ReplicaSets.<br />a Deployment is an object that manages the deployment and scaling of a set of pods.</p>
<h2 id="heading-steps">Steps:</h2>
<ol>
<li>Create EC2 instance.<br /> Requirements:-<br /> - 2 CPUs or more<br /> - 2GB of free memory</li>
</ol>
<ol start="2">
<li>Install docker, minikube, kubectl.</li>
</ol>
<ol start="3">
<li>Clone the repository to your local.</li>
</ol>
<ol start="4">
<li><p>Build docker image from a dockerfile given in the github repository. Now verify if the image is created.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1714568849654/1fe2eb01-5a19-4c62-8dc7-5c49e0c3236b.jpeg" alt class="image--center mx-auto" /></p>
</li>
<li><p>Now push this image to the docker hub.</p>
</li>
<li><p>Now create the deployment.yml file. I have mentioned the YAML file image below.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1714568796718/d6cd6387-e259-49ae-8a02-b5bffd7271fd.jpeg" alt class="image--center mx-auto" /></p>
</li>
<li><p>Let's create this deployment. Run this command</p>
<pre><code class="lang-plaintext"> kubectl apply -f deployment.yml
</code></pre>
</li>
<li><p>Let us verify if any pods are created. Run this command</p>
<pre><code class="lang-plaintext"> kubectl get pods
</code></pre>
</li>
<li><p>Let us test if the container we created is working or not so login to kubernetes cluster. Run this command</p>
<pre><code class="lang-plaintext"> minikube ssh
</code></pre>
</li>
<li><p>Then connect to the application using the container's IP. Run this command</p>
<pre><code class="lang-plaintext">curl -L http://&lt;container_ip&gt;:8001
</code></pre>
</li>
</ol>
<p>So the deployment I created and working successfully.<br />Now check the auto-healing and autoscaling features by deleting one pod</p>
<pre><code class="lang-plaintext">kubectl get pods
kubectl delete pod &lt;podname&gt;
</code></pre>
<p>You can observe that one pod is created , proving that those came up automatically after the deletion of pods. This is the feature of k8s: auto-scaling and auto-healing.  </p>
<ol start="11">
<li><p>Let's create service.yaml file. We will use the service NodePort.<br />I have mentioned the service.yaml below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1714568884043/09f669a6-a26d-4108-bac2-ac0e6abc722b.jpeg" alt class="image--center mx-auto" /></p>
<ol start="12">
<li><p>Now let's apply this service to the K8s cluster using the:</p>
<pre><code class="lang-plaintext">kubectl apply -f service.yaml
</code></pre>
</li>
</ol>
</li>
</ol>
<p>    Then verify if the service is created:</p>
<pre><code class="lang-plaintext">    kubectl get service
</code></pre>
<ol start="13">
<li>To access the pod outside we would need service url:</li>
</ol>
<pre><code class="lang-plaintext">minikube service todo-app --url
</code></pre>
<p>This command will give us service url.</p>
<p>Now we can access pod outside the minikube:</p>
<pre><code class="lang-plaintext">curl -L &lt;service url&gt;
</code></pre>
<ol start="14">
<li><p>Now we will edit "/etc/hosts" for host IP allocation :</p>
<pre><code class="lang-plaintext">sudo vim /etc/hosts
</code></pre>
<p>Now paste sevice IP ( 192. 168.49.2 ) &lt;space&gt; &lt;give a name to your IP&gt;</p>
<pre><code class="lang-plaintext">192. 168.49.2 todo-app . com
</code></pre>
<p>Now check todo-app. com :</p>
<pre><code class="lang-plaintext">curl -L http: // todo-app. com: 30007
</code></pre>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[Setting Up a Local GitLab Runner on Linux machine and Configuring  the runner on Gitlab Pipeline.]]></title><description><![CDATA[What is Gitlab Runner ?
GitLab Runner is an application that works with GitLab CI/CD to run jobs in a pipeline.
How to install Gitlab-runner on linux (Ubuntu) 64-bit machine ?
Step 1. Run this command on your Linux terminal:
sudo curl -L --output /us...]]></description><link>https://ritik3311.hashnode.dev/setting-up-a-local-gitlab-runner-on-linux-machine-and-configuring-the-runner-on-gitlab-pipeline</link><guid isPermaLink="true">https://ritik3311.hashnode.dev/setting-up-a-local-gitlab-runner-on-linux-machine-and-configuring-the-runner-on-gitlab-pipeline</guid><category><![CDATA[gitlab-runner]]></category><dc:creator><![CDATA[Ritik Ranjan]]></dc:creator><pubDate>Sun, 10 Mar 2024 10:07:50 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1710065059534/2f9dfb3e-8280-46bf-9169-c1b4e79b65a5.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-what-is-gitlab-runner"><strong>What is Gitlab Runner ?</strong></h3>
<p>GitLab Runner is an application that works with GitLab CI/CD to run jobs in a pipeline.</p>
<h3 id="heading-how-to-install-gitlab-runner-on-linux-ubuntu-64-bit-machine"><strong>How to install Gitlab-runner on linux (Ubuntu) 64-bit machine ?</strong></h3>
<h3 id="heading-step-1-run-this-command-on-your-linux-terminal">Step 1. Run this command on your Linux terminal:</h3>
<pre><code class="lang-plaintext">sudo curl -L --output /usr/local/bin/gitlab-runner https://s3.dualstack.us-east-1.amazonaws.com/gitlab-runner-downloads/latest/binaries/gitlab-runner-linux-amd64
</code></pre>
<h3 id="heading-step-2-give-it-permissions-to-execute">Step 2. Give it permissions to execute:</h3>
<pre><code class="lang-plaintext">sudo chmod +x /usr/local/bin/gitlab-runner
</code></pre>
<h3 id="heading-step-3create-a-gitlab-ci-user">Step 3.Create a GitLab CI user:</h3>
<pre><code class="lang-plaintext">sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
</code></pre>
<h3 id="heading-step-4install-and-run-as-service">Step 4.Install and run as service:</h3>
<pre><code class="lang-plaintext">sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner

sudo gitlab-runner start
</code></pre>
<h3 id="heading-step-5generate-runner-authentication-token">Step 5.Generate runner authentication token</h3>
<p><strong>How to generate runner authentication token on gitlab ?</strong></p>
<p>To create an instance runner:</p>
<ol>
<li><p>On the left sidebar, at the bottom, select <strong>Admin Area</strong>.</p>
</li>
<li><p>Select <strong>CI/CD &gt; Runners</strong>.</p>
</li>
<li><p>Select <strong>New instance runner</strong>.</p>
</li>
<li><p>Select the operating system where GitLab Runner is installed.</p>
</li>
<li><p>In the <strong>Tags</strong> section, in the <strong>Tags</strong> field, enter the job tags to specify jobs the runner can run. If there are no job tags for this runner, select <strong>Run untagged</strong>.</p>
</li>
<li><p>Optional. In the <strong>Runner description</strong> field, to add a runner description that displays in GitLab, enter a runner description.</p>
</li>
<li><p>Optional. In the <strong>Configuration</strong> section, add additional configurations.</p>
</li>
<li><p>Select <strong>Create runner</strong>.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710061320271/f3f1e3d5-7ee8-4a55-b42e-555eaebcd686.avif" alt class="image--center mx-auto" /></p>
</li>
</ol>
<h3 id="heading-step-6-register-a-runner">Step 6. Register a runner.</h3>
<p>Prerequisites:</p>
<ul>
<li><p>Obtain a runner authentication token. You can either:</p>
<ul>
<li>Create a <a target="_blank" href="https://docs.gitlab.com/ee/ci/runners/runners_scope.html#create-a-shared-runner-with-a-runner-authentication-token">shared</a>, <a target="_blank" href="https://docs.gitlab.com/ee/ci/runners/runners_scope.html#create-a-group-runner-with-a-runner-authentication-token">group</a>, or <a target="_blank" href="https://docs.gitlab.com/ee/ci/runners/runners_scope.html#create-a-project-runner-with-a-runner-authentication-token">project</a> runner.</li>
</ul>
</li>
</ul>
<pre><code class="lang-plaintext">sudo gitlab-runner register
</code></pre>
<p>Enter Gitlab instance URL :- https://gitlab.com/</p>
<p>Then Enter Gitlab <strong>Runner Authentication Token</strong> and select <strong>executor.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710061337464/0285c14a-87f2-4bcc-8214-187b78eeb6af.avif" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710061387168/429767fd-061e-4d8b-a981-625bc51e348c.avif" alt class="image--center mx-auto" /></p>
<p>Please follow this document to setup <strong>executors</strong> during registering a runner**.**</p>
<p><a target="_blank" href="https://docs.gitlab.com/runner/executors/">https://docs.gitlab.com/runner/executors/</a></p>
<h3 id="heading-step-7-how-to-configure-gitlab-runner-on-gitlab-pipeline"><strong>Step 7</strong>. <strong>How to configure gitlab-runner on gitlab pipeline ?</strong></h3>
<p>When you register a runner, you can add <strong>tags</strong> to it.</p>
<p>When a CI/CD job runs, it knows which runner to use by looking at the assigned tags. Tags are the only way to filter the list of available runners for a job.</p>
<p>For example, if a runner has the <code>build</code> <strong>tag</strong>, you would add this code to your project’s <code>.gitlab-ci.yml</code> file:</p>
<p>In gitlab project Navigate to <strong>gitlab.ci.yml</strong> configure this command:</p>
<pre><code class="lang-plaintext">tags:
 - Build
</code></pre>
<p><strong>Example:-</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710060777835/4dedd77b-c300-4ce8-b2c3-a54a0b2ceb66.png" alt /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710060860032/2bd3d627-dae7-4654-a0f1-5f5785a2870c.png" alt class="image--center mx-auto" /></p>
<p><strong><mark>Important note:</mark></strong> Tag should be same in runner and <a target="_blank" href="http://gitlab.ci">gitlab.ci</a>.yml.</p>
]]></content:encoded></item><item><title><![CDATA[Configuring Jenkins Declarative Pipeline with AWS Cloud]]></title><description><![CDATA[Step 1: Start an EC2 Server with Enabled Ports
To begin, launch an EC2 server and make sure to enable inbound rules for ports 22, 8080, and 8000. These ports are crucial for successful configuration.

Step 2: Connect to the Server via SSH
Next, estab...]]></description><link>https://ritik3311.hashnode.dev/configuring-jenkins-declarative-pipeline-with-aws-cloud</link><guid isPermaLink="true">https://ritik3311.hashnode.dev/configuring-jenkins-declarative-pipeline-with-aws-cloud</guid><category><![CDATA[jenkins-declarative-pipeline]]></category><category><![CDATA[Docker]]></category><category><![CDATA[AWS]]></category><dc:creator><![CDATA[Ritik Ranjan]]></dc:creator><pubDate>Fri, 14 Jul 2023 10:23:10 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1689330423345/a06427e1-ffeb-4ac7-8d2c-ebc3116e1563.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-step-1-start-an-ec2-server-with-enabled-ports"><strong>Step 1: Start an EC2 Server with Enabled Ports</strong></h3>
<p>To begin, launch an EC2 server and make sure to enable inbound rules for ports 22, 8080, and 8000. These ports are crucial for successful configuration.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689328018441/8c6b02cf-0772-4605-8c90-47db92fa3264.jpeg" alt class="image--center mx-auto" /></p>
<h3 id="heading-step-2-connect-to-the-server-via-ssh"><strong>Step 2: Connect to the Server via SSH</strong></h3>
<p>Next, establish a connection to the server using the SSH command. This will allow you to interact with the server's command line.</p>
<h3 id="heading-step-3-install-java-jdk-and-jenkins-using-shell-script"><strong>Step 3: Install Java JDK and Jenkins Using Shell Script</strong></h3>
<p>To install Java JDK and Jenkins, follow these steps:</p>
<ol>
<li><p>Install Java JDK</p>
<pre><code class="lang-plaintext"> sudo apt-get install openjdk-17-jdk
</code></pre>
</li>
<li><p>Install Jenkins</p>
<pre><code class="lang-plaintext"> curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
   /usr/share/keyrings/jenkins-keyring.asc &gt; /dev/null
 echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
   https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
   /etc/apt/sources.list.d/jenkins.list &gt; /dev/null
 sudo apt-get update
 sudo apt-get install jenkins
</code></pre>
</li>
<li><p>Grant Jenkins access to build and run Docker images:</p>
<pre><code class="lang-plaintext"> sudo usermod -aG docker jenkins
 sudo reboot
</code></pre>
</li>
<li><p>Access Jenkins by entering your EC2 instance's public IP followed by port 8080 in your browser. Obtain the initialAdminPassword by running:</p>
<pre><code class="lang-plaintext"> sudo cat /var/lib/jenkins/secrets/initialAdminPassword
</code></pre>
<p> Copy and paste the password in the provided tab and install all the necessary plugins.</p>
</li>
<li><p>Install Docker</p>
<pre><code class="lang-plaintext"> Sudo apt-get install docker.io
</code></pre>
</li>
</ol>
<h3 id="heading-step-4-creating-a-declarative-pipeline"><strong>Step 4: Creating a Declarative Pipeline</strong></h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689328665532/fb4f0943-39f8-4c12-a5f5-17a8adf3eacf.jpeg" alt class="image--center mx-auto" /></p>
<p>Now, let's create a declarative pipeline in Jenkins:</p>
<ol>
<li><p>Click on "New Item" and name it "my-note-app-cicd-pipeline".</p>
</li>
<li><p>Under the configuration settings, select the GitHub project and provide the repository URL:</p>
<pre><code class="lang-plaintext"> https://github.com/LondheShubham153/django-notes-app
</code></pre>
<p> Set the name to "Django notes app".</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689328803386/88ecf7b0-7fb5-4861-a340-1473c4e6490f.jpeg" alt class="image--center mx-auto" /></p>
</li>
<li><p>In the "Pipeline" section, choose "Pipeline Script" and add the following script:</p>
<pre><code class="lang-plaintext"> pipeline{

     agent any

         stages{
             stage("Cloning Code"){
                 steps{
                     echo "Cloning the code from github"
                     git url: "https://github.com/LondheShubham153/django-notes-app.git" , branch: "main"
                 }
             }
             stage("Build Docker Image"){
                 steps{
                     echo "Building Docker Image"
                     sh "docker build -t ritik3311/django-notes-app:0.1 ."
                 }
             }

             stage("Push to Dockerhub"){
                 steps{
                     echo "Pushing Docker image to Dockerhub"
                     withCredentials([usernamePassword(credentialsId:"dockerhub" ,passwordVariable:"dockerhubPass", usernameVariable:"dockerhubUser")]){
                         sh "docker login -u ${env.dockerhubUser} -p ${env.dockerhubPass}"
                         sh "docker push ritik3311/django-notes-app:0.1"
                     }
                 }
             }

             stage("Deploy"){
                 steps{
                     echo "Deploying Django Notes App on AWS EC2"
                     sh "docker run -d -p 8000:8000 ritik3311/django-notes-app:0.1"
                 }
             }
         }
 }
</code></pre>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689329527535/c788855c-b6cc-420d-89b3-e3b07e81b89e.jpeg" alt class="image--center mx-auto" /></p>
<h3 id="heading-before-building-make-sure-to-follow-these-additional-steps"><strong>Before building, make sure to follow these additional steps:</strong></h3>
<ol>
<li><p>Add DockerHub credentials in the global credentials section with the ID as "dockerHub" along with the username and password.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689329182511/09bbe49d-da8e-46c5-a243-4f8efdbbb89b.jpeg" alt class="image--center mx-auto" /></p>
</li>
</ol>
</li>
</ol>
<p>Once everything is set up, you can manually trigger the pipeline by clicking the build button in the Jenkins interface.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689329362187/6313e624-bd26-4f57-b77d-0c6f0b7cdee9.jpeg" alt class="image--center mx-auto" /></p>
<h1 id="heading-congratulations-our-django-notes-app-is-successfully-deployed">Congratulations <strong>Our Django Notes App is Successfully Deployed!</strong></h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1689329485738/e2067e4a-8737-499d-924e-c4b0d9bc2003.jpeg" alt class="image--center mx-auto" /></p>
<p>Congratulations! Our Notes App is now deployed and ready to use. Enjoy the benefits of automation and continuous integration.</p>
]]></content:encoded></item><item><title><![CDATA[Build a CI/CD Pipeline using Jenkins, SonarQube, Docker and AWS]]></title><description><![CDATA[We'll use Jenkins, SonarQube, Docker, and AWS to build an automated CI/CD pipeline for your web application. This pipeline will build, test, analyze, and deploy your project to your AWS EC2 instance.
Creating EC2 Instances
Create two EC2 Instances
1s...]]></description><link>https://ritik3311.hashnode.dev/build-a-cicd-pipeline-using-jenkins-sonarqube-docker-and-aws</link><guid isPermaLink="true">https://ritik3311.hashnode.dev/build-a-cicd-pipeline-using-jenkins-sonarqube-docker-and-aws</guid><category><![CDATA[Devops]]></category><category><![CDATA[ Jenkins, DevOps]]></category><category><![CDATA[Jenkins]]></category><category><![CDATA[Docker]]></category><category><![CDATA[AWS]]></category><dc:creator><![CDATA[Ritik Ranjan]]></dc:creator><pubDate>Wed, 05 Jul 2023 10:27:54 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1688549664394/70f82b14-c221-4112-a3e3-0913eb9b6885.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We'll use Jenkins, SonarQube, Docker, and AWS to build an automated CI/CD pipeline for your web application. This pipeline will build, test, analyze, and deploy your project to your AWS EC2 instance.</p>
<h1 id="heading-creating-ec2-instances"><strong>Creating EC2 Instances</strong></h1>
<p>Create two EC2 Instances</p>
<p>1st for Jenkins and Docker</p>
<p>2nd for SonarQube</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688549755066/c5ceb807-8e24-4ebd-bf46-0c9fa1ee63ec.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-setting-security-group"><strong>Setting Security Group</strong></h2>
<p>Under the security details for instance, click on security groups and then click on "<strong>Edit Inbound rules"</strong>.</p>
<p>Generally, there is only one rule present for port 22 for SSH.<br />We have to add some more rules as:</p>
<p>In 1st Instance</p>
<ul>
<li><p>Port 8080, for Jenkins</p>
</li>
<li><p>Port 8000, for exposing our web application</p>
<p>  <strong><em>Set the source to "Anywhere-IPv4" i.e. 0.0.0.0/0</em></strong></p>
<p>  Now, click on save rules to save your changes.</p>
</li>
</ul>
<p>In 2nd Instance</p>
<ul>
<li><p>Port 9000, for SonarQube</p>
<p>  <strong><em>Set the source to "Anywhere-IPv4" i.e. 0.0.0.0/0</em></strong></p>
<p>  Now, click on save rules to save your changes</p>
</li>
</ul>
<h1 id="heading-setting-up-instances"><strong>Setting up Instances</strong></h1>
<p>Now install Jenkins and Docker on 1st instance and</p>
<p>Install SonarQube on 2nd instance</p>
<p>To install Jenkins, Docker and SonarQube on instances, firstly you have to ssh to your instance in your terminal by selecting that instance and then clicking on connect.</p>
<p>Now install Jenkins <a target="_blank" href="https://www.jenkins.io/doc/book/installing/linux/">https://www.jenkins.io/doc/book/installing/linux/</a></p>
<p>Now install Docker "sudo apt-get install docker.io"</p>
<p>Now, copy the public IPv4 address of Jenkins, paste it into your browser, and put the port number 8080 after it in the format i.e &lt;ip_address&gt;:8080</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688550443457/d88ee261-04eb-45f4-bedf-7ec054e050fb.jpeg" alt class="image--center mx-auto" /></p>
<p><strong><em>To unlock jenkins paste the secret key to Administrator password, you can get it with the following command:</em></strong></p>
<pre><code class="lang-plaintext">sudo cat /var/lib/jenkins/secrets/initialAdminPassword
</code></pre>
<p>After unlocking Jenkins click on <code>"Install suggested plugins"</code> and then provide the basic details on the <mark>"Create First Admin User" page</mark> and get to the Jenkins dashboard after completing all the required steps.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688550598294/73183346-2dd1-47af-b27d-bfbae3448aed.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-installing-sonarqube-on-2nd-ec2-instance"><strong>Installing SonarQube on 2nd EC2 Instance</strong></h2>
<p>To install SonarQube to your instance run the following command in your terminal:</p>
<pre><code class="lang-plaintext">sudo apt update
sudo apt install openjdk-17-jre
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-10.0.0.68432.zip
</code></pre>
<p>To unzip the zip file, run the following command:</p>
<pre><code class="lang-plaintext">sudo apt install unzip
unzip sonarqube-10.0.0.68432.zip
</code></pre>
<p>Now, head over to the Linux directory to execute the installation file:</p>
<pre><code class="lang-plaintext">cd /home/ubuntu/sonarqube-10.0.0.68432/bin/linux-x86-64
./sonar.sh console
#this will start the SonarQube on port 9000
</code></pre>
<h1 id="heading-integrating-sonarqube-for-jenkins"><strong>Integrating SonarQube For Jenkins</strong></h1>
<p>Copy the Public IP of SonarQube and paste it on the browser and put port 9000 after it in such format &lt;public IP&gt;:9000<br /><mark>For ex:- 54.174.102.233 :9000</mark></p>
<p>Now, login with username - admin &amp; password - admin</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688550969158/b84231ed-6e52-4b34-8880-b713686ebbf5.jpeg" alt class="image--center mx-auto" /></p>
<p>After login and changing your password, you'll land on the SonarQube dashboard.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688551010060/b2cf44ba-bb12-44df-a88f-8c8dca87eac2.jpeg" alt class="image--center mx-auto" /></p>
<p>Click "Manually" icon.</p>
<p>Give a name to your Project and provide the name of the branch you want to analyze.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688551184123/7ab9ebfc-b518-42ac-9e2f-948860835b97.jpeg" alt class="image--center mx-auto" /></p>
<p>Now, we have many options to select for Continuous Integration tools. For now, we will move forward with Jenkins.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688551036237/bc253b77-6246-4988-8a95-45f09a402ef1.jpeg" alt class="image--center mx-auto" /></p>
<p>On the next page, we'll choose GitHub for the DevOps platform.</p>
<p>Now, it will ask for configuration. Click <code>continue</code> up to the 3rd step and select <mark>other</mark> as we are going to deploy our application. Copy the code that it is providing and save it somewhere safe as we will going to use it later.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688551349165/e914fc0c-b0a4-47a6-b7c1-a40ecec0a3c0.jpeg" alt class="image--center mx-auto" /></p>
<p>Click on <mark>Finish this tutorial</mark> to save it, and after saving it move to <strong>My Accounts&gt;Security&gt;Generate Tokens</strong></p>
<p>Now, create a Token for integrating with Jenkins.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688551405311/043273d4-acc4-4c5c-9bcb-8d40ec12e44d.jpeg" alt class="image--center mx-auto" /></p>
<p>Copy the token and save it somewhere safe, as we are going to use it later.</p>
<h1 id="heading-now-open-jenkins">Now open Jenkins</h1>
<p><strong><em>Now, head over to Jenkins Dashboard, by pasting the Public IP of Jenkins and put port 8080 after it in such fromat <mark>&lt;Public IP&gt;:8080</mark></em></strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688551639443/431c8bdf-2b50-4c91-a749-c47e9ea1e360.jpeg" alt class="image--center mx-auto" /></p>
<p>We have to install some plugins on Jenkins for setting up SonarQube.</p>
<p>On Jenkins Dashboard, click on <strong><mark>Manage Jenkins&gt;&gt;Manage Plugins&gt;&gt;Available Plugins</mark></strong></p>
<p>Now, in Available Plugins, search for <strong>SonarQube Scanner</strong> <strong>.</strong><br />After selecting them click on "<strong>Install without restart".</strong></p>
<p>On Jenkins Dashboard click on <strong><mark>Manage Jenkins&gt;&gt;Global Tool Configuration</mark></strong> and search for <strong>SonarQube Scanner</strong> under it.</p>
<p>After clicking on "<strong>Add SonarQube Scanner"</strong>, give a suitable name to it and check on <strong>Install automatically</strong> for its installation, and then <strong>save it</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688551657843/fc6b3d74-b447-4a8b-8e76-a12257fd3acb.jpeg" alt class="image--center mx-auto" /></p>
<p>Now, on <strong>Manage Jenkins&gt;&gt;Configure system</strong>, search for <strong>SonarQube servers</strong> and click on "<strong>Add SonarQube"</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688551688890/9517655c-ecda-4b47-ad00-21cd7455bf4c.jpeg" alt class="image--center mx-auto" /></p>
<p>Name it accordingly, copy the Public IP of SonarQube and paste it, and put port 9000 after it in such format <mark>http://&lt;Public IP&gt;:9000</mark> . Apply &amp; save it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688551738013/7a8f180c-ff77-4384-aa70-b85267c85973.jpeg" alt class="image--center mx-auto" /></p>
<h1 id="heading-create-a-jenkins-job-for-deploying-our-web-application"><strong>Create a Jenkins Job for Deploying our Web Application</strong></h1>
<p>On the Jenkins Dashboard, <mark>click on </mark> <strong><mark>"Create a Job".</mark></strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688551794640/c1aec3d5-bd47-4767-ad99-4c3538398f7a.jpeg" alt class="image--center mx-auto" /></p>
<p>Give it a name, select the type of pipeline you want to create, and then click <strong>"OK"</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688551874427/d717b3c2-5d58-4db3-8815-ef6fd4e3f6a9.jpeg" alt class="image--center mx-auto" /></p>
<p>Under the configuration setting, select <strong>"Git"</strong> for <strong>Source Code Management</strong>. <mark>Copy and paste the git link from the GitHub repository.</mark></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688551917117/5d3292cb-4e45-4d50-8313-4fbc71e18e9d.jpeg" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688551939070/49a87349-b273-4405-8d43-493c9329fabb.jpeg" alt class="image--center mx-auto" /></p>
<p>Specify the branch you want to build and deploy.</p>
<h2 id="heading-configuring-pipeline-for-sonarqube"><strong>Configuring Pipeline for SonarQube</strong></h2>
<p>Search for <strong>Build Steps</strong> and click on <strong>"Add build step"</strong> and select <strong>"SonarQube Scanner".</strong></p>
<p>Now, paste the code in the <strong>Analysis Properties</strong> field, which you copied from SonarQube which we kept saved.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688552053458/47b4f98e-49f4-4c21-8044-e42bcc5a9668.jpeg" alt class="image--center mx-auto" /></p>
<p>Apply and save it, and head over to J<strong>enkins Dashboard&gt;&gt;Manage Plugins&gt;&gt;Configure System</strong> and add server authentication token for SonarQube by clicking on <strong>"Add"</strong>, and selecting <strong>Jenkins</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688552112649/b77eefca-0159-4190-8ae7-b640507b6d10.jpeg" alt class="image--center mx-auto" /></p>
<p>Change Kind to <strong>secret text</strong> and paste the secret token key which we copied earlier and saved it. Give it an ID name accordingly.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688552158468/4c309760-93a8-479d-b15a-c9f65468bcc0.jpeg" alt class="image--center mx-auto" /></p>
<p>Now, for the <strong>server authentication token</strong>, from the scroll bar select the ID name, the one which you just created.</p>
<h2 id="heading-configuring-pipeline-for-docker"><strong>Configuring Pipeline for Docker</strong></h2>
<p>U<strong>nder the CI-CD Pipeline</strong> on Jenkins Dashboard click on "<strong>Configure</strong>", search for <strong>Build Steps,</strong> and select <strong>Execute shell</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688552441641/d3981222-f550-4ff9-859c-319578347db4.jpeg" alt class="image--center mx-auto" /></p>
<p><mark>Apply and save it.</mark></p>
<p>Now, under the CI-CD Pipeline, click <strong>"Build Now".</strong><br />If everything works fine, then you'll see success. Here is our live website working on Port 8000 on Docker.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688552619068/5560f776-b136-48e6-b1a9-0424acd803c0.jpeg" alt class="image--center mx-auto" /></p>
<p>Now check SonarQube</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1688552316722/335bc086-0174-4b8e-bf18-6b65de4780f1.jpeg" alt class="image--center mx-auto" /></p>
]]></content:encoded></item></channel></rss>