Monday, April 29, 2024

Docker Swarm Swetup

 https://medium.com/@navidehbaghaifar/how-to-setup-two-nodes-docker-swarm-cluster-ubuntu-118435973c10

https://www.techrepublic.com/article/how-to-deploy-service-docker-swarm-cluster/

Swarm Visualizer:

https://github.com/dockersamples/docker-swarm-visualizer


docker swarm init --advertise-addr <PrivateIP/public ip>


docker swarm join --token SWMTKN-1-5wqxzcs7dkh62waa8zab4az7ja0me6xv0brp2bxma1n4on684o-551fktv3nklleaymxl5bpjky4 3.110.127.12:2377


Thursday, April 11, 2024

Nexus Installation

https://github.com/kishoraswar22/NexusInstallation/blob/main/Sonatype%20Nexus.docx

Scripted Pipeline

 node {
    stage('Build') {
        echo 'Building...'
        git changelog: false, poll: false, url: 'https://github.com/kishoraswar22/spring-boot-war-example.git'
    }
    
    stage('Test') {
        echo 'Testing...'
        // This stage could include commands to run your tests
    }
    
    stage('Deploy') {
        echo 'Deploying...'
        // This stage could include commands to deploy your application
    }

    try {
        echo 'Pipeline execution completed successfully.'
    } catch (err) {
        echo "Pipeline failed: ${err}"
    }
}


      

Jenkins Sonarqube Pipeline

      pipeline {
    agent any
    
    tools {
        maven 'maven3'
        jdk 'jdk11'
    }
    environment{
        SONAR_SCANNER_HOME= tool 'sonar-scanner'
    }

    stages {
        stage('Code Checkout') {
            steps {
                git changelog: false, poll: false, url: 'https://github.com/kishoraswar22/spring-boot-war-example.git'
            }
        }
        stage('Code Build') {
            steps {
                sh 'mvn compile'
            }
        }
        stage('Code Test') {
             
             tools{
                 jdk 'jdk17'
             }
           
                steps {
                withSonarQubeEnv('sonar') {
                   sh '''
                    $SONAR_SCANNER_HOME/bin/sonar-scanner  -Dsonar.projectName=SpringWebapp -Dsonar.projectKey=SpringWebapp \
                    -Dsonar.java.binaries=.
                    
                   
                    
                  '''
                   
               }
                    
               }
            }
        
     
            
        
        stage('Dev Deploy') {
            steps {
                deploy adapters: [tomcat9(credentialsId: 'tomcat_admin', path: '', url: 'http://43.204.32.171:8080')], contextPath: null, war: '**/*.war'
            }
        }
        
        
    }
}

      

Wednesday, April 10, 2024

Tomcat Installation on Linux

Step 1) Create EC2 instance

Step 2) Install java 

# yum install java -y

Step 3)  Download tomcat package

path: /opt/

#wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.87/bin/apache-tomcat-9.0.87.tar.gz

 Step 4)  Extract tomcat package

#cd /opt

#gunzip apache-tomcat-9.0.87.tar.gz

#tar -xvf apache-tomcat-9.0.87.tar

path: /opt/apache-tomcat-9.0.87

Step 5) Comment out below line in context.xml file

Path: /opt/apache-tomcat-9.0.87/webapps/manager/META-INF

vi context.vml

  <!--  <Valve className="org.apache.catalina.valves.RemoteAddrValve"

  allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->

path: /opt/apache-tomcat-9.0.87/webapps/host-manager/META-INF

 <!--  <Valve className="org.apache.catalina.valves.RemoteAddrValve"

  allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->

Step 6) Add tomcat user.

path: /opt/apache-tomcat-9.0.87/conf

#vi  tomcat-users.xml --> add user configuration.

<role rolename="admin-gui"/>

  <role rolename="admin-script"/>

  <role rolename="manager-gui"/>

  <role rolename="manager-status"/>

  <role rolename="manager-script"/>

  <role rolename="manager-jmx"/>

  <user name="admin" password="admin" roles="admin-gui,admin-script,manager-gui,manager-status,manager-script,manager-jmx"/>


Step 7)Start tomcat

path: /opt/apache-tomcat-9.0.87/bin

#./startup.sh

Step 8)Access tomcat using below URL.

http://<public-ip>:8080







Friday, April 5, 2024

Create Sample Java Web Application using Maven and Deploy it on Tomcat Server

Install Maven on windows:

https://phoenixnap.com/kb/install-maven-windows

Install maven on Linux:

Install Maven (Latest From Maven Repo)

Follow the steps given below to install the latest maven package from the official maven repo.

Step 1: Go to Maven Downlaods and get the download link of the latest package.

wget wget https://dlcdn.apache.org/maven/maven-3/3.9.0/binaries/apache-maven-3.9.0-bin.tar.gz

Step 2: Untar the mvn package to the /opt folder.

sudo tar xvf apache-maven-3.9.0-bin.tar.gz -C /opt

Step 3: Create a symbolic link to the maven folder. This way, when you have a new version of maven, you just have to update the symbolic link and the path variables remain the same.

sudo ln -s /opt/apache-maven-3.9.0 /opt/maven


Add Maven Folder To System PATH


To access the mvn command systemwide, you need to either set the M2_HOME environment variable or add /opt/maven to the system PATH.

We will do both by adding them to the profile.d folder. So that every time the shell starts, it gets sourced and the mvn command will be available system-wide.

Step 1: Create a script file named maven.sh in the profile.d folder.

sudo vi /etc/profile.d/maven.sh
Step 2: Add the following to the script and save the file.

export M2_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
Step 3: Add execute permission to the maven.sh script.

sudo chmod +x /etc/profile.d/maven.sh
Step 4: Source the script for changes to take immediate effect.

source /etc/profile.d/maven.sh
Step 5: Verify maven installation

mvn -version

Maven Command To Create Java Web Application:

mvn archetype:generate  -DgroupId=com.companyname.automobile -DartifactId=trucks -DarchetypeArtifactId=maven-archetype-webapp  -DinteractiveMode=false

Maven Command to generate artifact:

First go the location where pom.xml file is placed... and execute below command

#mvn package

Deploy Sample Web application on tomcat server:

Copy  the artifact from target folder and deploy it on tomcat server(tomcat deployment directory is webapps)











Sample Game App Deployment on EKS cluster

 https://padmakshi.medium.com/setting-up-an-eks-cluster-and-deploying-a-game-application-a-step-by-step-guide-08790e0be117