SlideShare a Scribd company logo
1 of 22
Download to read offline
Docker + Kubernetes
Pourquoi c’est génial ?
Docker
Introduction à un cas pratique
App 1 App 3App 2
Elephant TurtleLeopard
NodeJS current
Dépendance avec Debian 8 Dépendance avec Debian 9
NodeJS 8 NodeJS 6
Première approche : sans Docker
Config dev 1
Node 11
Config dev 2
Debian 8
Node 8
Config dev 3
Debian 9
Node 6
Config prod 1
Ubuntu Server 18.04
Node 11
Config prod 2
Debian 8
Node 8
Config prod 3
Debian 9
Node 6
● Installation de l’OS et des dépendances pour chaque machine ou VM
● Scalabilité horizontale ou verticale à gérer manuellement
● Configuration manuelle des paramètres du réseau
● Sécurité à gérer manuellement pour chaque machine ou VM
● Stratégie complexe pour le déploiement de mises à jour
Seconde approche : avec Docker !
Config 1
Node 11
Config 2
Debian 8
Node 8
Config 3
Debian 9
Node 6
● L’OS et les dépendances sont décrites dans des fichiers
● Une seule installation requise sur la machine : Docker
● Scalabilité infinie avec réplication et répartition de la charge
● Configuration du réseau automatique
● Sécurité auto-gérée et configuration possible selon les besoins
● Déploiement des mises à jour facilitée
Contenu des fichiers pour notre sandbox
{
"name": "pastis.tech-2" ,
"author" : "Nazim Lachter <nazim+github@blueforest.fr>" ,
"repository" :
"git@github.com:n4zim/Talk_pastis.tech-2.git" ,
"license" : "Apache-2.0" ,
"scripts" : {
"elephant" : "node server.js elephant" ,
"leopard" : "node server.js leopard" ,
"turtle" : "node server.js turtle"
},
"dependencies" : {
"express" : "^4.16.4" ,
"mustache-express" : "^1.2.8"
}
}
package.json
const express = require("express" )
const path = require("path")
const mustacheExpress = require("mustache-express" )
const os = require("os")
const app = express()
app.engine("html", mustacheExpress ())
app.set("view engine" , "html")
app.set("views", path.join(__dirname , "views"))
app.use("/static" , express.static("static" ))
app.get("/", (req, res) => {
res.render(`${process.argv[2]}.html`, {
hostname: os.hostname (),
os: process.env.OS_NAME,
version: process.version,
})
})
const PORT = 8080
app.listen(PORT, () => {
console.log(`The server is running on port ${PORT}`)
})
server.js
goo.gl/hdAhbi
Fichiers de description Docker
FROM node:alpine
ENV OS_NAME "Alpine"
# Install
WORKDIR /app
COPY package*.json ./
RUN npm install --only=production
# JS
COPY server.js .
# View
COPY views/elephant.html ./views/elephant.html
# Static
COPY static/common.css ./static/common.css
COPY static/elephant.png ./static/elephant.png
# Start
EXPOSE 8080
CMD [ "npm", "start", "elephant" ]
FROM node:8-jessie
ENV OS_NAME "Debian 8 (jessie)"
# Install
WORKDIR /app
COPY package*.json ./
RUN npm install --only=production
# JS
COPY server.js .
# View
COPY views/leopard.html ./views/leopard.html
# Static
COPY static/common.css ./static/common.css
COPY static/leopard.png ./static/leopard.png
# Start
EXPOSE 8080
CMD [ "npm", "start", "leopard" ]
FROM node:6-stretch
ENV OS_NAME "Debian 9 (stretch)"
# Install
WORKDIR /app
COPY package*.json ./
RUN npm install --only=production
# JS
COPY server.js .
# View
COPY views/turtle.html ./views/turtle.html
# Static
COPY static/common.css ./static/common.css
COPY static/turtle.png ./static/turtle.png
# Start
EXPOSE 8080
CMD [ "npm", "start", "turtle" ]
elephant.Dockerfile turtle.Dockerfileleopard.Dockerfile
goo.gl/hdAhbi
Dockerfile
Fonctionnement général de Docker
Code source
DépendancesSystème
IMAGE CONTAINERS
goo.gl/hdAhbi
Fonctionnement général de Docker Compose
Dockerfile 1
Docker Compose
CLI
Dockerfile 2
Dockerfile 3
IMAGES
CONTAINERS
goo.gl/hdAhbi
Configurations pour Docker Compose
version: "3.3"
services:
elephant:
container_name: elephant
build:
context: .
dockerfile: ./docker/elephant.Dockerfile
ports:
- 8090:8080
leopard:
container_name: leopard
build:
context: .
dockerfile: ./docker/leopard.Dockerfile
ports:
- 8091:8080
turtle:
container_name: turtle
build:
context: .
dockerfile: ./docker/turtle.Dockerfile
ports:
- 8092:8080
version: "3.3"
services:
elephant:
container_name: elephant
build: { context: ., dockerfile: ./docker/elephant.Dockerfile}
ports: [ "8090:8080" ]
volumes: [ ".:/app" ]
leopard:
container_name: leopard
build: { context: ., dockerfile: ./docker/leopard.Dockerfile}
ports: [ "8091:8080" ]
volumes: [ ".:/app" ]
turtle:
container_name: turtle
build: { context: ., dockerfile: ./docker/turtle.Dockerfile}
ports: [ "8092:8080" ]
volumes: [ ".:/app" ]
goo.gl/hdAhbi
Version avec fichiers du build
Version avec les fichiers du disque
Création d’une image avec Docker Compose
Building elephant
Step 1/11 : FROM node:alpine
---> a13f3a3ed57f
Step 2/11 : ENV OS_NAME "Alpine"
---> Running in 8cefb436200b
Removing intermediate container 8cefb436200b
---> db0fd4b470f1
Step 3/11 : WORKDIR /app
---> Running in 70e639166bf1
Removing intermediate container 70e639166bf1
---> 5d1f92b457b3
Step 4/11 : COPY package*.json ./
---> 6f52fcb81813
Step 5/11 : RUN npm install --only=production
---> Running in 7ac696e7c422
added 55 packages from 48 contributors and audited 128
packages in 1.764s
found 0 vulnerabilities
Removing intermediate container 7ac696e7c422
---> d7df463ae85e
Step 6/11 : COPY server.js .
---> 426a2053134b
Step 7/11 : COPY views/elephant.html ./views/elephant.html
---> 5344fc2b6865
Step 8/11 : COPY static/common.css ./static/common.css
---> b454076c052c
Step 9/11 : COPY static/elephant.png ./static/elephant.png
---> d9892db38ef7
Step 10/11 : EXPOSE 8080
---> Running in 9eab28c5a72c
Removing intermediate container 9eab28c5a72c
---> 7e82b4b774b1
Step 11/11 : CMD [ "npm", "start", "elephant" ]
---> Running in eacde22ed281
Removing intermediate container eacde22ed281
---> d98c14877978
Successfully built d98c14877978
Successfully tagged pastistech2_elephant:latest
Building leopard
Step 1/11 : FROM node:8-jessie
---> 297a988c4eb6
Step 2/11 : ENV OS_NAME "Debian 8 (jessie)"
---> Running in d90b437e8716
Removing intermediate container d90b437e8716
---> cb9889060ff6
Step 3/11 : WORKDIR /app
---> Running in 07e3b9b40b5c
Removing intermediate container 07e3b9b40b5c
---> 5bdb1a241feb
Step 4/11 : COPY package*.json ./
---> f18e7635ae2e
Step 5/11 : RUN npm install --only=production
---> Running in dba620dfa6c4
added 55 packages from 48 contributors and audited 128
packages in 5.837s
found 0 vulnerabilities
Removing intermediate container dba620dfa6c4
---> 63cdad5528f2
Step 6/11 : COPY server.js .
---> 590c3a51fba5
Step 7/11 : COPY views/leopard.html ./views/leopard.html
---> 1b452a3efb26
Step 8/11 : COPY static/common.css ./static/common.css
---> 574be8fce045
Step 9/11 : COPY static/leopard.png ./static/leopard.png
---> 7aa38d9dd53c
Step 10/11 : EXPOSE 8080
---> Running in 1bdd062e0993
Removing intermediate container 1bdd062e0993
---> 2f50dc3c5382
Step 11/11 : CMD [ "npm", "start", "leopard" ]
---> Running in a98902c800dd
Removing intermediate container a98902c800dd
---> e06636a0fac5
Successfully built e06636a0fac5
Successfully tagged pastistech2_leopard:latest
Building turtle
Step 1/11 : FROM node:6-stretch
---> 753cb37bc49c
Step 2/11 : ENV OS_NAME "Debian 9 (stretch)"
---> Running in af6f8a7c5892
Removing intermediate container af6f8a7c5892
---> 631e75029482
Step 3/11 : WORKDIR /app
---> Running in 9c3aaea56157
Removing intermediate container 9c3aaea56157
---> 286a9e305cc0
Step 4/11 : COPY package*.json ./
---> 90c2db3b1b4f
Step 5/11 : RUN npm install --only=production
---> Running in 6990bcc22c8e
pastis.tech-2@ /app
[ ... NPM TREE REMOVED ... ]
Removing intermediate container 6990bcc22c8e
---> 12297907f6aa
Step 6/11 : COPY server.js .
---> dbd805f4a5e5
Step 7/11 : COPY views/turtle.html ./views/turtle.html
---> 9ca99806ffad
Step 8/11 : COPY static/common.css ./static/common.css
---> c38ddda9c2f0
Step 9/11 : COPY static/turtle.png ./static/turtle.png
---> fbc1534922b6
Step 10/11 : EXPOSE 8080
---> Running in 34a87f5f265c
Removing intermediate container 34a87f5f265c
---> 779c85756f4e
Step 11/11 : CMD [ "npm", "start", "turtle" ]
---> Running in 4e4f236882a4
Removing intermediate container 4e4f236882a4
---> af5fcb9e2e99
Successfully built af5fcb9e2e99
Successfully tagged pastistech2_turtle:latest
$ docker-compose build
goo.gl/hdAhbi
Exécution de containers avec Docker Compose
$ docker-compose up
Creating network "pastistech2_default" with the default driver
Creating leopard ...done
Creating elephant ...done
Creating turtle ...done
Attaching to elephant, leopard, turtle
elephant |
elephant | > pastis.tech-2@ start /app
elephant | > node server.js "elephant"
elephant |
elephant | The server is running on port 8080
leopard |
leopard | > pastis.tech-2@ start /app
leopard | > node server.js "leopard"
leopard |
leopard | The server is running on port 8080
turtle |
turtle | > pastis.tech-2@ start /app
turtle | > node server.js "turtle"
turtle |
turtle | The server is running on port 8080
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5349377daec9 pastistech2_elephant "npm start elephant" 23 minutes ago Up 10 minutes 0.0.0.0:8090->8080/tcp elephant
75556cd5a17f pastistech2_leopard "npm start leopard" 23 minutes ago Up 10 minutes 0.0.0.0:8091->8080/tcp leopard
58b4500f236d pastistech2_turtle "npm start turtle" 23 minutes ago Up 10 minutes 0.0.0.0:8092->8080/tcp turtle
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
pastistech2_elephant latest d98c14877978 About an hour ago 80.1MB
pastistech2_leopard latest e06636a0fac5 About an hour ago 680MB
pastistech2_turtle latest af5fcb9e2e99 About an hour ago 892MB
goo.gl/hdAhbi
Kubernetes
Fonctionnement de Kubernetes dans notre cas goo.gl/hdAhbi
http://elephant.sandbox.blueforest.fr http://leopard.sandbox.blueforest.fr http://turtle.sandbox.blueforest.fr
LOADBALANCER
Elephant SERVICE Leopard SERVICE
Turtle SERVICE
Envoi des images Docker locales sur GCP
$ docker tag pastistech2_elephant gcr.io/blueforest/pastistech2_elephant
$ docker push gcr.io/blueforest/pastistech2_elephant
[ ... ]
latest: digest: sha256:3e8b4a65ceb58ebfa9ac9b31ce04521ff19a85d1cc13638cce483e27ff8a8e38 size: 2407
$ docker tag pastistech2_leopard gcr.io/blueforest/pastistech2_leopard
$ docker push gcr.io/blueforest/pastistech2_leopard
[ ... ]
latest: digest: sha256:ac69a75d16bca48270741d66d25e42d907b74127ed3679a7dc331cc3750513d9 size: 3253
$ docker tag pastistech2_turtle gcr.io/blueforest/pastistech2_turtle
$ docker push gcr.io/blueforest/pastistech2_turtle
[ ... ]
latest: digest: sha256:cbfecba82b9251ef360de15cd90c6c9fe15114e400664c5e4767a75e84cff2e7 size: 3463
goo.gl/hdAhbi
Création d’un cluster Kubernetes sur Google Cloud Platform goo.gl/hdAhbi
● Nom : pastistech2
● Zone : europe-west3-b
● Version maître : 1.12.5-gke.10
● Nombre de noeuds : 3
● Nombre CPUs : 1
● Quantité RAM : 2 Go
Accès au cluster Kubernetes
$ gcloud container clusters get-credentials pastistech2 --zone europe-west3-b --project blueforest
goo.gl/hdAhbi
Configuration des déploiements Kubernetes
kind: Deployment
apiVersion: apps/v1
metadata:
name: elephant
spec:
replicas: 3
selector:
matchLabels:
app: elephant
template:
metadata:
labels:
app: elephant
spec:
containers:
- name: elephant
image: |
gcr.io/blueforest/pastistech2_elephant
ports:
- containerPort: 8080
kind: Deployment
apiVersion: apps/v1
metadata:
name: turtle
spec:
replicas: 3
selector:
matchLabels:
app: turtle
template:
metadata:
labels:
app: turtle
spec:
containers:
- name: turtle
image: |
gcr.io/blueforest/pastistech2_turtle
ports:
- containerPort: 8080
kind: Deployment
apiVersion: apps/v1
metadata:
name: leopard
spec:
replicas: 3
selector:
matchLabels:
app: leopard
template:
metadata:
labels:
app: leopard
spec:
containers:
- name: leopard
image: |
gcr.io/blueforest/pastistech2_leopard
ports:
- containerPort: 8080
goo.gl/hdAhbi
elephant.deployment.yml leopard.deployment.yml turtle.deployment.yml
Déploiement des containers Kubernetes
$ kubectl apply -f elephant.deployment.yml
deployment.apps/elephant created
$ kubectl apply -f leopard.deployment.yml
deployment.apps/leopard created
$ kubectl apply -f turtle.deployment.yml
deployment.apps/turtle created
Liaison des containers à des services Kubernetes goo.gl/hdAhbi
$ kubectl apply -f elephant.service.yml
service/elephant created
$ kubectl apply -f leopard.service.yml
service/leopard create
$ kubectl apply -f turtle.service.yml
service/turtle created
Création d’un équilibreur de charge goo.gl/hdAhbi
kind: Ingress
apiVersion : extensions/v1beta1
metadata :
name: loadbalancer
annotations :
kubernetes.io/ingress.class : gce
spec:
rules:
- host: elephant.sandbox.blueforest.fr
http:
paths:
- backend:
serviceName : elephant
servicePort : 8080
- host: leopard.sandbox.blueforest.fr
http:
paths:
- backend:
serviceName : leopard
servicePort : 8080
- host: turtle.sandbox.blueforest.fr
http:
paths:
- backend:
serviceName : turtle
servicePort : 8080
Code source : https://goo.gl/hdAhbi
Nazim Lachter
Co-fondateur de Blue Forest
Développeur du turfu
linkedin.com/in/nlachter
blueforest.fr

More Related Content

What's hot

What's hot (20)

DeveloperWeek 2015: A Practical Introduction to Docker
DeveloperWeek 2015: A Practical Introduction to DockerDeveloperWeek 2015: A Practical Introduction to Docker
DeveloperWeek 2015: A Practical Introduction to Docker
 
Hyperledger composer
Hyperledger composerHyperledger composer
Hyperledger composer
 
Everything as a code
Everything as a codeEverything as a code
Everything as a code
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)
 
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)
 
Docker on openstack by OpenSource Consulting
Docker on openstack by OpenSource ConsultingDocker on openstack by OpenSource Consulting
Docker on openstack by OpenSource Consulting
 
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
 
Enterprise Messaging Foundations
Enterprise Messaging FoundationsEnterprise Messaging Foundations
Enterprise Messaging Foundations
 
Ansible ex407 and EX 294
Ansible ex407 and EX 294Ansible ex407 and EX 294
Ansible ex407 and EX 294
 
Docker command
Docker commandDocker command
Docker command
 
Real World Lessons on the Pain Points of Node.js Applications
Real World Lessons on the Pain Points of Node.js ApplicationsReal World Lessons on the Pain Points of Node.js Applications
Real World Lessons on the Pain Points of Node.js Applications
 
Real World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and ProductionReal World Experience of Running Docker in Development and Production
Real World Experience of Running Docker in Development and Production
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using docker
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)
 
Deploying applications to Windows Server 2016 and Windows Containers
Deploying applications to Windows Server 2016 and Windows ContainersDeploying applications to Windows Server 2016 and Windows Containers
Deploying applications to Windows Server 2016 and Windows Containers
 
Nginx2
Nginx2Nginx2
Nginx2
 
Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016Deploying Windows Containers on Windows Server 2016
Deploying Windows Containers on Windows Server 2016
 
Python virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutesPython virtualenv & pip in 90 minutes
Python virtualenv & pip in 90 minutes
 
Configuration Management with Saltstack
Configuration Management with SaltstackConfiguration Management with Saltstack
Configuration Management with Saltstack
 
Vagrant and CentOS 7
Vagrant and CentOS 7Vagrant and CentOS 7
Vagrant and CentOS 7
 

Similar to Présentation "Docker + Kubernetes" @ Pastis.tech #2

Openstack kilo installation using rdo
Openstack kilo installation using rdoOpenstack kilo installation using rdo
Openstack kilo installation using rdo
Narasimha sreeram
 

Similar to Présentation "Docker + Kubernetes" @ Pastis.tech #2 (20)

Continuous delivery with docker
Continuous delivery with dockerContinuous delivery with docker
Continuous delivery with docker
 
Hands-On Session Docker
Hands-On Session DockerHands-On Session Docker
Hands-On Session Docker
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
Docker: ao vivo e a cores
Docker: ao vivo e a coresDocker: ao vivo e a cores
Docker: ao vivo e a cores
 
Openstack kilo installation using rdo
Openstack kilo installation using rdoOpenstack kilo installation using rdo
Openstack kilo installation using rdo
 
Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...
Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...
Arnold Bechtoldt, Inovex GmbH Linux systems engineer - Configuration Manageme...
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
 
AtlasCamp 2015 Docker continuous integration training
AtlasCamp 2015 Docker continuous integration trainingAtlasCamp 2015 Docker continuous integration training
AtlasCamp 2015 Docker continuous integration training
 
OSMC 2021 | Icinga-Installer – the easy way to your Icinga
OSMC 2021 | Icinga-Installer – the easy way to your IcingaOSMC 2021 | Icinga-Installer – the easy way to your Icinga
OSMC 2021 | Icinga-Installer – the easy way to your Icinga
 
Pluralsight Webinar: Simplify Your Project Builds with Docker
Pluralsight Webinar: Simplify Your Project Builds with DockerPluralsight Webinar: Simplify Your Project Builds with Docker
Pluralsight Webinar: Simplify Your Project Builds with Docker
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
 
Check the version with fixes. Link in description
Check the version with fixes. Link in descriptionCheck the version with fixes. Link in description
Check the version with fixes. Link in description
 
Docker perl build
Docker perl buildDocker perl build
Docker perl build
 
Yobi d2 naver(create)
Yobi d2 naver(create)Yobi d2 naver(create)
Yobi d2 naver(create)
 
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHPHands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
Hands on Docker - Launch your own LEMP or LAMP stack - SunshinePHP
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
k8s practice 2023.pptx
k8s practice 2023.pptxk8s practice 2023.pptx
k8s practice 2023.pptx
 
Learning Docker with Thomas
Learning Docker with ThomasLearning Docker with Thomas
Learning Docker with Thomas
 
Docker orchestration
Docker orchestrationDocker orchestration
Docker orchestration
 
桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作桃園市教育局Docker技術入門與實作
桃園市教育局Docker技術入門與實作
 

Recently uploaded

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
Financial Accounting IFRS, 3rd Edition-dikompresi.pdf
Financial Accounting IFRS, 3rd Edition-dikompresi.pdfFinancial Accounting IFRS, 3rd Edition-dikompresi.pdf
Financial Accounting IFRS, 3rd Edition-dikompresi.pdf
MinawBelay
 

Recently uploaded (20)

The Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptxThe Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptx
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Financial Accounting IFRS, 3rd Edition-dikompresi.pdf
Financial Accounting IFRS, 3rd Edition-dikompresi.pdfFinancial Accounting IFRS, 3rd Edition-dikompresi.pdf
Financial Accounting IFRS, 3rd Edition-dikompresi.pdf
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING IIII BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdf
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the life
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 

Présentation "Docker + Kubernetes" @ Pastis.tech #2

  • 1. Docker + Kubernetes Pourquoi c’est génial ?
  • 3. Introduction à un cas pratique App 1 App 3App 2 Elephant TurtleLeopard NodeJS current Dépendance avec Debian 8 Dépendance avec Debian 9 NodeJS 8 NodeJS 6
  • 4. Première approche : sans Docker Config dev 1 Node 11 Config dev 2 Debian 8 Node 8 Config dev 3 Debian 9 Node 6 Config prod 1 Ubuntu Server 18.04 Node 11 Config prod 2 Debian 8 Node 8 Config prod 3 Debian 9 Node 6 ● Installation de l’OS et des dépendances pour chaque machine ou VM ● Scalabilité horizontale ou verticale à gérer manuellement ● Configuration manuelle des paramètres du réseau ● Sécurité à gérer manuellement pour chaque machine ou VM ● Stratégie complexe pour le déploiement de mises à jour
  • 5. Seconde approche : avec Docker ! Config 1 Node 11 Config 2 Debian 8 Node 8 Config 3 Debian 9 Node 6 ● L’OS et les dépendances sont décrites dans des fichiers ● Une seule installation requise sur la machine : Docker ● Scalabilité infinie avec réplication et répartition de la charge ● Configuration du réseau automatique ● Sécurité auto-gérée et configuration possible selon les besoins ● Déploiement des mises à jour facilitée
  • 6. Contenu des fichiers pour notre sandbox { "name": "pastis.tech-2" , "author" : "Nazim Lachter <nazim+github@blueforest.fr>" , "repository" : "git@github.com:n4zim/Talk_pastis.tech-2.git" , "license" : "Apache-2.0" , "scripts" : { "elephant" : "node server.js elephant" , "leopard" : "node server.js leopard" , "turtle" : "node server.js turtle" }, "dependencies" : { "express" : "^4.16.4" , "mustache-express" : "^1.2.8" } } package.json const express = require("express" ) const path = require("path") const mustacheExpress = require("mustache-express" ) const os = require("os") const app = express() app.engine("html", mustacheExpress ()) app.set("view engine" , "html") app.set("views", path.join(__dirname , "views")) app.use("/static" , express.static("static" )) app.get("/", (req, res) => { res.render(`${process.argv[2]}.html`, { hostname: os.hostname (), os: process.env.OS_NAME, version: process.version, }) }) const PORT = 8080 app.listen(PORT, () => { console.log(`The server is running on port ${PORT}`) }) server.js goo.gl/hdAhbi
  • 7. Fichiers de description Docker FROM node:alpine ENV OS_NAME "Alpine" # Install WORKDIR /app COPY package*.json ./ RUN npm install --only=production # JS COPY server.js . # View COPY views/elephant.html ./views/elephant.html # Static COPY static/common.css ./static/common.css COPY static/elephant.png ./static/elephant.png # Start EXPOSE 8080 CMD [ "npm", "start", "elephant" ] FROM node:8-jessie ENV OS_NAME "Debian 8 (jessie)" # Install WORKDIR /app COPY package*.json ./ RUN npm install --only=production # JS COPY server.js . # View COPY views/leopard.html ./views/leopard.html # Static COPY static/common.css ./static/common.css COPY static/leopard.png ./static/leopard.png # Start EXPOSE 8080 CMD [ "npm", "start", "leopard" ] FROM node:6-stretch ENV OS_NAME "Debian 9 (stretch)" # Install WORKDIR /app COPY package*.json ./ RUN npm install --only=production # JS COPY server.js . # View COPY views/turtle.html ./views/turtle.html # Static COPY static/common.css ./static/common.css COPY static/turtle.png ./static/turtle.png # Start EXPOSE 8080 CMD [ "npm", "start", "turtle" ] elephant.Dockerfile turtle.Dockerfileleopard.Dockerfile goo.gl/hdAhbi
  • 8. Dockerfile Fonctionnement général de Docker Code source DépendancesSystème IMAGE CONTAINERS goo.gl/hdAhbi
  • 9. Fonctionnement général de Docker Compose Dockerfile 1 Docker Compose CLI Dockerfile 2 Dockerfile 3 IMAGES CONTAINERS goo.gl/hdAhbi
  • 10. Configurations pour Docker Compose version: "3.3" services: elephant: container_name: elephant build: context: . dockerfile: ./docker/elephant.Dockerfile ports: - 8090:8080 leopard: container_name: leopard build: context: . dockerfile: ./docker/leopard.Dockerfile ports: - 8091:8080 turtle: container_name: turtle build: context: . dockerfile: ./docker/turtle.Dockerfile ports: - 8092:8080 version: "3.3" services: elephant: container_name: elephant build: { context: ., dockerfile: ./docker/elephant.Dockerfile} ports: [ "8090:8080" ] volumes: [ ".:/app" ] leopard: container_name: leopard build: { context: ., dockerfile: ./docker/leopard.Dockerfile} ports: [ "8091:8080" ] volumes: [ ".:/app" ] turtle: container_name: turtle build: { context: ., dockerfile: ./docker/turtle.Dockerfile} ports: [ "8092:8080" ] volumes: [ ".:/app" ] goo.gl/hdAhbi Version avec fichiers du build Version avec les fichiers du disque
  • 11. Création d’une image avec Docker Compose Building elephant Step 1/11 : FROM node:alpine ---> a13f3a3ed57f Step 2/11 : ENV OS_NAME "Alpine" ---> Running in 8cefb436200b Removing intermediate container 8cefb436200b ---> db0fd4b470f1 Step 3/11 : WORKDIR /app ---> Running in 70e639166bf1 Removing intermediate container 70e639166bf1 ---> 5d1f92b457b3 Step 4/11 : COPY package*.json ./ ---> 6f52fcb81813 Step 5/11 : RUN npm install --only=production ---> Running in 7ac696e7c422 added 55 packages from 48 contributors and audited 128 packages in 1.764s found 0 vulnerabilities Removing intermediate container 7ac696e7c422 ---> d7df463ae85e Step 6/11 : COPY server.js . ---> 426a2053134b Step 7/11 : COPY views/elephant.html ./views/elephant.html ---> 5344fc2b6865 Step 8/11 : COPY static/common.css ./static/common.css ---> b454076c052c Step 9/11 : COPY static/elephant.png ./static/elephant.png ---> d9892db38ef7 Step 10/11 : EXPOSE 8080 ---> Running in 9eab28c5a72c Removing intermediate container 9eab28c5a72c ---> 7e82b4b774b1 Step 11/11 : CMD [ "npm", "start", "elephant" ] ---> Running in eacde22ed281 Removing intermediate container eacde22ed281 ---> d98c14877978 Successfully built d98c14877978 Successfully tagged pastistech2_elephant:latest Building leopard Step 1/11 : FROM node:8-jessie ---> 297a988c4eb6 Step 2/11 : ENV OS_NAME "Debian 8 (jessie)" ---> Running in d90b437e8716 Removing intermediate container d90b437e8716 ---> cb9889060ff6 Step 3/11 : WORKDIR /app ---> Running in 07e3b9b40b5c Removing intermediate container 07e3b9b40b5c ---> 5bdb1a241feb Step 4/11 : COPY package*.json ./ ---> f18e7635ae2e Step 5/11 : RUN npm install --only=production ---> Running in dba620dfa6c4 added 55 packages from 48 contributors and audited 128 packages in 5.837s found 0 vulnerabilities Removing intermediate container dba620dfa6c4 ---> 63cdad5528f2 Step 6/11 : COPY server.js . ---> 590c3a51fba5 Step 7/11 : COPY views/leopard.html ./views/leopard.html ---> 1b452a3efb26 Step 8/11 : COPY static/common.css ./static/common.css ---> 574be8fce045 Step 9/11 : COPY static/leopard.png ./static/leopard.png ---> 7aa38d9dd53c Step 10/11 : EXPOSE 8080 ---> Running in 1bdd062e0993 Removing intermediate container 1bdd062e0993 ---> 2f50dc3c5382 Step 11/11 : CMD [ "npm", "start", "leopard" ] ---> Running in a98902c800dd Removing intermediate container a98902c800dd ---> e06636a0fac5 Successfully built e06636a0fac5 Successfully tagged pastistech2_leopard:latest Building turtle Step 1/11 : FROM node:6-stretch ---> 753cb37bc49c Step 2/11 : ENV OS_NAME "Debian 9 (stretch)" ---> Running in af6f8a7c5892 Removing intermediate container af6f8a7c5892 ---> 631e75029482 Step 3/11 : WORKDIR /app ---> Running in 9c3aaea56157 Removing intermediate container 9c3aaea56157 ---> 286a9e305cc0 Step 4/11 : COPY package*.json ./ ---> 90c2db3b1b4f Step 5/11 : RUN npm install --only=production ---> Running in 6990bcc22c8e pastis.tech-2@ /app [ ... NPM TREE REMOVED ... ] Removing intermediate container 6990bcc22c8e ---> 12297907f6aa Step 6/11 : COPY server.js . ---> dbd805f4a5e5 Step 7/11 : COPY views/turtle.html ./views/turtle.html ---> 9ca99806ffad Step 8/11 : COPY static/common.css ./static/common.css ---> c38ddda9c2f0 Step 9/11 : COPY static/turtle.png ./static/turtle.png ---> fbc1534922b6 Step 10/11 : EXPOSE 8080 ---> Running in 34a87f5f265c Removing intermediate container 34a87f5f265c ---> 779c85756f4e Step 11/11 : CMD [ "npm", "start", "turtle" ] ---> Running in 4e4f236882a4 Removing intermediate container 4e4f236882a4 ---> af5fcb9e2e99 Successfully built af5fcb9e2e99 Successfully tagged pastistech2_turtle:latest $ docker-compose build goo.gl/hdAhbi
  • 12. Exécution de containers avec Docker Compose $ docker-compose up Creating network "pastistech2_default" with the default driver Creating leopard ...done Creating elephant ...done Creating turtle ...done Attaching to elephant, leopard, turtle elephant | elephant | > pastis.tech-2@ start /app elephant | > node server.js "elephant" elephant | elephant | The server is running on port 8080 leopard | leopard | > pastis.tech-2@ start /app leopard | > node server.js "leopard" leopard | leopard | The server is running on port 8080 turtle | turtle | > pastis.tech-2@ start /app turtle | > node server.js "turtle" turtle | turtle | The server is running on port 8080 $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5349377daec9 pastistech2_elephant "npm start elephant" 23 minutes ago Up 10 minutes 0.0.0.0:8090->8080/tcp elephant 75556cd5a17f pastistech2_leopard "npm start leopard" 23 minutes ago Up 10 minutes 0.0.0.0:8091->8080/tcp leopard 58b4500f236d pastistech2_turtle "npm start turtle" 23 minutes ago Up 10 minutes 0.0.0.0:8092->8080/tcp turtle $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE pastistech2_elephant latest d98c14877978 About an hour ago 80.1MB pastistech2_leopard latest e06636a0fac5 About an hour ago 680MB pastistech2_turtle latest af5fcb9e2e99 About an hour ago 892MB goo.gl/hdAhbi
  • 14. Fonctionnement de Kubernetes dans notre cas goo.gl/hdAhbi http://elephant.sandbox.blueforest.fr http://leopard.sandbox.blueforest.fr http://turtle.sandbox.blueforest.fr LOADBALANCER Elephant SERVICE Leopard SERVICE Turtle SERVICE
  • 15. Envoi des images Docker locales sur GCP $ docker tag pastistech2_elephant gcr.io/blueforest/pastistech2_elephant $ docker push gcr.io/blueforest/pastistech2_elephant [ ... ] latest: digest: sha256:3e8b4a65ceb58ebfa9ac9b31ce04521ff19a85d1cc13638cce483e27ff8a8e38 size: 2407 $ docker tag pastistech2_leopard gcr.io/blueforest/pastistech2_leopard $ docker push gcr.io/blueforest/pastistech2_leopard [ ... ] latest: digest: sha256:ac69a75d16bca48270741d66d25e42d907b74127ed3679a7dc331cc3750513d9 size: 3253 $ docker tag pastistech2_turtle gcr.io/blueforest/pastistech2_turtle $ docker push gcr.io/blueforest/pastistech2_turtle [ ... ] latest: digest: sha256:cbfecba82b9251ef360de15cd90c6c9fe15114e400664c5e4767a75e84cff2e7 size: 3463 goo.gl/hdAhbi
  • 16. Création d’un cluster Kubernetes sur Google Cloud Platform goo.gl/hdAhbi ● Nom : pastistech2 ● Zone : europe-west3-b ● Version maître : 1.12.5-gke.10 ● Nombre de noeuds : 3 ● Nombre CPUs : 1 ● Quantité RAM : 2 Go
  • 17. Accès au cluster Kubernetes $ gcloud container clusters get-credentials pastistech2 --zone europe-west3-b --project blueforest goo.gl/hdAhbi
  • 18. Configuration des déploiements Kubernetes kind: Deployment apiVersion: apps/v1 metadata: name: elephant spec: replicas: 3 selector: matchLabels: app: elephant template: metadata: labels: app: elephant spec: containers: - name: elephant image: | gcr.io/blueforest/pastistech2_elephant ports: - containerPort: 8080 kind: Deployment apiVersion: apps/v1 metadata: name: turtle spec: replicas: 3 selector: matchLabels: app: turtle template: metadata: labels: app: turtle spec: containers: - name: turtle image: | gcr.io/blueforest/pastistech2_turtle ports: - containerPort: 8080 kind: Deployment apiVersion: apps/v1 metadata: name: leopard spec: replicas: 3 selector: matchLabels: app: leopard template: metadata: labels: app: leopard spec: containers: - name: leopard image: | gcr.io/blueforest/pastistech2_leopard ports: - containerPort: 8080 goo.gl/hdAhbi elephant.deployment.yml leopard.deployment.yml turtle.deployment.yml
  • 19. Déploiement des containers Kubernetes $ kubectl apply -f elephant.deployment.yml deployment.apps/elephant created $ kubectl apply -f leopard.deployment.yml deployment.apps/leopard created $ kubectl apply -f turtle.deployment.yml deployment.apps/turtle created
  • 20. Liaison des containers à des services Kubernetes goo.gl/hdAhbi $ kubectl apply -f elephant.service.yml service/elephant created $ kubectl apply -f leopard.service.yml service/leopard create $ kubectl apply -f turtle.service.yml service/turtle created
  • 21. Création d’un équilibreur de charge goo.gl/hdAhbi kind: Ingress apiVersion : extensions/v1beta1 metadata : name: loadbalancer annotations : kubernetes.io/ingress.class : gce spec: rules: - host: elephant.sandbox.blueforest.fr http: paths: - backend: serviceName : elephant servicePort : 8080 - host: leopard.sandbox.blueforest.fr http: paths: - backend: serviceName : leopard servicePort : 8080 - host: turtle.sandbox.blueforest.fr http: paths: - backend: serviceName : turtle servicePort : 8080
  • 22. Code source : https://goo.gl/hdAhbi Nazim Lachter Co-fondateur de Blue Forest Développeur du turfu linkedin.com/in/nlachter blueforest.fr