0% found this document useful (0 votes)
360 views24 pages

DevOps Tutorial (Technical Guftgu)

Uploaded by

Aryan Kumar
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)
360 views24 pages

DevOps Tutorial (Technical Guftgu)

Uploaded by

Aryan Kumar
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/ 24

DevOps Tutorial {Technical Guftgu]

De­vOps Tu­to­ri­­al {Tech­ni­cal Guft­gu]

1- Preq­ui­sites for De­vOps

2- What is De­vOps , De­vOps Stages , Ag­ile

3- Ba­sics of AWS Cloud re­quired for De­vOps

4 Every­thing about Lin­ux from Scratch (ii)

Start­ed in 1964 at Bell Lab­o­ra­to­ry, New JEr­sey for mul­ti-user real time op­er­at­ing sys­tem

With­drawn in 1969
Den­nis Ritchie and Ken Thomp­son start UNICS (Uni­plexed In­for­ma­tion & Com­put­ing Ser­vices)

UNIX V6 was re­leased in 1975 which be­came very pop­u­lar


Dif­fer­ent bod­ies pro­duced dif­fer­ent of their own flavours of UNICS (E.g. IBM-AIX, MAC OS , HP _ UX)

A stu­dent , Li­nus Tor­valds pro­duced LIN­UX in Helsin­ki Uni­ver­si­ty, 1991.Note that LIN­UX is not a UNIX
de­riv­a­tive but mere­ly took in­spi­ra­tion from it
Pro­fes­sor An­drew Tanen­baum pro­duced MIN­UX for teach­ing pur­pos­es

GNU , a prod­uct of the Free Soft­ware move­ment, pro­duced as­so­ci­at­ed soft­ware for Lin­ux ker­nel to com­plete
Lin­ux op­er­at­ing sys­tem
(Lin­ux is orig­in
­ al­ly just ker­nel, not op­er­ar­ing sys­tem : The ker­nel refers to core soft­ware tjhat is re­spon­si­ble for
ac­cess­ing and di­rect­ly in­ter­act­ing with hard­ware com­po­nents of the sys­tem)
Lin­ux source code is free and open source , so any­one is free to pro­duce their own ver­sion of op­er­at­ing sys­tem
Sev­er­al com­pa­nies made their own ver­sion of lin­ux op­er­at­ing sys­tem (aka dis­tri­b­u­tions) - some com­mer­cial
and some open source as well. e.g. RHEL , Fe­do­ra, De­bian <ubun­tu , Cen­tOS, Ama­zon Lin­ux ,etc.
(Op­er­at­ing sys­tems can be op­er­at­ed ei­ther through CLI (Com­mand Line In­ter­face) or GUI (Graph­i­cal User
In­ter­face))

Lin­ux Fea­tures:

1. Open Source - The in­ter­nal source code is open­ly avail­able which al­lows a per­spi­ca­cious in­sight into the in­ner
work­ings and mech­a­nisms of the sys­tem from end user
2. Se­cure - Ad­vanced ac­cess con­trol , au­dit­ing of open source code and de­fence against virus­es' self-repli­cat­ing
mech­a­nism
3. Sim­pli­fied up­dates for all in­stalled soft­ware - Ef­fec­tive pack­age man­age­ment and in­stal­la­tion tools avail­able
which are much
4. Light weight - Dy­nam­ic­ al­ly loads ker­nel mod­ules. Takes less mem­o­ry and disk re­sources. Less bloat­ware.
5. Multi­user and Mul­ti­task­ing - Ad­vanced ac­cess con­trol and ad­vanced process con­trol and re­source shar­ing
mech­a­nisms
**6. Va­ri­ety of mul­ti­ple dis­tri­b­u­tions - ** Due to the open source na­ture, there is a great va­ri­ety of dis­tri­b­u­tions
avail­able. Users can in­stall dis­tri­b­u­tion which most suits them

5 - Every­thing about Lin­ux from Scratch (ii)

Win­dows Lin­ux

Hard­ware in­ter­acts with OS Hard­ware in­ter­acts with ker­nel

Shell is medi­um be­tween OS and user Shell is medi­um be­tween ker­nel and user

Fold­er Di­rec­to­ry

Ad­min­is­tra­tor root user

Soft­ware pack­age

The top lev­el di­rec­to­ry is /, which con­tains all files.


C:\ con­tains all sys­tem files - De­fault fold­ers in­clude
Root di­rec­to­ries in­clude /root , /home , /boot , /etc ,
'Pro­gram Files, Users , Pro­grams(x86) and Per­flogs
/usr and /bin

CLI tends to be faster and more ac­cu­rate than do­ing the same thing in GUI mode
A 'fold­er' in Lin­uc is re­ferred to as di­rec­to­ry

File sys­tem hi­er­ar­chy in Lin­ux

1. /home - home di­rec­to­ry of oth­er users

2. /root - home di­rec­to­ry for root user


3. /boot -Con­tains bootable files for lin­ux
4. /etc - con­tains all con­fig­u­ra­tion
5. /usr - soft­ware is in­stalled in this di­rec­to­ry by de­fault
6. /bin - con­tains com­mands used by all users
7. /sbin - con­tains com­mands used by only root user
8. /opt - Op­tion­al ap­pli­ca­tion soft­ware pack­ages
9. /dev - De­vice files . In­cludes ter­mi­nal de­vices, USBs

POST (Pow­er On Self Test) :

6 - Every­thing about Lin­ux from Scratch (iii) - Lin­ux com­mands and its
use cas­es

**How to cre­ate a file: **

1. cat
E.g.

cat > file1

1
Copy Copied

Here, file1 is the new file cre­at­ed. Any­thing en­tered into stdin is writ­ten into this file. To ter­mi­nate in­put , the
key­board short­cut Ctrl+D can be used which sends EOF (End-of-File char­ac­ter)
2. touch cre­ates an emp­ty file
3. vi / vim - one of the most pop­u­lar CLI ed­it­ors
4. nano - an­oth­er pop­u­lar CLI ed­it­or

sudo su - (su­pe­ruser-do switch-user) changes from


NOTE : Every­thing in lin­ux bash is case-sen­si­tive, stick to small­er let­ters most­ly

The cat com­mand

One of the most uni­ver­sal tools . It es­sen­tial­ly copies stan­dard in­put to stan­dard out­putThere are three main use
cas­es :

1. Cre­ate file: Cre­ate sin­gle file

cat > file1


Hello

1
2

Copy Copied

2. Con­cate­nate file: Con­cate­nate the con­tent of files


3. Copy files Copy­ing con­tent of one file to an­oth­er

The touch com­mand

Up­dates time­stampUse cas­es of touch :

1. Cre­ate an emp­ty file

touch file1

Copy Copied

(cre­ates emp­ty file file1 )


2. Cre­ate mul­ti­ple emp­ty files

touch file1

Copy Copied

(cre­ates emp­ty file file1 )


3. Change all time­stamps of a file
touch file2

Copy Copied

4. Up­date only ac­cess time of file, mod­if­y time of file

touch -a file1
touch -m file2

1
2

Copy Copied

(cre­ates emp­ty file file1 )Types of time­stamps:1.**Ac­cess time: ** ( Last time when user ac­cesed)

2. **Change time: ** ( Last time when file meta­da­ta was changed)


3. **Mod­if­ied time: ** (Last time when a file was mod­if­ied)

The vi ed­i­tor

A pro­gram­mer text ed­it­or


Can be used to edit any plain text. Es­pe­cial­ly use­ful for edit­ing pro­grams;
:w Saves file
:wq / :x Saves file and quits ed­it­or
:q Quits file
:q: Force­ful­ly quits, even if file is un­saved

The nano ed­i­tor

nano file_a

Copy Copied

cre­ates file_a if it doesn't al­ready ex­ist and opens it.


Con­tains in­struc­tions on key­baord short­cuts for sav­ing /ex­it­ing/ etc.

Demon­stra­tion

7 - Every­thing about Lin­ux from Scratch (iv)

mkdir com­mand

Cre­ates new di­rec­to­ry

mkdir dir1 dir2


1

Copy Copied

cre­ates new di­rec­to­ries dir1 and dir2

mkdir dir1/dir2/dir3

Copy Copied

cre­ates dir1 di­rec­to­ry , a dir2 in­side it and an­oth­er dir2 in­side it.

cd di­rec­to­ry

Change di­rec­to­ry com­mand

cd dir2

Copy Copied

switch­es to di­rec­to­ry dir2

cd ..

Copy Copied

changes di­rec­to­ry to .. (i.e. par­ent di­rec­to­ry)

pwd di­rec­to­ry

print work­ing di­rec­to­ry/ Shows cur­rent work­ing di­rec­to­ry.

pwd

Copy Copied

8 - Every­thing about Lin­ux from Scratch (v)

Any file/di­rec­to­ry which be­gins with . is hid­den, they can be shown us­ing ls only with -a flag

ls -a
1

Copy Copied

cp com­mand

Used for copy­ing files

cp file1 file2

Copy Copied

Copies file1 to file2

mv com­mand

Move files/di­rec­to­ries

mv file1 dir1

Copy Copied

moves file1 to dir1

rmdir com­mand

Com­mand for re­mov­ing spec­if­ied di­rec­to­ry (if emp­ty)

rmdir -p

Copy Copied

Re­move both men­tioned di­rec­to­ry and its par­ent di­rec­to­ry

rm com­mand

re­move files/di­rec­to­ries

rm -rf

Copy Copied

force­ful­ly re­moves all con­tents of di­rec­to­ry and its con­stituent sub­di­rec­to­ries and files re­cur­sive­ly

rm -rp
1

Copy Copied

re­cur­sive­ly re­move both di­rec­to­ry and its par­ent di­rec­to­ry.

Demon­stra­tion

9 - Every­thing about Lin­ux from Scratch (vi)

hostname com­mand

Re­veals de­tails about the cur­rent­ly run­ning ma­chine

hostname -i

1
2

Copy Copied

Demon­strates ver­sion name of OS

ifconfig com­mand

Shows IP ad­dress of the ma­chine.

yum pack­age man­ag­er

Yel­low­Dog Up­date Mod­i­fi­er (YUM)

yum install httpd -y

Copy Copied

In­stalls httpd pack­age to sys­tem. The -y flag auto-con­firms every prompt

yum remove httpd

Copy Copied

Re­moves httpd pack­a­gr

yum update httpd

Copy Copied
Up­dates httpd pack­age

yum list

Copy Copied

Show list of in­stalled pack­ages

Sys­tem ser­vices

service httpd start

Copy Copied

Ini­ti­ates httpd ser­vice

service httpd status

Copy Copied

Checks sta­tus of httpd ser­vice


chkconfig httpd on
chkconfig
chkconfig httpd off

echo com­mand

re­turns what­ev­er is sent as in­put as out­put.

echo "Hello"

Copy Copied

re­turns Hello to out­put.

echo "Welcome" >file1

Copy Copied

redi­rects in­put Welcome to file1 which is cre­at­ed if it doesn't al­ready ex­ist.

echo "Wilkommen" >> file1

1
Copy Copied

ap­pends in­put Wilkommne to file

grep com­mand

used for search­ing strings any­where , ap­plies reg­u­lar ex­pres­sion match­ing

sort com­mand

sorts out­put in al­pha­bet­ic­ al­ly as­cend­ing or­der

Demon­stra­tion

10 - Every­thing about Lin­ux from Scratch (vii)

User con­trol com­mands

useradd com­mand - Cre­ates user

useradd bhupinder

Copy Copied

cre­ates a new user named bhupinder . The users/ user­groups are saved in /etc/passwd
groupadd com­mand - Cre­ates user group

groupadd techguftgu

Copy Copied

cre­ates a new user­group called techguftgu . The user­groups are saved in /etc/group
gpasswd com­mand - Adds user to user­group

gpasswd -a aman techguftgu```


## Shortcut(symbolic link) commands
`ln` command - creates link
```bash
ln file2 backupfile2

2
3

4
5
6

Copy Copied

cre­ates a hard link backupfile2 for file2 while

ln -s file1 softfile1

Copy Copied

cre­ates a soft link softfile1 for file1


A soft link is iden­ti­cal to a short­cut in win­dows. Even if it is delet­ed, the orig­in
­ al file is un­af­fect­ed. A hard link cre­ates
a com­plete back­up copy of the giv­en file. It,how­ev­er, doesn't re­flect changes made to orig­in
­ al file.

File archiv­ing com­mands

tar com­mand - an archiv­er tool used to com­bine mul­ti­ple files into one.
gzip com­mand

tar -cvf dirx.tar dirx

Copy Copied

the flag -c , -v and -f stand for creak , ver­bose and force­ful­ly re­spec­tive­ly. The com­mand cre­ates a tar file
dirx.tar from the di­rec­to­ry dirx .

gzip dirx.tar

Copy Copied

Com­press­es the con­tents of dirx.tar into dirx.tar.gz

gunzip dirx.tar.gz

Copy Copied

tar -xvf dirx.tar

Copy Copied

The -x flag stands for ex­trac­tion


wget com­mand

Non-in­ter­ac­tive down­loader tool

Demon­stra­tion

Every­thing about Lin­ux from Scratch

Ac­cess con­trols in Lin­ux

Ac­cess mode File Di­rec­to­ry

r (4) To dis­play con­tent To list con­tent

w (2) To mod­if­y To cre­ate/re­move

x (1) To ex­e­cute the file To en­ter into di­rec­to­ry

drwxr_xr___ 1 root root 0 July 01 04:00PM dirx


The first char­ac­ter d sig­ni­fies that the giv­en file is a di­rec­to­ry. If it was a sym­bol­ic link, it would be l ; _ if it just a
file.
The next three char­ac­ters de­fine per­mis­sions for own­er/root user , the next three for user group and the last three
for oth­ers.
The per­mis­sions are de­fined by three char­ac­ters : r stands for read­able, w stands for writable and x stands for
ex­e­cutable.
Then fol­lows the own­er of the file/di­rec­to­ry and the user group of file/di­rec­to­ry and then the file size in bytes.
chmod com­mand - change ac­cess per­mis­sions of file/di­rec­to­ry

1 chmod 536 dirx

changes per­mis­sions od dirx to 536 ( equiv­a­lent of r_x_wxr_x)


An­oth­er way to al­ter these per­mis­sions :-

1 chmod u+x,g-w,o=rwx file1

This will add ex­e­cute per­mis­sions to user (if they al­ready dont have it), re­move write per­mis­sions from group (if
they have it) and set oth­ers' ac­cess con­trol to rwx.
chown com­mand - change own­er of file/di­rec­to­ry

1 chown bhupinder file1

chgrp com­mand - change group of file/di­rec­to­ry

1 chgrp main file1


11 - What is GIT /GitHub

Source Code Man­age­ment is nec­es­sary to en­sure ef­fi­cient col­lab­o­ra­tion for soft­ware pro­jects.
Be­fore the era of ver­sion con­trol, a man­ag­er had to in­di­vid­u­al­ly mon­it­or code as­signed to sev­er­al dif­fer­ent
per­son­nel.
There are two forms of code man­age­ment :

1. Cen­teal­ized Ver­sion Con­trol Sys­tem


2. Dis­trib­uted Ver­sion Con­trol Sys­tem

Note: Git is just a soft­ware/tool . Github and Git­lab are tools built on top of

12 - Three stages of Git - Work­ing di­rec­to­ry , stag­ing area and lo­cal


repos­i­to­ry

Git work­flow

1. Cre­ate your pro­ject di­rec­to­ry


2. Run git init in­side pro­ject repos­it­o­ry. This makes the di­rec­to­ry a lo­cal repos­it­o­ry and makes a .git file
3. This log­ic­ al­ly (as op­posed to phys­ic­ al­ly) con­verts your di­rec­to­ry into three di­vi­sions
4. Work­ing di­rec­to­ry

5. Stag­ing area
6. Lo­cal repo
7. The code you write first gets saved in work­ing di­rec­to­ry.
8. Stag­ing area is where pre­ma­ture code can be saved. It is not nec­es­sary but rec­om­mend­ed for or­gan­ised
work­flow. This can be done with git add .
9. git commit will save a snap­shot of code as it was and changes from last com­mit to lo­cal repo.

What is Github? - Not to be con­fused with Git, Github pro­vides a cen­tral repos­it­o­ry. It is owned by Mi­crosoft with
free pub­lic repos­it­o­ry stor­age.
Since GitHub was ac­quired by a ma­jor tech­nol­o­gy gi­ant, Git­Lab was launched as a com­plete­ly free al­ter­na­tive.
git push is used to push changes to lo­cal repos­it­o­ry into re­mote repos­it­o­ries (like those on GitHub).
git pull is used to pull changes on re­mote repos­it­o­ry to lo­cal repos­it­o­ry.
A code repos­it­o­ry may have mul­ti­ple branch­es, the de­fault branch is known as mas­ter branch.
Every com­mit cre­at­ed pro­duces a Com­mit ID and record of changes made then. Every­thing is kept trans­par­ent for
all col­lab­o­ra­tors to see.

Repos­it­o­ry

Repos­it­o­ry is where all code is stored as a di­rec­to­ry in serv­er.


The fold­er is par­tic­u­lar to the prod­uct

The Serv­er stores all repos­it­o­ries and con­tains all meta­da­ta. E.g. Mi­crosoft stores all GitHub data
All files can be phys­ic­ al­ly seen and worked upon in the work­ing di­rec­to­ry/ work­space.
l

In oth­er CVCS , there is no stag­ing area but di­rect com­mit-ing only from

Com­mit ID -

Ref­er­ence to iden­ti­fy each change.


Iden­ti­fies who changed file.
Tags:
These as­sign a mean­in­ful name with a spe­cif­ic ver­sion in the repos­it­o­ry. Once a tag is cre­at­ed for a par­tic­u­lar
save
Snap­shots

Rep­re­sens data state at par­tic­u­lar time.


It is in­cre­men­tal: in­stead of stor­ing en­tire data, only changes are stored
Push:
Push op­er­a­tions copies changes from lo­cal repos­it­o­ry to a re­mote / cen­tral repo. Changes are stored
per­ma­nent­ly into git repos­it­o­ry.
Pull:
Pull op­er­a­tion copies changes from a re­mote repos­it­o­ry to lo­cal ma­chine
Branch
Branch­es can be used to di­vide the work­flow by dif­fer­ent tasks. E.g. some­one is do­ing CSS styling and
back­end dvel­op­ment is han­dled sep­a­rate­ly. They can han­dle dif­fer­ent branch­es, which can be merged lat­er
when work is com­plete on both ends.
Each task can be giv­en one sep­a­rate branch

Fi­nal­ly all branch­es can be merged


Use­ful for par­al­lel work.
Can cre­ate one branch through an­oth­er branch.

Changes are per­son­al to the par­tic­u­lar branch.


De­fault branch is known as Mas­ter branch.
File cre­at­ed in work­space will be vis­ib
­ le in any of the branch­es.
Once com­mit­ed, changes will be­long to the par­tic­u­lar branch.
Ad­van­tages of Git
Free and Open ource

Fast and small in size


Ef­fec­tive Se­cu­ri­ty
Pow­er­ful hard­ware is not nec­es­sary
Easy branch­ing of code al­lows good com­part­men­tal­is­ a­tion
**Types of branch­es: **

1. Bare repos­it­o­ries
2. Non-bare repos­it­o­ries

Store and share only


A

Com­mit

Store changes in repos­it­o­ry : This is asigned a Com­mit ID.


It con­sists of 40 al­phanu­mer­ic char­ac­ters

It uses SHA-1 check­sum ver­if­i­ca­tion


Even if a sin­gle char­ac­ter is changed , Com­mit ID is al­tered as well.
Helps you track changes
Com­mit is also known as SHA-1 hash.

13 - How to in­stall git on AWS Lin­ux ma­chine

14 - How to add, com­mit in git

There

15 - How to cre­ate branch in git

Branch­es en­able par­al­lel work sep­a­rate from mas­ter branch.


A pro of paal­lel work is that mas­ter branch can be kept free from fa­tal er­rors which may oc­cur whilst work­ing on
oth­er branch­es.
While we make a branch, all data is copied as it is on the main branch it split from.
When want­ed, work done in the branch can be merged back into mas­ter/par­ent branch and work can fur­ther
con­tin­ue.
We can make as many branch­es as per task re­quire­ments

File cre­at­ed in work­space is vis­ib


­ le from all branch­es.

1 git branch

Shows list of all branch­es, and cur­rent branch

1 git log ---oneline

Shows log of com­mits in one line

1 git branch <branch-name>

Cre­ates new branch with branch-name

1 git checkout <branch-name>


switch to branch-name

1 git branch -d <branch-name>

Delete branch-name branch

1 git merge <branch-name

Merge branch-name with master branch

1 git log

Ver­if­y mes­sage of git

1 git push origin master

Push to cen­tral repo like GitHub

Git con­flict

When same files hav­ing dif­fer­ent con­tent in dif­fer­ent branch­es are merged, a con­flict emerges.

Git stash

Set aside files/changes for work­ing upon lat­er

1 git stash

stash­es an item

1 git stash list

See stashed items

1 git stash apply stash @[0]

Ap­ply stashed items

1 git stash clear

Clear stashed items


1 git reset

Demon­stra­tion

16 - What is git re­vert/ git­lab

17 - What is Chef in De­vOps(i)

Used to be han­dled by sys­tem en­gi­neer ear­li­er. Chef is used for au­toma­tion of sysad­min tasks be­fore,
eThere are two types of con­gi­fure man­age­ment tools :-

1. Oush vased tools that use push con­fig­u­ra­tion servers that push­es con­fig­u­ra­tion o the nodes. In­fra­struc­ture as
code ser­vices. Serv­er no­ti­fies about up­dates be­ing rolled out.
An­si­ble and are push based tools
2. Pull based tools - Pull con­fig­u­raion nodes. Reuces fault tore­ance.
E.g. Chef. Pup­pet

Too­lused for de­vops en­gi­neer de­vel­oped in ruby and er­lang.


Used to be called Mar­io
­ nette.
Made open source in 2019

Au­to­mates all tasks done by sysad­mins ear­li­er


Con­fig­u­ra­tion man­age­ment tools au­to­mate all sysad­min tasks
Code be­comes re­peat­able, testable and ver­sion­able.
-Ad­v­nat­ges of such tools

1. Com­plete au­toma­tion
2. Re­duced down­times
3. Imorive per­for­mance

4. En­sure com­pli­ance
5. Pre­vent er­rors
6. Re­duce costs

Chef ar­chi­tec­ture

Con­sists of:

1. Work­sta­tion - Code is worked on here. Code grouped to­geth­er may be termed as recipes. Cook­book is a
col­lec­tion of recipes.
2. Chef serv­er - Cook­books are stored here. It id con­nect­ed to chef serv­er by a CLI tool known as knife
3. Mode serv­er -
**chef suo­er­mar­ket ** con­tains sev­er­al chef cook­books.

0 Work­sta­tions are per­son­al compyters


De­vops en­gi­neers op­er­ate from chef serv­er.
Mi­dle­man be­tween node serv­er and work­sta­tion.
Node are where codes are ac­tu­al­ly ap­plied.
Ohai fetch­es cur­rent state of node.

18 - What is Chef in De­vOps(ii)

How to cre­ate cook­book and Recipes

Cre­ate a Lin­ux Ma­chine in AWS


Use PuT­Ty

1 which chef

1 chef --version

check which ver­sion of chef you have

Cook­books

It is a col­lec­tion of recipes and some oth­er files and fold­ers


Con­tents of a cook­book:-

1. .chefignore - Sim­il­ar to func­tions of .gitignore


2. Kitchenyml

3. Metadata.rb
4. Readme.md
5. Recipes

6. Specs
7. Tests -

1 chef generate cookbook

1 generate-recipe <name>

Ruby recipe code struc­ture:

1 File do
2 content
3 action Create
4 end
Ruby recipe for soft­ware in­stal­la­tion could be

1 package 'tree' do
2 action install
3 end

Chef does not over­write any­thing if a recipe is run mul­ti­ple times.

1 chef-client -zr "recipe[test-cookbook "recipe-name"]"

1 chef exec ruby -c <path of chef recipe>

Re­source

Ba­sic Com­po­nent of a recipe used to man­age the in­fra­struc­ture with dif­fer­ent kind of states. There can be mul­ti­ple
re­sources in a recipe, which will help in con­fig­ur­ing and man­ag­ing in­fra­struc­ture.
Some re­sources are:

1. Pack­age - Man­ages pack­ages on a node


2. Ser­vice - Man­ages ser­vices on a node
3. User - Man­ages users on the node
4. Group - Man­ages groups

5. Tem­plate - Man­ages file with em­bed­ded ruby tem­plate


6. Cokkbook.file - Trans­fers the files from the files sub­di­rec­to­ry in the cook­book to a lo­ca­tion on the node
7. File - Man­ages the con­tent of a file on the node
8. ex­e­cute - ex­e­cutes a com­mand on the node

9. cron - Edit an ex­ist­ing cron file on the node


10. di­rec­to­ry - man­ages di­rec­to­ry on a node

Demon­stra­tion

57c5945428bb341b0946f2c7ad5837f2.png
5412f89fcac8e1aa16eb394dd36536ba.png

19 - What is at­tribute in CHEF

Helps dis­tin­guish fea­tures of sev­er­al dif­fer­ent node servers run­ning.

At­tribute is a key-val­ue pair whch rep­re­sents a spe­cif­ic de­tail about a node

An at­tribute can help us find out

Cur­rent state of node


What the state of a node was af­ter the end of pre­vi­ous chef-client run
what state of a node should be at the end of the cur­rent chef-client run

Types of at­tribute (n ncas­ing pri­orty)

de­fault
force=de­fault

nor­mal
Over­ride
force-over­ride
au­to­mat­ic

At­trib­ut­es de­fined by Ohai have the high­est pri­orty, fol­lowed by at­trib­ut­es , fol­lowed by those de­fined by at­tribute
files

20 - Chef recipes

21 - Boot­strap­ping in CHEF

22 - Roles in CHEF

23 - In­tro­duc­tion to Dock­er

24 - OS Lev­el vir­tu­al­i­sa­tion in Dock­er

Dock­er is an open source cen­tralised plat­form


Dock­er per­ofmrs OS-lev­el vir­tu­al­is­ a­tion while VMware per­forms hard­ware-lev­el vir­tu­al­is­ a­tion

Vir­tu­al­i­sa­tion in VMWare schema : Hy­per­vi­sor is built upon Hard­ware. The VM takes all re­sources from
hard­ware.

Con­tainer­iza­tion in Dock­er : Dock­er is in­stalled on top of host OS. Based upon con­tain­ers rather than vir­tu­al
ma­chines which con­tain UNIX based op­er­at­ing sys­tems. Con­tain­er im­ages can be pulled from an on­line repos­it­o­ry
called Dock­er Hub. Most code of UNIX like dis­tros are sim­il­ar, the con­tain­er-spe­cif­ic code is ob­tained from Dock­er
Hub. A con­tain­er is very light weight com­pared to a vir­tu­al ma­chine as only mar­gin­al op­er­at­ing sys­tem files
nec­es­sary for boot­ing and run­ning the sys­tem is re­quired.

25 - Dock­er - ar­chi­tec­ture, pros and cons

Ad­van­tages of Dock­er:

No pre-al­lo­ca­tion of RAM - Un­like vir­tu­al ma­chines. When n im­age is run, it is re­ferred to as a con­tain­er.
In­creased ef­fi­cien­cy of Con­tin­u­ous In­te­gra­tion - Dock­er re­moves de­pen­den­cy on plat­form and hard­ware

Low­er costs - Since there is no pe-al­lo­ca­tion of RAM


Light weight
Can

In or­der to run Dock­er on win­dows , you will need to en­able vir­tu­al­is­ a­tion and hy­per­vi­sor. Dock­er is main­ly
de­signed for Lin­ux sys­tems.

Changes to a con­tain­er can be saved to im­ages.

Dis­ad­van­tages of Dock­er

Not great for cross-plat­form com­pat­ib


­ il­it­y.
Not a good so­lu­tion for ap­pli­ca­tions re­quir­ing GUI

Suit­able when dvelop­ing OS and test­ing OS is same

Dock­er ar­chi­tec­ture

A dock­er­file plays the same role which is played by cook­book in Chef. The dock­er­file makes an im­age and in­stalls
de­pen­den­cies and re­quire­ments as men­tioned. A con­tain­er is pro­duced from the im­age. The con­tain­er may be
pub­lished to Dock­er Hub (a.k.a. reg­istry) as an im­age. It can be pulled by oth­er users as re­quired.

A con­tain­er has a lay­ered file sys­tem, which has its process­es run lay­er-by-lay­er.

Dock­er ecosys­tem

1. Dock­er Client - The end user of Dock­er


2. Dock­er dae­mon - ex­e­cutes com­mands and pro­duces im­ages

3. Dock­er Hub - Re­mote stor­age for keep­ing im­ages


4. Dock­er Im­ages - tem­plates for run­ning con­tain­ers
5. Dock­er com­pose - Man­ag­ing and run­ning sev­er­al im­ages at once

Dock­er Host - used to pro­vide an en­vi­ron­ment to ex­e­cute and run ap­pli­ca­tions . Con­tains the whole dock­er
ecosys­tem.

Dock­er reg­istry man­ages and stores dock­er im­ages.There are two types of reg­istry in Dock­er:

1. Pub­lic Reg­istry
2. Pri­vate reg­istry - For use with­in en­ter­prise

Dock­er Im­ages are bi­na­ry read-only tem­plates re­quired to run con­tain­ers.

There are three ways to cre­ate im­ages:

1. Take im­age from Dock­er Hub


2. Cre­ate your own im­age from Dock­er­file
3. Cre­ate im­age from ex­ist­ing dock­er con­tain­er

Dock­er Con­tain­er - a copy of the im­age it was cre­at­ed from. Hold all es­sen­tial pack­ages in or­der to run an
ap­pli­ca­tion.
26 - Us­ing dock­er - run­ning/stop­ping con­tain­ers

27 - Dock­er­file cre­ation

docker diff com­mand

1 docker diff <Container1> <Container2>

Find the dif­fer­ence be­tween <Con­tain­er1> and <Con­tain­er2>


Out­op­ut shown shows three types of changes:-

1. C (Change)
2. A (Ap­pend)
3. D (Delete)

1 docker commit <ContainerName> <ImageName>

Cre­ates new im­age of con­tain­er.

1 docker run -it --name <ContainerName> <UpdatedContainer> /bin/bash

Dock­er­file

A text file con­tain­ing a set of in­struc­tions


Au­to­mates dock­er im­age cre­ation
Dock­er com­ponenets

1. FROM
Base im­age on top of which im­age is be­ing cre­at­ed. A dock­er­file al­ways starts with this
2. RUN
Ex­e­cutes com­mands. This also pro­duces lay­ers in im­age
3. MAIN­TAIN­ER
Pro­vides in­for­ma­tion about au­thor and con­trib­u­tors
4. COPY
Copy files from lo­cal sys­tem to con­tain­er
5. ADD
Sim­il­ar func­tion to COPY , but also ca­pa­ble of down­load­ing off in­ter­net and un­pack­ing/ex­tract­ing archived
di­rec­to­ries
6. EX­POSE
Ex­pos­es ports for net­work­ing
7. WORKDIR
Set work di­rec­to­ry for con­tain­er
8. CMD
Ex­e­cute com­mands dur­ing con­tain­er cre­ation
9. EN­TRY­POINT
Like CMD, but with high­er pri­orty. En­sures se­quence of com­mands be­ing ex­e­cut­ed
10. ENV
set en­vi­ron­ment vari­ables

1 docker build

Used for build­ing im­ages from dock­er­file

Demo

28 - Dock­er Vol­ume

Vol­ume is just a di­rec­to­ry where con­tain­er run­time in­for­ma­tion may be per­sis­tent­ly stored. It en­ables shar­ing of
in­for­ma­tion among mul­ti­ple con­tain­ers.

A di­rec­to­ry is just de­clared as a vol­ume, then the vol­ume can be shared


Even if con­tain­er is stopped, vol­ume is ac­ces­si­ble.
In­for­ma­tion from a con­tain­er stored in a vol­ume can be shared with any con­tain­er
Vol­umes can't be cre­at­ed from ex­ist­ing con­tain­ers
Vol­ume is not in­clud­ed when an im­age is up­dat­ed.
Vol­umes can be mapped in two ways: Con­tain­er <-> Con­tain­er, Host <-> Con­tain­er

Vol­ume will act as sim­ply just an­oth­er di­rec­to­ry if it is not linked up with con­cerned con­tain­er.

Ben­e­fits of us­ing vol­umes

De­cou­pling con­tain­ers from stor­age


Share vol­ume among dif­fer­ent con­tain­ers
At­tach vol­umes to con­tain­er
Upon delet­ing con­tain­ers, vol­umes are not delet­ed

1 docker

29 - Dock­er port map­ping, Dock­er ex­pose

IP ad­dress­ing ba­sics

Every net­work­ing process has a port as­signed to it to unique­ly iden­ti­fy it.

Dock­er IP net­work­ing

Ports can be mapped from host to con­taine


To ac­com­plish this, cer­tain ports of a con­tain­er are set as ex­posed

1 docker run -td --name techserver -p 80:80 Ubuntu

would map port num­ber 80 of host to the tech­serv­er ubun­tu con­tain­er.

1 docker port techserver - 80


2
3
4 # 30 - What is dock­er hub and how it works
5
6 # 31 - An­si­ble in­tro­duc­tion and work­
ing
7
8 # 32 -
9
10 # 33 -
11
12 # 34 -
13
14 # 35 -
15
16 # 36 -
17
18 # 37 -
19
20 # 38 - Jenkins and Maven basics
21
22 # 39 -
23
24 # 40 -
25
26 # 41 -
27
28 # 42 -
29
30 # 43 - Nagios Continuous Monitoring Tool
31
32 # 44 - Nagios setup on Linux
33
34 # 45 - Ku­ber­netes in­tro­duc­tion
35
36 # 46 - Ku­ber­netes ar­chi­tec­ture
37
38 # 47 -
39
40 # 48 -
41
42 # 49 -
43
44 # 50
45
46 # 51 - Kubernetes Networking
47
48 # 52 -
49
50 # 53 -
51
52 # 54 -
53
54 # 55 -
55
56 # 56 -
57
58 # 57 - What is Helm | HELM chart
59
60 # 58 - Helm in­stal­la­tion and com­
mands

You might also like