0% found this document useful (0 votes)
32 views

Kits Devops Class-2

Devops

Uploaded by

ai21jr1a4314
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Kits Devops Class-2

Devops

Uploaded by

ai21jr1a4314
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

JENKINS PROJECT

STEP-1: LAUNCH 2 INSTANCES

STEP-2: CONNECT JENKINS SERVER AND EXECUTE THE SCRIPT

vim candy.sh

go to insert mode

paste the script

save & continue (:wq)

sh candy.sh

STEP-3: CONNECT TOMCAT SERVER AND EXECUTE THE SCRIPT

vim jerry.sh

go to insert mode

paste the script

save & continue (:wq)

sh jerry.sh

STEP-4: SETUP JENKINS AND TOMCAT DASHBORAD

STEP-5: INSTALL PLUGIN TO DEPLOY APP

go to manage jenkins >>>> plugins >>>> available plugins

search for deploy to container

STEP-6: INSTALL DEPENDENCIES ON JENKINS SERVER

yum install git java-1.8.0-openjdk maven -y

STEP-7: CREATE A PIPELINE JOB AND WRITE A PIPELINE TO DEPLOY APP

go to jenkins dashboard >>> click on create a job >>> enter job name & select pipeline
pipeline {

agent any

stages {

stage('Code') {

steps {

git "https://github.com/siva-kits-devops/one.git"

stage ("Build") {

steps {

sh 'mvn package'

stage ("Test") {

steps {

sh 'mvn test'

stage ("Deploy") {

steps {

deploy adapters: [tomcat9(credentialsId: 'tomcat', path: '', url:


'http://98.81.132.37:8080')], contextPath: 'zomato', war: 'target/*.war'

}
}

====**=====OUR DEPLOYMENT IS DONE=====**====

DOCKER

MONOLITHIC:

If an application contains N number of services (Let's take Paytm has Money Transactions,
Movie Tickets, Train tickets, etc..) If all these services are included in one server then it will be
called Monolithic Architecture. Every monolithic Architecture has only one database for all
the services.

MICRO SERVICES:

If an application contains N number of services (Let's take Paytm has Money Transactions,
Movie Tickets, Train tickets, etc..) if every service has its own individual servers then it is
called microservices. Every microservice architecture has its own database for each service.

WHY DOCKER:

let us assume that we are developing an application, and every application has front end,
backend and Database.
To develop the application we need install those dependencies to run to the code.

So i installed Java11, ReactJS and MongoDB to run the code.

After some time, i need another versions of java, react and mongo DB for my application to
run the code.

So its really a hectic situation to maintain multiple versions of same tool in our system. To
overcome this problem we will use virtualization.

VIRTUALISATION:

It is used to create a virtual machines inside on our machine. in that virtual machines we can
hots guest OS in our machine.
by using this Guest OS we can run multiple application on same machine. Hypervisor is used
to create the virtualisation.

DRAWBACKS:

It is old method.
If we use multiple guest OS then the performance of the system is low.

CONTAINERIZATION: It is used to pack the application along with its


dependencies to run the application.

CONTAINER:

Container is nothing but, it is a virtual machine which does not have any OS.
Docker is used to create these containers.
A container is like a lightweight, standalone package that contains everything needed to
run a piece of software.
It includes the application code, runtime, system libraries, and dependencies.
To create a container we use docker.

DOCKER

It is an open source centralized platform designed to create, deploy and run applications.
Docker is written in the Go language.
Docker uses containers on host O.S to run applications. It allows applications to use the
same Linux kernel as a system on the host computer, rather than creating a whole virtual
O.S.
We can install Docker on any O.S but the docker engine runs natively on Linux
distribution.
Docker performs O.S level Virtualization also known as Containerization.
Before Docker many users face problems that a particular code is running in the
developer’s system but not in the user system.
It was initially released in March 2013, and developed by Solomon Hykes and Sebastian
Pahl.
Docker is a set of platform-as-a-service that use O.S level Virtualization, where as VM
ware uses Hardware level Virtualization.
Container have O.S files but its negligible in size compared to original files of that O.S.

DOCKER ARCHITECTURE:

DOCKER CLIENT:

It is the primary way that many Docker users interact with Docker. When you use commands
such as docker run, the client sends these commands to docker daemon, which carries them
out. The docker command uses the Docker API.

DOCKER HOST:

Docker host is the machine where you installed the docker engine.
DOCKER DAEMON:

Docker daemon runs on the host operating system. It is responsible for running containers to
manage docker services. Docker daemon communicates with other daemons. It offers various
Docker objects such as images, containers, networking, and storage.

DOCKER REGISTYR:

A Docker registry is a place where Docker images are stored and can be easily shared. It
serves as a centralized repository for Docker images, allowing users to upload, download, and
manage container images.

POINTS TO BE FOLLOWED:

You cant use docker directly, you need to start/restart first (observe the docker version
before and after restart)
You need a base image for creating a Container.
You cant enter directly to Container, you need to start first.
If you run an image, By default one container will create.

DOCKER BASIC COMMANDS:

To install docker in Linux : yum install docker -y


To see the docker version : docker --version
To start the docker service : service docker start
To check service is start or not : service docker status
To check the docker information : docker info
To see all images in local machine : docker images
To find images in docker hub : docker search image name
To download image from docker hub to local : docker pull image name
To download and run image at a time : docker run -it image name /bin/bash
To give names of a container : docker run -it --name raham img-name /bin/bash
To start container : docker start container name
To go inside the container : docker attach container name
To see all the details inside container : cat /etc/os-release
To get outside of the container : exit
To see all containers : docker ps -a
To see only running containers : docker ps (ps: process status)
To see only exited containers: docker ps -q -f "state=exited"
To stop the container : docker stop container name
To delete container : docker rm container name
To stop all the containers : docker stop $(docker ps -a -q)
To delete all the stopped containers : docker rm $(docker ps -a -q)
To delete all images : docker rmi -f $(docker images -q)

DOCKER FILE:

It is basically a text file which contains some set of instructions.


Automation of Docker image creation.
Always D is capital letters on Docker file.
And Start Components also be Capital letter.

HOW IT WORKS:

First you need to create a Docker file


Build it
Create a container using the image

DOCKER FILE TO USE NGINX IMAGE


WRITE A PIPELINE TO DEPLOY A APP ON CONTAINER:

pipeline {

agent any

stages {

stage ("Code") {

steps {

git "https://github.com/siva-kits-devops/docker-repo.git"

stage ("Build") {

steps {

sh 'docker build -t image1 .'

stage ("Deploy") {

steps {

sh 'docker run -itd --name contname -p 1234:80 image1'

You might also like