Skip to main content

Command Palette

Search for a command to run...

Project 2 — DevOps

Published
3 min readView as Markdown
K

With a rich history spanning decades in Industrial IT, I currently serve as a Technical Consultant at onshore. My career has been defined by my unwavering commitment to DevOps and leadership in database administration projects.

Cloud Expertise: I possess extensive knowledge and hands-on experience in the realms of Microsoft Azure and AWS Cloud. I've played a pivotal role in architecting and optimizing cloud solutions that enable businesses to scale, innovate, and thrive.

Cloud DB and DevOps Advocate: My pursuit of excellence never stops. I'm on a constant quest to acquire deep knowledge in Cloud Database solutions and DevOps tools. From Azure DevOps to Jenkins, Ansible to GitHub, Terraform to Docker and Kubernetes, I'm committed to staying at the forefront of industry trends.

I'm passionate about leveraging technology to drive success in industrial IT. Let's connect and explore how my decades of experience and expertise can contribute to your organization's growth and transformation.

Project Description

The project is about automating the deployment process of a web application using Jenkins and its declarative syntax. The pipeline includes stages like building, testing, and deploying to a staging environment. It also includes running acceptance tests and deploying to production if all tests pass.

Lets begin.

Step 1:

As part of requisite we need EC2 instance who has Jenkins and docker alredy installed on it.

Go to aws console and create new EC2 instance as Jenkins server.

Step 2:

Connect to instance using SSH client and install necessary software like Java, Jenkins and docker.

Will create shell script as below and install all necessary software in one go.

Add the execute right to file and trigger the install.sh file.

Step 3:

Verify the installation and Jenkins and docker service.

Step 4:

Add our user and Jenkins user to the Docker group

Step 5: Enable port 8080 of default port of jenkins in security group.

Step 6 : Generate SSH Keys

Generate SSH keys for Jenkins-Git integration using the command

Step 7: Setup Jenkins.

Navigate the Jenkins dashboard at instance-public-IP/8080.

Access the path /var/lib/jenkins/secrets/initialAdminPassword for initial admin password and paste here and click on continue button.

Install suggested plugins in next step.

In next stage will create first admin user.

We are all good now with Jenkins setup and ready to build CI/CD.

Step 8: Building project/Pipeline.

Go to Jenkins dashboard->New Item->Enter Item name (We are mentioning declarative-pipeline-project) and choose project type as Pipeline and press Ok button.

Provide description

Put declarative pipeline syntax as below in pipeline script section.

pipeline {
    agent any

stages {
    stage ('Checkout source code') {
        steps {
            git URL: "https://github.com/kishorchavan87/django-app.git", branch: 'main'
              }    
        }

    stage ('Build the code') {
        steps {
            sh 'docker build -t django-app-img:latest .'
              }    
        }

    stage ('Test the code') {
        steps {
            echo "Testing the code
              }    
        }

    stage ('Deploy the code') {
        steps {
            sh 'docker run -d -p 8001:8001 --name django-demo-app django-app-img:latest'
              }    
        }


    }

}

Save the configuration and hot build now button.

We can see build status stage wise.

We could see our pipeline successfully completed. will check console output for more details.

Step 9: Verify the deployment by navigating public-ip:8001

We have successfully built the image of a Web app source code, and deployed that image as a container, using Jenkins declarative Pipelines.

Hope you found this article helpful.

Thanks,

Kishor Chavan