Coder Social home page Coder Social logo

devops-fully-automated's Introduction

Jenkins CI/CD Pipeline Project Architecture (Java Web Application)

CompleteCICDProject!

Jenkins Complete CI/CD Pipeline Environment Setup

CICD Applications setup

  1. GitHub setup

    Fork GitHub Repository by using the existing repo "devops-fully-automated" (https://github.com/RichieJJ/devops-fully-automated)

  2. Jenkins/Maven/Ansible
  3. SonarQube
  4. Nexus
  5. EC2 (Dev/Stage/Prod)
  6. Prometheus
  7. Grafana
  8. Slack
    • Join the slack channel https://join.slack.com/t/devopsfullyau-r0x2686/shared_invite/zt-1nzxt7e9z-ChDASWBOysUpa3tH5gi95A
    • Join into the channel "#team-devops"
    • Generate Team Subdomain & Integration Token Credential ID (workspace --> channel --> drop-down --> integrations --> Add an App --> Jenkins CI --> Click on Install/View --> Configuration --> Add to Slack --> Select Channel #team-devops --> Store Team subdomain & Integration Token Credential ID which can be used later on)

Jenkins setup

  1. Access Jenkins

    Copy your Jenkins Public IP Address and paste on the browser = ExternalIP:8080

    • Login to your Jenkins instance using your Shell (GitBash or your Mac Terminal)
    • Copy the Path from the Jenkins UI to get the Administrator Password
      • Run: sudo cat /var/lib/jenkins/secrets/initialAdminPassword
      • Copy the password and login to Jenkins
    • Plugins: Choose Install Suggested Plugings
    • Provide
      • Username: admin
      • Password: admin
      • Name and Email can also be admin. You can use admin all, as its a poc.
    • Continue and Start using Jenkins
  2. Plugin installations:

    • Click on "Manage Jenkins"
    • Click on "Plugin Manager"
    • Click "Available"
    • Search and Install the following Plugings "Install Without Restart"
      • SonarQube Scanner
      • Prometheus metrics
      • CloudBees Disk Usage Simple
      • Slack Notification
    • Once all plugins are installed, select Restart Jenkins when installation is complete and no jobs are running
  3. Pipeline creation

    • Click on New Item
    • Enter an item name: app-cicd-pipeline & select the category as Pipeline
    • Now scroll-down and in the Pipeline section --> Definition --> Select Pipeline script from SCM
    • SCM: Git
    • Repositories
      • Repository URL: FILL YOUR OWN REPO URL (that we created by importing in the first step)
      • Branch Specifier (blank for 'any'): */main
      • Script Path: Jenkinsfile
    • Save
  4. Global tools configuration:

    • Click on Manage Jenkins --> Global Tool Configuration

      JDK --> Add JDK --> Make sure Install automatically is enabled -->

      Note: By default the Install Oracle Java SE Development Kit from the website make sure to close that option by clicking on the image as shown below.

      JDKSetup!

    • Maven --> Add Maven --> Make sure Install automatically is enabled --> Install from Apache --> Fill the below values

      • Name: localMaven
      • Version: Keep the default version as it is
  5. Credentials setup(SonarQube, Nexus, Ansible, Slack):

    • Click on Manage Jenkins --> Manage Credentials --> Global credentials (unrestricted) --> Add Credentials

      1. SonarQube secret token (sonarqube-token)
        • Kind: Secret text : Generating SonarQube secret token - Login to your SonarQube server (http://sonarserver-public-ip:9000, with the credentials username: admin & password: admin) - Click on profile --> My Account --> Security --> Tokens - Generate Tokens: Fill jenkins-token - Click on Generate - Copy the token
        • Secret: Fill the secret token value that we have created on the SonarQube server
        • ID: sonarqube-token
        • Description: sonarqube-token
        • Click on Create
      2. Nexus username & password (nexus-credentials)
        • Kind: Username with password
        • Username: admin
        • Enable Treat username as secret
        • Password: admin
        • ID: nexus-credentials
        • Description: nexus-credentials
        • Click on Create
      3. Ansible deployment server username & password (ansible-deploy-server-credentials)
        • Kind: Username with password
        • Username: ansadmin
        • Enable Treat username as secret
        • Password: ansadmin
        • ID: ansible-deploy-server-credentials
        • Description: ansible-deploy-server-credentials
        • Click on Create
      4. Slack secret token (slack-token)
        • Kind: Secret text
        • Secret: Place the Integration Token Credential ID (Note: Generate for slack setup)
        • ID: slack-token
        • Description: slack-token
        • Click on Create
  6. Configure system:

    1)  - Click on Manage Jenkins --> Global Tool Configuration
        - Go to section SonarQube servers --> **Add SonarQube **
        - Name: **SonarQube**
        - Server URL: http://REPLACE-WITH-SONARQUBE-SERVER-PRIVATE-IP:9000          (replace SonarQube privat IP here)
        - Click on Save    
    
    2)  - Click on Manage Jenkins --> Configure System
        - Go to section Prometheus
        - Collecting metrics period in seconds: **15**
        - Click on Save
    
    3)  - Click on Manage Jenkins --> Configure System
        - Go to section Slack
        - Use new team subdomain & integration token credentials created in the above slack joining step
        - Workspace: **Replace with Team Subdomain value** (created above)
        - Credentials: select the slack-token credentials (created above) 
        - Default channel / member id: #general
        - Click on Save  
    

SonarQube setup

Copy your SonarQube Public IP Address and paste on the browser = ExternalIP:9000

  1. Jenkins webhook in SonarQube:

Nexus setup

Copy your Nexus Public IP Address and paste on the browser = http:://NexusServerExternalIP:8081

  1. Setting up password:

    • SSH into Nexus server
    • Execute sudo cat /opt/nexus/sonatype-work/nexus3/admin.password
    • Copy the default password
    • Now login into Nexus console with the username: admin & password (copied from the SSH above)
    • Once signed in fill the below details in the setup wizard
    • New password: admin
    • Confirm password: admin
    • Configure anonymus access: Select Disable anonymus access
    • Click on Finish
  2. Creating a new maven repository for project:

    • Once login to the Nexus server, click on Settings icon --> Repository --> Repositories
    • Click on Create repository
    • Select maven2(group)
    • Name: maven_project
    • Scroll-down to Group section & select all the available repositories (maven-snapshots, maven-public, maven-releases, maven-central) as members Hint: You can select one repo at a time and click on > symbol to add the repo as group member.
    • Once all the repositories are added to the group, click on Create repository

Ansible setup

Nothing to be done for the Ansible setup as the jenkins server already created with the ansible instllation and the deployment servers have the required ansadmin users for the deployment.

Prometheus setup

Copy your Prometheus Public IP Address and paste on the browser = http:://PrometheusServerExternalIP:9090

Note: Prometheus setup is also full automated, so just verifying the health of servers are required

  1. Checking targets health:

    • Once prometheus accessed --> Status --> Targets (for the health checkup)
    • Once prometheus accessed --> Status --> Configuration (for the config file verification)

Grafana setup

Copy your Grafana Public IP Address and paste on the browser = http:://GrafanaServerExternalIP:3000

  1. Setting up username & password:

    • Once the UI Opens pass the following username and password
      • Username: admin
      • Password: admin
      • New Username: admin
      • New Password: admin
      • Save and Continue
  2. Adding Datasource as Prometheus:

    • Once you get into Grafana, follow the below steps to Import a Dashboard into Grafana to visualize your Infrastructure/App Metrics
      • Click on "Configuration/Settings" on your left
      • Click on "Data Sources"
      • Click on "Add Data Source"
      • Select Prometheus
      • Underneath HTTP URL: http://PrometheusPrivateIPaddress:9090
      • Click on "SAVE and TEST"
  3. Create NodeExporter Dashboard:

  4. Create Jenkins Performance and Health Overview Dashboard:

GitHub webhook

  1. Add jenkins webhook to github

  2. Configure on the Jenkins side to pull based on the event

    • Access your jenkins server, pipeline app-cicd-pipeline
    • Once pipeline is accessed --> Click on Configure --> In the General section --> Select GitHub project checkbox and fill your repo URL of the project devops-fully-automated.
    • Scroll down --> In the Build Triggers section --> Select GitHub hook trigger for GITScm polling checkbox

Once both the above steps are done click on Save.

Codebase setup

  1. SonarQube IP change

    • Go back to your local, open your "devops-fully-automated" project on VSCODE

    • Open "Jenkinsfile" & Replace the SonarQube server private ip on line number 69

    • Save the changes in both files

    • Finally push changes to repo

      git add .

      git commit -m "relevant commit message"

      git push

  2. Nexus IP's change

    • Go back to your local, open your "devops-fully-automated" project on VSCODE

    • Open "pom.xml" & Replace the nexus server private ip on line numbers 32 & 36

    • Open nexus-setup/settings.xml & Replace the nexus server private ip on line numbers 21

    • Save the changes in both files

    • Finally push changes to repo

      git add .

      git commit -m "relevant commit message"

      git push

Finally observe the whole flow and understand the integrations :)

Happy learning, everyone! ๐Ÿ˜Š ๐Ÿ˜Š

devops-fully-automated's People

Contributors

r-akparanta avatar richiey2kng avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.