0% found this document useful (0 votes)
11 views53 pages

Cours DEVOPS

cours DEVOPS

Uploaded by

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

Cours DEVOPS

cours DEVOPS

Uploaded by

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

Trainer MABROUK Houssem Eddine August 2021

C2 – Usage restreint
Plan


What is DevOps?

DevOps life cycle

Containerization

Source control Mnagement

CI/CD

2
C2 – Usage restreint
What is DevOps ?

3
C2 – Usage restreint
What is DevOps ?

Definitions
DevOps is a set of software development practices that combines software development
(Dev) and information technology operations (Ops) to shorten the system development life
cycle while delivering features, fixes and update frequently in close alignment with
business objectives.[wikipedia]

DevOps is the combination of cultural philosophies, practices, and tools that increases an
organization’s ability to deliver applications and services at high velocity: evolving and
improving products at a faster pace than organizations using traditional software
development and infrastructure management processes. This speed enables organizations
to better serve their customers and compete more effectively in the market.[ Amazon]

DevOps is the union of people, process, and technology to enable continuous delivery of
value to customers. DevOps, a compound of dev (development) and ops (operations), is a
software development practice that unifies development and IT operations. The meaning
signifies coordination and collaboration among formerly siloed disciplines. Quality
engineering and security teams also become part of the broader team in the DevOps
model.[Microsft azure]

4
C2 – Usage restreint
DevOps Life Cycle

5
C2 – Usage restreint
DevOps Life Cycle

6
C2 – Usage restreint
DevOps life cycle


Plan: Initially plan yourself regarding the type of application you need to develop. Make the rough
picture regarding the development process

Code: Code the application as per the client requirement. with the plan, you have made in the
initial step.

Build: Build the application by performing the integration of various codes you have done in the
previous step.

Test: This is the heart of the application. Test the application that you have built so far. And the
rebuilt the application if necessary.

Releases: If you succeed in the Test phase, then its time to release the application into Live.
Deploy: Deploy the code into a cloud environment for further usage. It is performed in such a

manner any changes made should not affect the functioning of high traffic website.

Operate: Perform the operation on the code if any have.

Monitor: Monitor the performance of the application as per the client requirement. Keep a note on
the performance of the application. Make modifications if any to satisfy the clients. And if does not
reach up to the mark make changes in that particular area to satisfy the client. 7
C2 – Usage restreint
DevOps tools

12

10

0
Row 1 Row 2 Row 3 Row 4

8
C2 – Usage restreint
DevOps Tools/fields

9
C2 – Usage restreint
Containerization

10
C2 – Usage restreint
Containerization

What is a Container?

Designed to make make easy to create, deploy, and run applications by
using containers.

Containers package up an application with all of the parts it needs.

Containers allow applications to run on any Linux machine regardless
of configuration.

Applications run in a loosely isolated environment called containers.

Containers are lightweight.

11
C2 – Usage restreint
Containerization

Docker Container
Docker is an open platform for developing, shipping, and running
applications.
Docker enables you to separate your applications from your infrastructure
so you can deliver software quickly. With Docker, you can manage your
infrastructure in the same ways you manage your applications.
By taking advantage of Docker’s methodologies for shipping,
testing, and deploying code quickly, you can significantly reduce the delay
between writing code and running it in production.
12
C2 – Usage restreint
Containerization

Docker Container
Docker containers include the application and all of its dependencies,
but share the kernel with other containers, running as isolated
processes in user space on the host operating system. Docker
containers are not tied to any specific infrastructure: they run on any
computer, on any infrastructure, and in any cloud.

13
C2 – Usage restreint
Containerization

Docker Container
Cgroups:
(abbreviated from control groups) is a Linux kernel feature that limits,
accounts for, and isolates the resource usage (CPU, memory, disk I/O, network,
etc.) of a collection of processes.

14
C2 – Usage restreint
Containerization

Docker Container
Namespaces
Provide the isolated work space called the container. When you run a container,
Docker creates a set of namespaces for that container.
These namespaces provide a layer of isolation. Each aspect of a container runs
in a separate namespace and its access is limited to that namespace.

15
C2 – Usage restreint
Containerization

Container vs VM

16
C2 – Usage restreint
Containerization

Platforms:
Docker runs on only Linux and Cloud platforms
Ubuntu 12.04, 13.04 et al
Fedora 19/20+
RHEL 6.5+
CentOS 6+
openSUSE 12.3+
CRUX 3.0+
Cloud:
Amazon EC2
Google Compute Engine
Microsoft Azure

17
C2 – Usage restreint
Containerization

How to install docker?



1-Install needed packages:

$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2

2-Configure the docker-ce repo:

$ sudo yum-config-manager --add-repo
https://download.docker.com/linux/centos/docker-ce.repo

3-Install docker-ce:

$ sudo yum install docker-ce

4-Start the Docker service:

$ sudo systemctl start docker

$ sudo systemctl start docker
18
C2 – Usage restreint
Containerization

Docker Engine Architecture


Client-server application


The server runs as a deamon process

REST API

A command interface (CLI) client

19
C2 – Usage restreint
Containerization

Docker Features

20
C2 – Usage restreint
Containerization

Container Life Cycle

21
C2 – Usage restreint
Containerization

Docker hub
Docker hub is a cloud-based registry service which allows you to link to code

repositories, build your images and test them, stores manually pushed images,

and links to Docker cloud so you can deploy images to your hosts.

It provides a centralized resource for container image discovery,

distribution and change management, user and team collaboration,

and workflow automation throughout the development pipeline.

22
C2 – Usage restreint
Containerization

Push/Pull images
1- docker login --username username --password password

2- docker tag my-image username/my-repo

3- docker push username/my-repo

23
C2 – Usage restreint
Containerization

Dockerfile
A Dockerfile is a text file that defines a Docker image. You’ll use a Dockerfile to
create your own custom Docker image, in other words to define your custom
environment to be used in a Docker container.

1- Create the Dockerfile and define the steps that build up your images
2- Issue the docker build command which will build a Docker image from your
Dockerfile
3- Use this image to start containers with the docker run command

24
C2 – Usage restreint
Containerization

25
C2 – Usage restreint
Containerization

Example

1- $ mkdir -p docker/images
2- $ cd /docker/images
3-$ vi Dockerfile
FROM nginx
WORKDIR /usr/share/nginx/html
COPY index.html ./

26
C2 – Usage restreint
Containerization

Example

27
C2 – Usage restreint
Containerization

Example
4- $ vi index.html
<html>
<header>
<title> hello </title>
</header>
<body>
Hello DevOps Engineer !
</body>
</html>
5- $ docker build . -t firstim:latest
6- $ docker images
7- $ docker run -d – name static- site -p 80:80 firstim:latest

28
C2 – Usage restreint
Containerization

Example
8- $ docker ps

9- $ curl http://localhost

29
C2 – Usage restreint
Containerization

Example
10- $ docker exec -it static-site /bin/bash

-i short for -interactive, this ensures STDIN is kept open even if not attached
to the running container

-t, which can also be referenced with -tty , starts an interactive bash shell in
the container

30
C2 – Usage restreint
Containerization

Exercice
1-Downloading a MySQL Server Docker Image
docker pull mysql/mysql-server:tag
docker images
2-Starting a MySQL Server Instance
docker run --name=mysql1 -d mysql/mysql-server:tag
docker ps
docker logs mysql1 2>&1 | grep GENERATED
3- Connecting to MySQL Server from within the Container
docker exec -it mysql1 mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
31
C2 – Usage restreint
Containerization

Exercice

4- Container Shell Access

docker exec -it mysql1 bash

5-Stopping and Deleting a MySQL Container

docker stop mysql1

docker start mysql1

docker restart mysql1


32
docker rm mysql1
C2 – Usage restreint
Containerization

Docker Volume

Volumes are the preferred mechanism for persisting data generated by and used by
Docker containers.

Volumes are completely managed by Docker.

Volumes are easier to back up or migrate than bind mounts.

Volumes are managed using Docker CLI commands or the Docker API.

Volumes can be more safely shared among multiple containers.

Volume drivers let you store volumes on remote hosts or cloud providers, to encrypt
the contents of volumes, or to add other functionality.

Volumes are often a better choice than persisting data in a container’s writable layer,
because a volume does not increase the size of the containers using it.

33
C2 – Usage restreint
Containerization

Docker Volume
Use -v or –volume

In the case of named volumes, the first field is the name of the volume, and is unique

on a given host machine. For anonymous volumes, the first field is omitted.

The second field is the path where the file or directory are mounted in the container.

The third field is optional, and is a comma-separated list of options, such as ro.

These options are discussed below.

34
C2 – Usage restreint
Containerization

Example
1- $ docker run -d –name=devtest -v devtest-vol:/app nginx:latest

2- $ docker ps

3- $ docker volume inspect devtest-vol


35
C2 – Usage restreint
Containerization

Docker Network
The Docker native network drivers are part of Docker Engine and don't require any extra
modules. They are invoked and used through standard docker network commands.
The following native network drivers exist.

bridge: The default network driver. If you don’t specify a driver, this is the type of network
you are creating. Bridge networks are usually used when your applications run in
standalone containers that need to communicate.

host: For standalone containers, remove network isolation between the container and

the Docker host, and use the host’s networking directly. There is no namespace separation,

and all interfaces on the host can be used directly by the container

36
C2 – Usage restreint
Containerization

Docker Network

overlay: Overlay networks connect multiple Docker daemons together and enable
swarm services to communicate with each other.

macvlan: Macvlan networks allow you to assign a MAC address to a container,
making it appear as a physical device on your network. The Docker daemon routes
traffic to containers by their MAC addresses. Using the macvlan driver is sometimes
the best choice when dealing with legacy applications that expect to be directly
connected to the physical network, rather than routed through the Docker host’s network
stack.

none: The none driver gives a container its own networking stack and network

namespace but does not configure interfaces inside the container. Without additional

configuration, the container is completely isolated from the host networking stack 37
C2 – Usage restreint
Containerization

Microservices Architectures
Is an architectural style that structures an application as a collection of services that are

Highly maintainable and testable

Loosely coupled

Independently deployable

Organized around business capabilities.

The microservice architecture enables the continuous delivery/deployment of large,
complex applications.

It also enables an organization to evolve its technology stack.


38
C2 – Usage restreint
Containerization

Docker Compose
Is a tool for defining and running multi-container Docker applications. With Compose,

you use a YAML file to configure your application’s services. Then, with a single command,

you create and start all the services from your configuration. To learn more about all the

features of Compose.

Compose works in all environments: production, staging, development, testing, as well

as CI workflows.

39
C2 – Usage restreint
Containerization

Docker Compose
Using Compose is basically a three-step process:

Define your app’s environment with a Dockerfile so it can be reproduced anywhere.

Define the services that make up your app in docker-compose.yml so they can be run

together in an isolated environment.



Run docker-compose up and Compose starts and runs your entire app.

40
C2 – Usage restreint
Containerization

Docker Compose

41
C2 – Usage restreint
Containerization

Docker Compose
version: '3'
services:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code
- logvolume01:/var/log
links:
- redis
redis:
image: redis
volumes:
logvolume01: {}
42
C2 – Usage restreint
Containerization

Docker Swarm
Docker Swarm is a clustering and scheduling tool for docker containers.

With Swarm, IT administrators and developers can establish and manage

a cluster of Docker nodes as a single virtual system.

43
C2 – Usage restreint
Source Control
Management

44
C2 – Usage restreint
Source Control Management

SCM
Source control (or version control) is the practice of tracking and managing

changes to code. Source control management (SCM) systems provide

a running history of code development and help to resolve conflicts when

merging contributions from multiple sources.

45
C2 – Usage restreint
Source Control Management

SCM

46
C2 – Usage restreint
Source Control Management

Git
Git is a distributed revision control and source code management system

with an emphasis on speed. Git was initially designed and developed by

Linus Torvalds for Linux kernel development. Git is a free software distributed

under the terms of the GNU General Public License version.

47
C2 – Usage restreint
Source Control Management

How to install & configure Git?

1- $ yum install git


2- $ git --version
3- $ git config --global user.name "Your Name"
4- $ git config --global user.email "[email protected]"
5- $ git config --list

48
C2 – Usage restreint
Source Control Management

Git Architecture

49
C2 – Usage restreint
CI/CD

50
C2 – Usage restreint
CI/CD

Jenkins
Jenkins is a powerful application that allows continuous integration and continuous

delivery of projects, regardless of the platform you are working on.

It is a free source that can handle any kind of build or continuous integration.

You can integrate Jenkins with a number of testing and deployment technologies.

In this tutorial, we would explain how you can use Jenkins to build and test your

software projects continuously.

51
C2 – Usage restreint
CI/CD

How to install Jenkins?


1- Install java
$ sudo yum install java-1.8.0-openjdk-devel
2- enable the Jenkins repository
$ curl --silent --location http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo | sudo
tee /etc/yum.repos.d/jenkins.repo
3 install the latest stable version of Jenkins
$ sudo yum install jenkins
$ sudo systemctl start jenkins

52
C2 – Usage restreint
CI/CD

What is a pipeline Jenkins?

53
C2 – Usage restreint

You might also like