0% found this document useful (0 votes)
21 views150 pages

Devops Lab Manual

The document is a lab manual for the DevOps Lab course at CMR Institute of Technology, detailing the course structure, prerequisites, outcomes, and assessment methods. It outlines the vision and mission of the Computer Science and Engineering department, along with a comprehensive syllabus and lesson plans for practical sessions. The manual also includes mappings of course outcomes with program educational objectives and outcomes, ensuring alignment with industry standards and educational goals.

Uploaded by

22r01a67k1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views150 pages

Devops Lab Manual

The document is a lab manual for the DevOps Lab course at CMR Institute of Technology, detailing the course structure, prerequisites, outcomes, and assessment methods. It outlines the vision and mission of the Computer Science and Engineering department, along with a comprehensive syllabus and lesson plans for practical sessions. The manual also includes mappings of course outcomes with program educational objectives and outcomes, ensuring alignment with industry standards and educational goals.

Uploaded by

22r01a67k1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 150

CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

A Lab Manual
on
DEVOPS LAB
R22
(III- B. Tech. – II– Semester)
Submitted to

DEPARTMENT OF COMPUTER SCIENCE& ENGINEERING


(DATA SCIENCE)

By
Ms.Penugonda Anusha
(Asst Professor, Dept. of CSE (DS))

Mr. Deekshith Chary


(Asst Professor, Dept. of CSE(DS))

Mr. Mohsin
(Asst Professor, Dept. of CSE(DS))

CMR INSTITUTE OF TECHNOLOGY


Kandlakoya(V), Medchal Road, Hyderabad – 501 401
Ph. No. 08418-222042, 22106 Fax No. 08418-222106

(2024-25)
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
CONTENTS

Sl. No. Particulars Page No.


1. Vision and Mission 2
2. Syllabus 4
3. Student Entry Behavior or Pre-requisites 5
4. Course Outcomes 6
5. Mapping of Course with PEOs-POs 7
6. Mapping Of Course Outcomes with POs 9
7. Direct Course Assessment 10
8. Indirect Course Assessment 11
9. Overall Course Assessment and Attainment level 13
Pi diagrams, Bar charts, Histograms for representing
10. 14
results
11. Lesson/Course Plan 15
12. Programs 16

1
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
1. Vision and Mission

2
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

3
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
2.Syllabus

Devops LAB

Course B.Tech.-VI-Sem. L T P C
Course Code 22CDPC66 - - 2 1

4
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
3.Student Entry Behavior or Pre-requisites

 Students should have basic knowledge on Linux commands

 Students should have basic knowledge on basic programming.

 Student should have knowledge on software engineering concepts

 These prerequisites are taken by the students during the first two years. However during the initial
sessions the topics are reviewed.

5
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
4.Course Outcomes

Course Course Outcome Statements


Outcome
CO - 1 identify DevOps workflow
CO – 2 use eclipse for DevOps
CO – 3 develop docker image
CO – 4 take part in grid deployment
CO – 5 make use of Jenkins framework in DevOps

6
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
5.Mapping of Course with PEOs-POs
(Only Ticking)

Program Educational Objectives (PEOs)

Sl. No. PEOs Name Program Education Objective Statements

1 PEO - 1 Pursue successful professional career in IT and IT-enabled


sectors. [PO’s: 1,2,3,4,5,7,8,9,10,11 and 12] [PSO’s: 1 and 2]
2 PEO – 2 Pursue lifelong learning skills to solve complex problems
through multidisciplinary-research. [PO’s:
1,2,3,4,5,6,7,8,9,10 and 12] [PSO’s: 1, 2 ]
3 PEO – 3 Exhibits professionalism, ethics and inter-personal skills to
develop leadership qualities. [PO’s: 1,2,3,4,5,6,7,8,9,10,11 and
12] [PSO’s: 2 ]

Program Outcomes (POs)

PO Graduate PO Statements
Name Attributes
PO1 Engineering Apply mathematics, science, engineering fundamentals to solve complex
knowledge engineering problems. [PEO’s: 1,2 and 3] [PSO’s: 1,2 ]
PO 2 Problem analysis Identify, formulate and analyze complex engineering problems to reach
substantiated conclusions. [PEO’s: 1,2 and 3] [PSO’s: 1,2 ]
PO 3 Design/ Design and develop a component/system/process to solve complex societal
development of engineering problems. [PEO’s: 1,2 and 3] [PSO’s: 1,2]
solutions
PO 4 Conduct Design and conduct experiments to analyze, interpret and synthesize data for
investigations of valid conclusions. [PEO’s: 1,2 and 3] [PSO’s: 1,2 ]
complex problems
PO 5 Modern tool usage Create, select and apply modern tools, skills, resources to solve complex
engineering problems. [PEO’s: 1,2 and 3] [PSO’s: 1,2 ]
PO 6 The engineer and Apply contextual engineering knowledge to solve societal issues. [PEO’s: 2
society and 3]
PO 7 Environment and Adapt modern engineering practices with environmental safety and
sustainability sustainable development. [PEO’s: 1,2 and 3]
PO 8 Ethics Apply professional code of ethics, responsibilities and norms in engineering
practices. [PEO’s: 1,2 and 3] [PSO’s: 2 ]

PO 9 Individual and Compete as an individual and/or as a leader in collaborative cross cultural


team work teams. [PEO’s: 1,2 and 3]
PO 10 Communication Communicate effectively through technical reports, designs, documentations
and presentations. [PEO’s: 1,2 and 3] [PSO’s: 2 ]

PO 11 Project Endorse cognitive management skills to prepare project report using modern
management and tools and finance. [PEO’s: 1 and 3] [PSO’s: 2]
finance
PO 12 Life-long learning Engage in independent and life-long learning in the broad context of
technological changes. [PEO’s: 1,2 and 3] [PSO’s: 1,2 ]

7
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

6.Mapping Of Course Outcomes With POs

Avg
No Course Outcomes Po1 Po2 Po3 Po4 Po5 Po6 Po7 Po8 Po9 Po10 Po11 Po12

1 CO - 1 3 3 3

2 CO – 2 3 3 3

3 CO – 3 3 3 3

4 CO – 4 3 3 3

5 CO – 5 3 3 3

Avg 3 3 3

8
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
7.Direct Course Assessment
(As mentioned in following table of 10 parameters, of which consider only the parameters required for
this courses)

Actual Course
No Description Targeted Performance Remarks
Performance Attainment
80% of Students(182
Internal Students) should Secure
1
Marks(25) 60% of Internal Marks
i.e., 15 Marks
80% of Students(182
External Students) should Secure
2
Marks(50) 70% of External Marks
i.e., 35 Marks
A minimum of 95% of
Clearing of Students(216 Students)
3
Subject should clear this course
in first attempt
90% of Students(205
Getting First Students) should Secure
4
Class I Class Marks i.e., 45
Marks in my course
80% of Students (182
Students) should secure
5 Distinction First Class With
Distinction i.e., 53 Marks
in my course
60% of Students (137
Students) should secure
Outstanding
6 80% and above Marks.
Performance
i.e., 60 Marks in my
course

9
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
8.Indirect Course Assessment

(As mentioned-strong (3), moderate (2), weak (1) & no comment (0))

Mission Statement of CSE


 Impart fundamentals through state of art technologies for research and career in Computer Science
& Engineering(DS).
 Create value-based, socially committed professionals for anticipating and satisfying fast changing
societal requirements.
 Foster continuous self learning abilities through regular interaction with various stake holders for
holistic development.

Correlation of Mission Elements with Mission Statement of CSE(DS) Department related to the Course
(only Ticking given by faculty)

No Mission Elements Strong Moderate Weak No


Comment
M-1 Impart Fundamentals

M-2 State Of Art Technologies

M-3 Research & Career Development

M-4 Value based Socially Committed
Professional √
M-5 Anticipating & Satisfying Industry
Trends √
M-6 Changing Societal Requirements

M-7 Foster Continuous Learning

M-8 Self Learning Abilities

M-9 Interaction with stakeholders

M-10 Holistic Development

10
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Indirect Course Assessment through Student Satisfaction Survey
(Note for *: Parameters used for course teaching like
a: Classroom teaching b: Simulations c:labs d: Mini_Projects
e: Major Projects f: Conferences g: professional activities
h: Technical Clubs i: Guest Lectures j: Workshops k: Technical Fests l:Tutorials
m:NPTLs n:Digital Library o: Industrial Visits p: software Tools q:
Internship/training r:Technical Seminars
s: NSS t: NSS u: sports etc.
No Question Based on PEO/ PO/PSO/CO Parameters Strong Moderate (2) Weak No comment
(a /b /c…/)* (3) (1) (0)
1 Did the course impart fundamentals
through interactive learning and
contribute to core competence?
2 Did the course provide the required
knowledge to foster continuous
learning?
3 Whether the syllabus content
anticipates & satisfies the industry and
societal needs?
4 Whether the course focuses on value
based education to be a socially
committed professional?
5 Rate the role of the facilitator in
mentoring and promoting the self
learning abilities to excel academically
and professionally?
6 Rate the methodology adopted and
techniques used in teaching learning
processes?
7 Rate the course in applying sciences &
engineering fundamentals in providing
research based conclusions with the
help of modern tools?
8 Did the course have any scope to
design, develop and test a system or
component?
9 Rate the scope of this course in
addressing cultural, legal, health,
environment and safety issues?
10 Scope of applying management
fundamentals to demonstrate effective
technical project presentations &
report writing?
Total
Average
Total Average

11
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
9.Overall Course Assessment

(80% Direct + 20% Indirect, if any)

No Assessment Type Weightage Attainment Level


Direct-Assignment, Quiz, Subjective,
1 University Exams, Results, Bench 0.8
Marks
2 Indirect-Surveys-Questionnaire 0.2
Overall

DEVOPS LAB Course Attainment level:

12
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
10.Pi diagrams, Bar charts, Histograms

(For representing previous results, if any)

ICS Pass % for Last 4 Academic Years Appeared Passed Pass%

13
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
11.Lesson/Course Plan

Text
Week No. Name of the Program Week Mode of Assessment
Books
Start DevOps with a
workflow that includes four By observations, lab records,
1 1 R1
phases: to do, in progress, viva-voice
code review, and done
Setup Eclipse for DevOps. By observations, lab records,
2 2 R1
viva
Jenkins Setup on AWS. By observations, lab records,
3 3 R1
viva
Build WAR file in DevOps. By observations, lab records,
4 4 R1
viva
Ansible Setup and SSH By observations, lab records,
5 5 R1
keys. viva
Deploy the artifact on the Test By observations, lab records,
6 Server. 6 R1
viva
Perform automation using By observations, lab records,
7 7 R1
Jenkins. viva
Build and deploy a grid for By observations, lab records,
8 Chrome and Firefox based 8 R1
viva
testing.
Create deployment resource By observations, lab records,
9 using Kubernetes. 9 R1
viva
Create a docker image for
any application using By observations, lab records,
10 10 R1
Docker file and push it to viva
Docker hub.
Setup Grafana for Devops. By observations, lab records,
11 11 R1
viva
Setup Prometheus for By observations, lab records,
12 12 R1
Devops. viva

14
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
12.Programs
Experiment-1
Aim: Start DevOps with a workflow that includes four phases: to do, in progress, code review, and done.
Require Software& Tools: JIRA, KANBAN.
Procedure:
Phase 1: To Do
 Objective: Identify and prioritize tasks or features to be developed.

 Key Actions:
o Define tasks clearly in a backlog.
o Prioritize tasks based on impact, urgency, and dependencies.
o Assign owners or teams to each task.
Tools:
Jira, Trello, GitHub Issues, or Asana.

Phase 2: In Progress
 Objective: Actively work on tasks selected from the "To Do" phase.
 Key Actions:
o Begin coding or configuring based on task requirements.
o Update the task status to reflect ongoing work.
o Ensure team members collaborate effectively (e.g., stand-ups, pair programming).
Best Practices:
 Use branches in version control systems for individual tasks (e.g., Git feature branches).
 Write unit tests alongside development.

Phase 3: Code Review


 Objective: Validate the quality, functionality, and security of the code.
 Key Actions:
o Submit pull requests for peer review.
o Review code for adherence to standards, logic, and potential issues.
o Approve or request changes.
Tools:
GitHub Pull Requests, GitLab Merge Requests, Bitbucket.

15
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Automation:
Integrate CI/CD pipelines to run tests automatically during reviews.

Phase 4: Done
 Objective: Mark tasks as completed and deploy changes if necessary.
 Key Actions:
o Merge the approved code into the main branch.
o Deploy to staging or production environments.
o Monitor deployment and validate functionality.
Post-Completion:
 Add documentation for the changes.
 Gather feedback from stakeholders or users.

Workflow Visualization
A Kanban board or similar visual representation can help track the status of tasks across these phases. For
example:
1. To Do: Contains all pending tasks.
2. In Progress: Tasks currently being worked on.
3. Code Review: Tasks awaiting review or approval.
4. Done: Completed and deployed tasks.
Tools:
Trello, Jira, Azure.

16
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Output:-

17
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Experiment-2

Aim: Setups Eclipse for Devops


Note: Write the given steps in your lab manual. The provided image is just for your better
understanding.

Require Software& Tools: Eclipse, Java jdk-17, Tomcat v.9, TestNG and Dependencies.
Procedure:
Step-1: Install Jdk-17 and set the java path in System environment
Step-2: Download eclipse zipfile and extract the contents the all eclipse file
Step-3:Create a Maven Project from eclipse as:
OR
Click on File in left corner -> Click on new -> click on Maven Project and follow the given image steps.
a.

b.

18
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

b. Click Next and Search org.apache.maven.archetypes and select webapp file

19
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

c. In a group id you can type anything like name and in aartefact id: you can type anything like your roll
number

d. Click Finish

e. Type Y and Press enter, You should see a Build Success message as below:

20
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-4:now open your pom.xml file and add your dependencies (Given file, Copy and Paste)

Step-5: Update your project once (Right click on Project -> click on Maven -> click on Update Project)
Step-6: Download Apache tomcat v9 from Official website.

21
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-7: After Download the Apache tomcat, Extract the .zip file and paste your apache-tomcat-9.0.98 folder in
your folder
Step-8: Now click on your project option in Menu -> Click on Properties -> Click on Targeted Runtime
Step-9: Click on new or follow the given image

22
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-10: Select Apache Tomcat v9.0

Step-11: Click on Browse and Select your Extracted file and then click on finish as given image

23
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-12: Now Click on help Menu ->click on Install new Software.


Step-13: Click on Add and it will show a popup dialog box like given image

In the place of Name type: TestNG


In the place of Location type: https://testng.org/testng-eclipse-update-site/

24
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-14:Click on Add ->It will load atestNG Dependencies ->SelectTestNglike given Imageand then click
Next.
It will take 10 minute to update TestNG in our Project

Step-15: After downloading the all dependencies it will show some file select all and click on next.
25
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-16: Accept Terms and condition and click on finish

26
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-17:After finish it will show restart option (Restart the Project) otherwise just update once of your
project.
Step-18: Now Login yourGitHub Account.
Step-19: Create a New Repository and Copy your Repository and paste in notepad
Step-20: After that Click on your Profile in Right corner -> Click on Setting.

Step-21: It will show a new page, scroll down and select the developer setting ->click on personal access
token ->select Token(Classic) ->click on Generate new token and select Generate new token(Classic) -

27
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
>write your token name and select repo option and scroll down and click on Generate Token. (Follow the
given Image)

28
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-22: After Generating the token copy the token id and paste in aNotePad.
Step-23: Now come on your project and right click on yourproject ->Click on Team ->Click on Share Project.

Step- 24: It will open a Dialog Box forGitHubSetup, select the option Use or create repository in parent
folder of project - >Select your Project and Click on Create Repository and click on Finish.

29
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-25: After that again Right click on yourProject and select the Team -> click on Commit-> and stage
your all file -> and Write a comment (i.e. First Commit) and click on Commit and push-> after that it show an
error dialog ->click OK ->now again click on Push Head Button

30
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

31
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-26: After that again click on Push Head, it will show a dialog like given image, paste your Repository
URL in URL section and type yourGitHub User Id and Password in User, password section -> Click on
preview ->Again clickon Preview.

Step-27:After that it will again show a user Id and Password option ->just type yourGithub id in user section
and paste your Token id in Password section -> click on push ->one more time it will ask user id and

32
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
password just repeat your last step with user id and token id ->now check your repository on github, your
file is uploaded or not

Step-28:Now you have to create a simple java code in SRC File, so first open your project from file manager-
>open SRC - >Create two folder in SRC -> first name: java, second name: test ->now open test folder and
create two more folder in test folder ->now come on your eclipse IDE and Update your project once -> After
that create a java class file with a Statement “Hello World”in your SRC/TEST/java folder.
Step-29:Now Push again your all unstage files in yourGitHubRepositorywith different version or Comment
(Its just for Version Control).
Step-30: Now Check again your Repository your recent file is uploaded or not with different version.

33
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Output:-

34
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Experiment-3

Aim: Jenkins Setup on AWS.


Note: Write the given steps in your lab manual. The provided image is just for your better
understanding.

Require Software & Tools: AWS, MobaXterm Software.


Procedure:
Step-1: Search AWS Free Tier Account in any Browser and Create an Account. (if you have already an
account then leave the steps)

35
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-2: After Creating the Account, Just Login as a ROOT User


Step-3: After Login It will show your account -> Click on EC2 option -> Click on Launch Instance

36
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Step-4: After Clicking on Launch Instance It will ask Instance Name and Other things -> Write Instance Name
as Jenkins -> Select Application and IOS Image as Ubuntu ->Scroll Down and Come on Instance Type Option
and Select t2.Medium -> Now Come in Key Pair(Login) Section and Click on Create New Key Pair -> Write
your Key Pair Name as Exp3 -> Select RSA -> Select .pem-> Click on Create Key Pair.

37
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-5: After Click on Create Key Pair it will download aExp3.pem file ->After that in Right Side we have a
Option Number of Instances Select 1 -> Click on Launch Instances (It will take some time and will create an
instance).

Step-6: After that Refresh the page -> Select the Created Instance -> Click on Security.

38
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

39
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Step-7: After Clicking on Security -> It Will Show a Blue Link name as Security Group -> Click on that blue Link
it will Open a Page -> Click On Edit Inbounds rule -> Click on Add Rule -> Add one Rule HTTP and Source
type Anywhere IPV4 ->Addone More Rule Custom TCP, port range 8080 and Source Anywhere IPV4 -> Click
on Save Rule

40
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Step-7: After that click on Dashboard -> click on instance Running -> select Jenkins -> click on connect.

Step-8: After that click on connect it will open a Linux terminal -> just type clearcommand and follow the setp-9
documents.

41
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Step-9: Now You have to Setup Jenkins -> Search Jenkins Document in Any Browser ->Click on first Jenkins
link -> Click on Installing Jenkins -> click on Linux -> Click on Debian/Ubuntu -> After that it will show the Linux
Command

42
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-10: Now Come on your MobaXtrem Application -> Type Clear and Hit Enter key ->it will clear your
Command Screen -> Now copy the theLong Term Support release code till /dev/null -> Paste in your Linux
Terminal and hit the Enter Key -> it will Download the Jenkins Support File
sudowget -O /usr/share/keyrings/jenkins-keyring.asc \
Code: https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
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> /dev/null

Step-11: Clear your Screen -> Now Update your Project Using Given Code.
Code:
sudoapt-get update

Step-12: clear your screen ->Now Check Java version Using Command: java --version
Step-13: if It Show Java Not Found then it show the option install Java -> so install java using given Command
-> it will ask Y/N just type Y and hit Enter -> It will take some time to download java.

Code:
sudoaptinstall fontconfig openjdk-17-jre

43
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-14: After Downloading the Java, Clear your Screen using clear command -> Once again Update your
Project Using Update Command (follow Step-14 command) -> now Install Jenkins Using Jenkins Command,
i.e given code (It will ask again Y/N just type Y and Hit Enter) -> After Installing the Jenkins Once again Update
your Project using Update Command Just Check Java and Jenkins Version Using (java –version and Jenkins –
version Command)
Code: Sudo apt-get install jenkins

Step-15: Now Enable the Jenkins Server Using Given Command


Command: Sudo systemctl enable jenkins

Step-16: After Enable the Jenkins Server Start Jenkins Server Using Given Command
Command:
Sudo systemctl start jenkins
Step-17: After Starting the Jenkins Server Check Jenkins Server Status using Given Command. It will show
the Status Active running ans show the status of memory, CPU etc.

Command:
Sudo systemctl status jenkins

Step-18: Now Open your Any Browser and Search the Jenkins Server using Instance IP and Custom Port
Number (Ip= <your instance ip> port is 8080)follow the given snap

Step-19: It will start the Jenkins Server, show some path with red colorand Ask the Administrator Password
like Given Image.

44
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-20: Copy the RED color path and Paste in your Linux Terminal followed by sudo cat command and hit the
Enter it will show 64-bit Alpha-Nemuric code -> Copy that code and paste in the place of password in your
browser -> click on continue option.

Step-21: After clicking on continue option it will show two option for installing the pluging-> Just click on
installed suggested plugin -> it will take some time for install all plugins -> After installing all plugins, it will ask
Creating an account usinguser ID and password so create an account using user id and password (fill all
related field). -> Click on Save and Continue

45
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-22: After click on Save and continue -> it show some links and show the option Save & Finish -> Click on
Save & Finish -> After that it show Jenkins in Ready and show a option Start using Jenkins -> just click on it ->
It will open a Jenkins Dashboard.

46
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Output:-

OUTPUT
Your Output is the Jenkins Dashboard

47
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Experiment-4
Aim:Ansible Setup and SSH key
(Note: All Blue Words is a command, just copy and paste)

Require Software & Tools: AWS Account, Puttygen software, Wincp Software.
Procedure:
Step-1: Login AWS and Create three Instances on AWS account using ubuntu OS and save key pair
also.

Step-2: change the 2nd and 3rd instance name as a server1 and server2 (you can named anything) ->
Edit inbound rules of 1st instance (ansible). Edit inbound rules like given details.

Step-3: Now come on instance and select 1st instance (ansible) and click on connect. It will open a
linux terminal -> type Clear command.

48
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-4: type command sudo apt update and hit enter.


Step-5: type command sudo apt install ansibleand hit enter -> it will ask yes/no type yes and hit enter.
Step-6: type command sudo apt install openssh-client and hit enter.
Step-7: type command sudo apt install openssh-server and hit enter.
Step-8: type command cd ~/.ssh/ and hit enter.
Step-9: type command ls and hit enter.
Step-10: type command cd and hit enter.
Step-11: type command cd - and hit enter. (it will show ssh path)
Step-12: now againtype command cd and hit enter.
Step-13: open puttygen software -> click on load -> select as all files -> select ansible.pem(your key
pair) -> click on save and -> click on save private key and save the file with .ppk extension.

49
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-14: Now open winCP software -> it will ask for host name just copy and paste your
ansibleinstance Ip-> In the place of user name type Ubuntu -> click on advance -> select authentication
-> in the place of private key select your downloaded .ppk file - > click on Ok -> click on Login. (it
will connect to your server and show a Ubuntu wincp window)
Note: follow 1 -> 2 -> 3 -> 4 -> 5 arrow.

50
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Step-15: after connecting to your server it will show two directory (one is your local disk, another is
ssh directory) -> right click in ssh directory -> click on new -> select directory -> create a folder name
as key -> now select your .pemfile from left side local disk directory and drag in your key folder.
Step-16: Now come on in your terminal -> type cd command and hit enter -> type lscommand hit
enter, you will see key.

Step-17: Now type cd key/ and hit enter, you will see ansible.pem
Step-18: Now type cpansible.pem ~/.ssh/ command and hit enter -> after that type cd hit enter -> after
that ls ~/.ssh/ and hit enter, you will see ansible.pem and authorized_key
Step-19: Now create one more directory using mkdiransible-script command and hit enter-> select
directory using cd ansible-script/ command and hit enter.
Step-20: Now write vi inventory.ini command and hit enter -> it will open your Vim Editor -> copy
the given command and paste in your Vim editor -> after that in the place of [server1-ip] copy and
paste server1 instance public ip and in the place of [server2-ip] copy and paste server2 instance public
ip -> after that save this vim editor using :wq! Command and hit enter

Command:

[webservers]
server1 ansible_host=[server1-ip] ansible_user=ubuntuansible_ssh_private_key_file=
/home/ubuntu/.ssh/ansible.pem
server2 ansible_host=[server2-ip] ansible_user=ubuntuansible_ssh_private_key_file=
/home/ubuntu/.ssh/ansible.pem

Step-21: Now write the command vi playbook.ymland create a yml file -> it will again open your Vim
editor -> copy and paste the given command in your vim editor after save and exit using command
:wq! and hit enter.
Command:

-- name: Install Nginx on AWS EC2


hosts: webservers
become: yes
tasks:
- name: Install Nginx
apt:
name: nginx
state: present
when: ansible_os_family == "Debian"
51
- name: start and enable nginx server
systemd:
name: nginx
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-22: Now you can check your .ini file and .yml file using cat inventory.ini command and cat
playbook.ymlcommand.
Step-23: Now type ansible-playbook –i playbook.ymlcommand and hit enter.
Step-24: Now type ansible-playbook –i inventory.ini playbook.ymlcommand and hit enter -> it will
ask for type yes and again yes and again yes or may be it will show server Unreachable.
Step-25: Now type cd and hit enter -> after that cd ~/.ssh/ hit enter, you will see
ansible.pemauthorized_key and known_hosts.
Step-26: Now again run the command ansible-playbook –i inventory.ini playbook.yml. it will run your
server or may be it will show again an error server unreachable.
Step-27: If server is reachable is then check your server using server ip otherwise -> write command
chmod 400 ~/.ssh/ansible.pemhit enter -> after that ls –l ~/.ssh/ and hit enter, it will show Ubuntu file.
Step-28: Now again run the command ansible-playbook –i inventory.ini playbook.yml. nowit will run
your server properly. After that you can check your server in any browser using server ip.

OUTPUT:-

52
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

53
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Experiment-5
(Note: All Blue Words is a command, just copy and paste)
Aim:Build War file in Devops
Require Software & Tools: Jenkins, Jdk-17 or jdk-21, Git bash.
Procedure:
Step-1: First open any browser and Search download Jenkins -> click on first link -> scroll down and
click on windows logo -> download will be started.

Step2: First check java jdk in your system, if java is available check the java version using cmd.
otherwise download and install jdk-17.

Step-3: Download Git Bash 64-bit Standalone Installer, and install git bash in your system. After
installation set the git.exe path in your runtime environment.
54
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-4: Now install Jenkins in your system -> click on next and again next -> select run service as
a local system -> click on next and click on Test port -> click on next and click on change and set
the java jdk path -> click on next and again next and click on install.

Step-5: After that install Git Bash in your system (no need to change anything just click on next
next and next till last).

55
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Step-6: Now open a browser -> search localhost:8080
Step-7: It will open your Jenkins server -> Copy red line location and search it to in your File
manager.

Step-7: It will show open with option just select notepad -> after that copy the password and
paste in Jenkins server -> click on continue -> click on suggested plugin -> it will take some time
for installation -> create admin user using given details and click on save and continue -> after
that click on save and finish -> Click on start using jenkins It will show Jenkins Dashboard.

56
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-8: After that click on manage Jenkins -> click on plugin -> click on available plugin ->
search maven -> select maven integration -> click on install -> scroll down and check maven
integration and and loading plugin is green and success or not -> After success click on go back
to the top page

57
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-9: Now again click on Manage Jenkins -> click on tools -> scroll down and check Git path ->
after that scroll down and in a Maven installation section -> click on add maven -> write maven
name and click on apply -> click on save.

58
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-10: now click on dashboard -> click on create a job -> type your buildwar name (i.e.
myWar) -> select Maven Project -> click on OK

59
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-10: Now take a new page -> login your GitHub -> check second experiment repository like
Devops_pipeline -> copy the git link of second experiment.

Step-11: scroll down and go to Source code management section -> select git -> paste git link ->
scroll down go to build option and type clean install package in goals option -> click on apply ->
click on save.

60
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step-12: After save the file -> it will show an option in left side build now -> click on build now -
> It will take two to five minute for creating build file.

Step-12: After building it will show success with green mark -> click on that section -> it will
open new section -> click on console output -> scroll down and check status, build success or not.

61
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

62
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Output:-

63
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Experiment-6

AIM:-Deploy the artifact on the Test Server


Softwares:Jenkins(port:8080),JDk 17 or 21,Tomcat 9 (port:9090),Gitbash
(Here we are creating one artifact war file. That war file we are deploy to test server(Tomcat server) using
Jenkins Server)
(Note:-Images are purpose of understanding only don’t paste it in records but output images paste it in output
area)
Step1:-Lunch Jenkins and Login(Use AWS or Software)

Step2:-Lunch Tomcat Server and login(use AWS or Software)

Open Jenkins do following steps


Step 3:-Install plugins
Go to Manage JenkinsPluginsInstall Plugin select verify GitGo to Available plugins install Maven
integration and Deploy to container install.

64
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Above picture three plugins are installed , If not showing please go to available plugins install it.

65
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step 4:-set up git path and maven installation in Tools


Go to manage JenkinsToolsIn git installation select path(Git bash) if your using Jenkins software or AWS
leave it In maven Enter name Maven and default installationApply and Save.

66
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

67
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step 5:-Creating New Job for deploy artifact in tomcat test server
1. Create New Item Enter name DeploytoTestServer select freestyle projectclick ok

68
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

2. Select git paste maven project url form GithubMust and should match branches

3. Go to Environment Select Add timestamps to the Console Output

69
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

4. Go to Build SetupsSelect Invoke top-level Maven targetsMaven Version enter maven Goals
clean install

.
5. Go to Post-build ActionsSelect Deploy war/ear to a containerWAR/EAR files enter
**/*.warselect Containers Tomcat 9.x RemoteAdd credentials like username, password, Id and
description.-->Tomcat URL http://localhost:9090 Apply and save.

70
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step 6:- Build war File


1. Click Build now Go to Build select console output now you got Successfully Finish.

71
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

72
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Output:-

73
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

74
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Experiment-7

AIM:-Perform Automation using Jenkins.


Softwares:Jenkins(port:8080),JDk 17 or 21,Tomcat 9 (port:9090),Gitbash
(Here we are creating one artifact war file. That war file we are deploy to test server(Tomcat server) using
Jenkins Server)
(Note:-Images are purpose of understanding only don’t paste it in records but output images paste it in output
area)
Step1:-Lunch Jenkins and Login(Use AWS or Software)

Step2:-Lunch Tomcat Server and login(use AWS or Software)

Open Jenkins do following steps


Step 3:-Install plugins
Go to Manage JenkinsPluginsInstall Plugin select verify GitGo to Available plugins install Maven
integration and Deploy to container install.

75
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Above picture three plugins are installed , If not showing please go to available plugins install

76
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step 4:-set up git path and maven installation in Tools


Go to manage JenkinsToolsIn git installation select path(Git bash) if your using Jenkins software or AWS
leave it In maven Enter name Maven and default installationApply and Save.

77
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

78
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step 5:-Creating New Job for deploy artifact in tomcat test server
6. Create New Item Enter name DeployPipeline select pipeline projectclick ok

79
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step 2:-Copy paste below commands pipeline script


pipeline{
agent any
tools{
maven 'Maven'

}
stages{
stage('clone the repository'){
steps{
git url: 'https://github.com/devisar/Exp2.5.git'
}
}
stage('Build the code'){
steps{
bat 'mvn clean install'
}
}
stage('deploy to tomcat'){
steps{
deploy adapters: [tomcat9(credentialsId: 'Deploy', path: '', url: 'http://localhost:8080')],
contextPath: null, war: '**/*.war'
}
}

80
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
}
}

Step 6:-deploy to tomcat you want to create pipeline script go to pipeline syntaxSelect in sample step
deploy: Deploy war/ear to a container enter war/ear files:**/*.warSelect Containers tomcat 9select
credentials tomcat user name and password. Enter Tomcat Url like http://localhost:9090. Click
Generate Pipeline Script copy and paste it original pipeline deployment stage.

81
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

82
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step 7:- Build war File


2. Click Build now Go to

Build
select console output now you got Successfully Finish.

83
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

84
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Output:-

85
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

86
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Experiment 8

Week 8
AIM:-Build and deploy a grid for Chrome and Firefox based testing.
Step1:- Download Selenium Grid

Step2:-Download Chrome Driver

87
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

88
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Below picture address copy and paste it new tab. Automatically chrome driver
downloded

89
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step3:-Download Gecko Driver

90
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step 4:-Put all drivers one folder

Step 5:-Run hub use following command and node also separate cmd. In cmd
change directory where available all drivers
91
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
1. java -jar selenium-server-4.29.0.jar hub
2. java -jar selenium-server-4.29.0.jar node --detect-drivers true
Also run chrome using ip address path it will generate after running hub and verify

92
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

93
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step 6:-Open Eclipse Attach Apache Tomcat and TestNG


1. Store Apache and eclipse folders only single folder and lunch Eclipse
same folder

94
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

95
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
3.Create maven project goto FileNewMaven Project SelectNextselect
org.apache.maven.archetypes select webappEnter Group Id:week7
ArtifactId:selenium Package:warFinish. Enter Y you get Build Success in
console.

96
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

97
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

3. Open Pom.xml copy paste below code this all I added dependies and
plugins. Next Right click ProjectMavenUpdate projectok.
(Note:If you not update every changes it will not save.)
98
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>DevOps</groupId>
<artifactId>MyDevPipeline</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>MyDevPipeline Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!--
https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!--

https://mvnrepository.com/artifact/org.seleniumhq.selenium/seleniu
m-api -->
<dependency>
99
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.141.59</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version> <!-- Use the latest version
available(7.11.0) -->
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.3.0</version>
</dependency>

</dependencies>
<build>
<finalName>MyDevPipeline</finalName>
<pluginManagement>
<plugins>
<plugin>

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<plugin>

100
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-
plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-
plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>17.0.12</source>
<target>17.0.12</target>
</configuration>
</plugin>
<plugin>

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-
plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<plugin>

101
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

102
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

4.Adding Apache tomcat server


Go to ProjectPropertiesMavenTargeted Runtimesnewselect apache
tomcat 9nextbrowse apache folder addressfinishclick check box
apache 9 and applyapply and close.
103
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
(Note:-because running srcindex.js file running purpose if you not adding it
will show errors.)

104
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

105
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

5. Adding TestNG in Eclipse.


Go to helpInstall New SoftwareAddEnter Name:TestNG,
Location:https://testng.org/testing-eclipse-update-site/Add.
Select TestNG check boxNextNextI acceptFinish
Trust SelectedTrust Selected.

106
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

107
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

108
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

109
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

110
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

6.Create Folder inside src test inside java.java folder select build path
current folder.Right click that foldernewothersclassnextgive
package name and class nameok
Java file created copy paste below code.change hub address must and
should.
Same page right clickrunTestNG Finally its run test passes.
SeleniumGridDemo.java
package com.testautomation.grid;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
import java.net.URL;

public class SeleniumGridDemo {

111
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

@Test
public void runTestOnChrome() throws Exception {
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
WebDriver driver = new RemoteWebDriver(new URL("
http://172.16.226.24:4444/wd/hub"), capabilities);

driver.get("https://www.google.com");
System.out.println("Page title on Chrome: " + driver.getTitle());
driver.quit();
}

@Test
public void runTestOnFirefox() throws Exception {
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
WebDriver driver = new RemoteWebDriver(new URL("
http://172.16.226.24:4444/wd/hub"), capabilities);

driver.get("https://www.google.com");
System.out.println("Page title on Firefox: " + driver.getTitle());
driver.quit();
}
}

112
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

113
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

114
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

115
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Output:-

116
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Experiment-9
Aim:-Create deployment resource using Kubernetes.
 Create the google cloud console free account

 It is a two step process

 It is deducting the 2 rupees from your account and it will give the 330$ free credit points.

NOTE: Don’t active the full account

 Once the account is created u can login to google cloud console

 NOW CREATE THE KUBERNETES CLUSTER

Open the cloud shell

To see the cluster list run the below command

117
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Gcloud container clusters list ( no clusters are there)

You create the cluster with below command

gcloud container clusters create my-cluster --zone us-central1-a

Cluster creation is taking 5 to 10 mints time

Once the cluster is created u can see the below message automatically

Now u go and check kubernetes engine--->cluster , you can see the my-cluster is running

Run the below command


118
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

gcloud container clusters get-credentials my-cluster --zone us-central1-a

To see the list of nodes

Create the pods

Kubectl run --image tomcat webserver

To see the pods list

To get the list of pods along with ip address and which node the pod is running

Kubectl get pods -o wide

119
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Actually u can create the pod using definition file

Create pd-df1.yaml

Vim pd-df1.yaml

apiVersion: v1
kind: Pod
metadata:
name: jenkins-pod
spec:
containers:
- name: myjenkins
image: jenkins/jenkins
ports:
- containerPort: 8080
hostPort: 8080

for accessing the application u need to open the port

How to open the port

gcloud compute firewall-rules create rule2 --allow tcp:8080

Kubectl create -f pd-df1.yaml

Kubectl get pods -o wide

120
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Kubectl get nodes -o wide

How can we access the pod

Take the external ip add the port no 8080

Open the browser paste ipaddress:8080

Now u can able to see the Jenkins


Output:-

121
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Experiment 10

AIM:-Create a docker image for any application using docker file and push it to Docker Hub.
Step 1:-Connecting AWS Instance Ubuntu using Mobaxterm
1. Login AWS(Amazon Web Services) Account
2. Lunch Instance name Docker
3. Connect to Ubuntu or mobaxterm

(note:-Follow this url for docker file and application—https://github.com/devisar/devopslab)


Step 2:-Create Docker Hub Account and create repository in Docker Hub
Step 3:-Install Docker and Check Status and Start Docker in mobaxterm
1. sudo apt update -y
2. sudo apt install docker.io –y
3. sudo systemctl status docker(come outside use command ctl+z)

Above status command is docker running means no problem if not run use command below to run
4. sudo systemctl start docker

Step 4:- Grant Access

Why we give grant access means


A easy way to verify your Docker installation is by running the below command

docker run hello-world

If the output says:

This can mean two things,

122
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
1. Docker deamon is not running.(start docker using “sudo systemctl start docker” )
2. Your user does not have access to run docker commands.

Grant Access to your user to run docker commands


1. sudo usermod -aG docker ubuntu

In the above command ubuntu is the name of the user, you can change the username appropriately.

NOTE: : You need to logout and login back for the changes to be reflected.

2. Logout purpose use commands exit or logout

Again run command “docker run hello-world”

Start
session

Step 5:-Creating application and Docker file

1. Mkdir docker1
2. cd docker1
3. vim app.py

print(“hello world”)

4. cat app.py
123
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
5. vim Dockerfile (below pic commands write lab record) typing command vim before click “i” for insert
data after completion Docker file commands save before click esc use :wq!

Below image for understanding purpose

se

Step 6:- Build and Check Docker image

Syntax:- docker build –t dockerhub_username/repositoryname:tag .

1. docker build –t anu1308/dockerimage:latest .


2. docker images

Below images for understanding purpose

124
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step 7:- Run your First Docker Container


1. docker run -it anu1308/dockerimage:latest

Output

Hello World

125
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Step 8:-Docker Login

1. docker login

Step 9:- Push the Image to DockerHub and share it with the world

1. docker push anu1308/dockerimage:latest

Output:-

126
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Definitions:-

Docker LifeCycle

We can use the above Image as reference to understand the lifecycle of Docker.

There are three important things,

1. docker build -> builds docker images from Dockerfile


2. docker run -> runs container from docker images
3. docker push -> push the container image to public/private regestries(docker hub) to share the docker images.

127
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
What is a container ?
A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly
and reliably from one computing environment to another. A Docker container image is a lightweight, standalone,
executable package of software that includes everything needed to run an application: code, runtime, system tools, system
libraries and settings.

Why are containers light weight ?


Containers are lightweight because they use a technology called containerization, which allows them to share the host
operating system's kernel and libraries, while still providing isolation for the application and its dependencies. This results
in a smaller footprint compared to traditional virtual machines, as the containers do not need to include a full operating
system. Additionally, Docker containers are designed to be minimal, only including what is necessary for the application to
run, further reducing their size.

What is Docker ?
Docker is a containerization platform that provides easy way to containerize your applications, which means, using Docker
you can build container images, run the images to create containers and also push these containers to container regestries
such as DockerHub

Docker daemon

The Docker daemon (dockerd) listens for Docker API requests and manages Docker objects such as images, containers,
networks, and volumes. A daemon can also communicate with other daemons to manage Docker services.

Docker client

The Docker client (docker) 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 dockerd, which carries them out. The docker command uses the
Docker API. The Docker client can communicate with more than one daemon.

Docker Desktop

Docker Desktop is an easy-to-install application for your Mac, Windows or Linux environment that enables you to build
and share containerized applications and microservices. Docker Desktop includes the Docker daemon (dockerd), the
Docker client (docker), Docker Compose, Docker Content Trust, Kubernetes, and Credential Helper. For more information,
see Docker Desktop.

Docker registries

A Docker registry stores Docker images. Docker Hub is a public registry that anyone can use, and Docker is configured to
look for images on Docker Hub by default. You can even run your own private registry.

When you use the docker pull or docker run commands, the required images are pulled from your configured registry.
When you use the docker push command, your image is pushed to your configured registry. Docker objects

When you use Docker, you are creating and using images, containers, networks, volumes, plugins, and other objects. This
section is a brief overview of some of those objects.

Dockerfile

128
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Dockerfile is a file where you provide the steps to build your Docker Image.

Images

An image is a read-only template with instructions for creating a Docker container. Often, an image is based on another
image, with some additional customization. For example, you may build an image which is based on the ubuntu image,
but installs the Apache web server and your application, as well as the configuration details needed to make your
application run.

Below Images for Understanding purpose


Connecting AWS Instance to Mobaxterm

129
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

130
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

131
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

132
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

133
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Remote host we want public key and .pem file also so login to AWS Account

134
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

135
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

136
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Here you can Directly connect Ubuntu also but better use mobaxterm

137
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

138
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

139
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Create Docker Hub Account and create repository in Docker Hub


140
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

141
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

142
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

143
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

144
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Experiment 11
Aim:-Setup Grafana for Devops.

ACCESS GRAFANA :
kubectl get secret prometheus-grafana -n monitoring -o jsonpath="{.data.admin-user}" | base64 --decode ; echo

If you run the above command u can see the username for grafana (admin)

kubectl get secret prometheus-grafana -n monitoring -o jsonpath="{.data.admin-password}" | base64 --decode ;


echo

If you run the abvoe command u can see the password for grafana (prom-operator)

PORT FORWARDING

kubectl port-forward svc/prometheus-grafana 3000:80 -n monitoring

Click on the web preview give the port no 3000 and click on change and preview u can see the grafana

145
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Output:-

You can login with admin and prom-operator

146
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB
Experiment 12

Aim:-Setup Prometheus for Devops.

PROMETHEUS SETUP:
helm repo add prometheus https://prometheus-community.github.io/helm-charts

helm repo update

helm install prometheus prometheus-community/kube-prometheus-stack --namespace monitoring --create-


namespace

This will install prometheus,alermanager and grafana

Check the prometheus pods and services

kubectl get pods -n monitoring

kubectl get svc -n monitoring

147
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Access prometheus and port forwarding

kubectl port-forward svc/prometheus-kube-prometheus-prometheus 9090:9090 -n monitoring

Click on the webpreview

Change port no to 9090

Click on change and preview

Now u can able to see prometheus in the browser

148
CMR INSTITUTE OF TECHNOLOGY DEVOPS LAB

Output:-

149

You might also like