Cours DEVOPS
Cours DEVOPS
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
●
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
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.
22
C2 – Usage restreint
Containerization
Push/Pull images
1- docker login --username username --password password
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
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.
34
C2 – Usage restreint
Containerization
Example
1- $ docker run -d –name=devtest -v devtest-vol:/app nginx:latest
2- $ docker ps
●
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.
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.
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
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.
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
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
Linus Torvalds for Linux kernel development. Git is a free software distributed
47
C2 – Usage restreint
Source Control Management
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
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
51
C2 – Usage restreint
CI/CD
52
C2 – Usage restreint
CI/CD
53
C2 – Usage restreint