DevOps Tutorial (Technical Guftgu)
DevOps Tutorial (Technical Guftgu)
Started in 1964 at Bell Laboratory, New JErsey for multi-user real time operating system
Withdrawn in 1969
Dennis Ritchie and Ken Thompson start UNICS (Uniplexed Information & Computing Services)
A student , Linus Torvalds produced LINUX in Helsinki University, 1991.Note that LINUX is not a UNIX
derivative but merely took inspiration from it
Professor Andrew Tanenbaum produced MINUX for teaching purposes
GNU , a product of the Free Software movement, produced associated software for Linux kernel to complete
Linux operating system
(Linux is origin
ally just kernel, not operaring system : The kernel refers to core software tjhat is responsible for
accessing and directly interacting with hardware components of the system)
Linux source code is free and open source , so anyone is free to produce their own version of operating system
Several companies made their own version of linux operating system (aka distributions) - some commercial
and some open source as well. e.g. RHEL , Fedora, Debian <ubuntu , CentOS, Amazon Linux ,etc.
(Operating systems can be operated either through CLI (Command Line Interface) or GUI (Graphical User
Interface))
Linux Features:
1. Open Source - The internal source code is openly available which allows a perspicacious insight into the inner
workings and mechanisms of the system from end user
2. Secure - Advanced access control , auditing of open source code and defence against viruses' self-replicating
mechanism
3. Simplified updates for all installed software - Effective package management and installation tools available
which are much
4. Light weight - Dynamic ally loads kernel modules. Takes less memory and disk resources. Less bloatware.
5. Multiuser and Multitasking - Advanced access control and advanced process control and resource sharing
mechanisms
**6. Variety of multiple distributions - ** Due to the open source nature, there is a great variety of distributions
available. Users can install distribution which most suits them
Windows Linux
Shell is medium between OS and user Shell is medium between kernel and user
Folder Directory
Software package
CLI tends to be faster and more accurate than doing the same thing in GUI mode
A 'folder' in Linuc is referred to as directory
6 - Everything about Linux from Scratch (iii) - Linux commands and its
use cases
1. cat
E.g.
1
Copy Copied
Here, file1 is the new file created. Anything entered into stdin is written into this file. To terminate input , the
keyboard shortcut Ctrl+D can be used which sends EOF (End-of-File character)
2. touch creates an empty file
3. vi / vim - one of the most popular CLI editors
4. nano - another popular CLI editor
One of the most universal tools . It essentially copies standard input to standard outputThere are three main use
cases :
1
2
Copy Copied
touch file1
Copy Copied
touch file1
Copy Copied
Copy Copied
touch -a file1
touch -m file2
1
2
Copy Copied
(creates empty file file1 )Types of timestamps:1.**Access time: ** ( Last time when user accesed)
The vi editor
nano file_a
Copy Copied
Demonstration
mkdir command
Copy Copied
mkdir dir1/dir2/dir3
Copy Copied
creates dir1 directory , a dir2 inside it and another dir2 inside it.
cd directory
cd dir2
Copy Copied
cd ..
Copy Copied
pwd directory
pwd
Copy Copied
Any file/directory which begins with . is hidden, they can be shown using ls only with -a flag
ls -a
1
Copy Copied
cp command
cp file1 file2
Copy Copied
mv command
Move files/directories
mv file1 dir1
Copy Copied
rmdir command
rmdir -p
Copy Copied
rm command
remove files/directories
rm -rf
Copy Copied
forcefully removes all contents of directory and its constituent subdirectories and files recursively
rm -rp
1
Copy Copied
Demonstration
hostname command
hostname -i
1
2
Copy Copied
ifconfig command
Copy Copied
Copy Copied
Copy Copied
Updates httpd package
yum list
Copy Copied
System services
Copy Copied
Copy Copied
echo command
echo "Hello"
Copy Copied
Copy Copied
1
Copy Copied
grep command
sort command
Demonstration
useradd bhupinder
Copy Copied
creates a new user named bhupinder . The users/ usergroups are saved in /etc/passwd
groupadd command - Creates user group
groupadd techguftgu
Copy Copied
creates a new usergroup called techguftgu . The usergroups are saved in /etc/group
gpasswd command - Adds user to usergroup
2
3
4
5
6
Copy Copied
ln -s file1 softfile1
Copy Copied
tar command - an archiver tool used to combine multiple files into one.
gzip command
Copy Copied
the flag -c , -v and -f stand for creak , verbose and forcefully respectively. The command creates a tar file
dirx.tar from the directory dirx .
gzip dirx.tar
Copy Copied
gunzip dirx.tar.gz
Copy Copied
Copy Copied
Demonstration
This will add execute permissions to user (if they already dont have it), remove write permissions from group (if
they have it) and set others' access control to rwx.
chown command - change owner of file/directory
Source Code Management is necessary to ensure efficient collaboration for software projects.
Before the era of version control, a manager had to individually monitor code assigned to several different
personnel.
There are two forms of code management :
Note: Git is just a software/tool . Github and Gitlab are tools built on top of
Git workflow
5. Staging area
6. Local repo
7. The code you write first gets saved in working directory.
8. Staging area is where premature code can be saved. It is not necessary but recommended for organised
workflow. This can be done with git add .
9. git commit will save a snapshot of code as it was and changes from last commit to local repo.
What is Github? - Not to be confused with Git, Github provides a central repository. It is owned by Microsoft with
free public repository storage.
Since GitHub was acquired by a major technology giant, GitLab was launched as a completely free alternative.
git push is used to push changes to local repository into remote repositories (like those on GitHub).
git pull is used to pull changes on remote repository to local repository.
A code repository may have multiple branches, the default branch is known as master branch.
Every commit created produces a Commit ID and record of changes made then. Everything is kept transparent for
all collaborators to see.
Repository
The Server stores all repositories and contains all metadata. E.g. Microsoft stores all GitHub data
All files can be physic ally seen and worked upon in the working directory/ workspace.
l
In other CVCS , there is no staging area but direct commit-ing only from
Commit ID -
1. Bare repositories
2. Non-bare repositories
Commit
There
1 git branch
1 git log
Git conflict
When same files having different content in different branches are merged, a conflict emerges.
Git stash
1 git stash
stashes an item
Demonstration
Used to be handled by system engineer earlier. Chef is used for automation of sysadmin tasks before,
eThere are two types of congifure management tools :-
1. Oush vased tools that use push configuration servers that pushes configuration o the nodes. Infrastructure as
code services. Server notifies about updates being rolled out.
Ansible and are push based tools
2. Pull based tools - Pull configuraion nodes. Reuces fault toreance.
E.g. Chef. Puppet
1. Complete automation
2. Reduced downtimes
3. Imorive performance
4. Ensure compliance
5. Prevent errors
6. Reduce costs
Chef architecture
Consists of:
1. Workstation - Code is worked on here. Code grouped together may be termed as recipes. Cookbook is a
collection of recipes.
2. Chef server - Cookbooks are stored here. It id connected to chef server by a CLI tool known as knife
3. Mode server -
**chef suoermarket ** contains several chef cookbooks.
1 which chef
1 chef --version
Cookbooks
3. Metadata.rb
4. Readme.md
5. Recipes
6. Specs
7. Tests -
1 generate-recipe <name>
1 File do
2 content
3 action Create
4 end
Ruby recipe for software installation could be
1 package 'tree' do
2 action install
3 end
Resource
Basic Component of a recipe used to manage the infrastructure with different kind of states. There can be multiple
resources in a recipe, which will help in configuring and managing infrastructure.
Some resources are:
Demonstration
57c5945428bb341b0946f2c7ad5837f2.png
5412f89fcac8e1aa16eb394dd36536ba.png
default
force=default
normal
Override
force-override
automatic
Attributes defined by Ohai have the highest priorty, followed by attributes , followed by those defined by attribute
files
20 - Chef recipes
21 - Bootstrapping in CHEF
22 - Roles in CHEF
23 - Introduction to Docker
Virtualisation in VMWare schema : Hypervisor is built upon Hardware. The VM takes all resources from
hardware.
Containerization in Docker : Docker is installed on top of host OS. Based upon containers rather than virtual
machines which contain UNIX based operating systems. Container images can be pulled from an online repository
called Docker Hub. Most code of UNIX like distros are similar, the container-specific code is obtained from Docker
Hub. A container is very light weight compared to a virtual machine as only marginal operating system files
necessary for booting and running the system is required.
Advantages of Docker:
No pre-allocation of RAM - Unlike virtual machines. When n image is run, it is referred to as a container.
Increased efficiency of Continuous Integration - Docker removes dependency on platform and hardware
In order to run Docker on windows , you will need to enable virtualis ation and hypervisor. Docker is mainly
designed for Linux systems.
Disadvantages of Docker
Docker architecture
A dockerfile plays the same role which is played by cookbook in Chef. The dockerfile makes an image and installs
dependencies and requirements as mentioned. A container is produced from the image. The container may be
published to Docker Hub (a.k.a. registry) as an image. It can be pulled by other users as required.
A container has a layered file system, which has its processes run layer-by-layer.
Docker ecosystem
Docker Host - used to provide an environment to execute and run applications . Contains the whole docker
ecosystem.
Docker registry manages and stores docker images.There are two types of registry in Docker:
1. Public Registry
2. Private registry - For use within enterprise
Docker Container - a copy of the image it was created from. Hold all essential packages in order to run an
application.
26 - Using docker - running/stopping containers
27 - Dockerfile creation
1. C (Change)
2. A (Append)
3. D (Delete)
Dockerfile
1. FROM
Base image on top of which image is being created. A dockerfile always starts with this
2. RUN
Executes commands. This also produces layers in image
3. MAINTAINER
Provides information about author and contributors
4. COPY
Copy files from local system to container
5. ADD
Similar function to COPY , but also capable of downloading off internet and unpacking/extracting archived
directories
6. EXPOSE
Exposes ports for networking
7. WORKDIR
Set work directory for container
8. CMD
Execute commands during container creation
9. ENTRYPOINT
Like CMD, but with higher priorty. Ensures sequence of commands being executed
10. ENV
set environment variables
1 docker build
Demo
28 - Docker Volume
Volume is just a directory where container runtime information may be persistently stored. It enables sharing of
information among multiple containers.
Volume will act as simply just another directory if it is not linked up with concerned container.
1 docker
IP addressing basics
Docker IP networking