Ident samples

This commit is contained in:
nemunaire 2018-10-14 22:58:19 +02:00
parent 6184c0bf3d
commit 02db9cc19c
47 changed files with 2658 additions and 213 deletions

View file

@ -21,10 +21,10 @@ cours d'exécution, arrêtés, ...) avec la commande suivante :
<div lang="en-US">
```
42sh$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
552d71619723 hello-world "/hello" 4 days ago Exited (0) 4 days ago dreamy_gates
0e8bbff6d500 debian "/bin/bash" 2 weeks ago Exited (0) 2 weeks ago cranky_jones
42sh$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS NAMES
552d71619723 hello-world "/hello" 4 days ago Exited (0) 4 days ago dreamy_gates
0e8bbff6d500 debian "/bin/bash" 2 weeks ago Exited (0) 2 weeks ago cranky_jones
```
</div>
@ -33,7 +33,7 @@ conteneurs. Pour les supprimer, utilisez la commande :
<div lang="en-US">
```
docker container rm 0e8bbff6d500 552d71619723
docker container rm 0e8bbff6d500 552d71619723
```
</div>
@ -41,7 +41,7 @@ ou encore :
<div lang="en-US">
```
docker container rm cranky_jones dreamy_gates
docker container rm cranky_jones dreamy_gates
```
</div>

View file

@ -13,7 +13,7 @@ Nous pouvons télécharger et lancer le service grâce à :
<div lang="en-US">
```
docker container run -i nemunaire/youp0m
docker container run -i nemunaire/youp0m
```
</div>
@ -36,7 +36,7 @@ Nous pouvons rediriger le port avec l'argument <span lang="en-US">`-p dst_host:s
<div lang="en-US">
```
docker container run -i -p 8080:8080 nemunaire/youp0m
docker container run -i -p 8080:8080 nemunaire/youp0m
```
</div>
@ -47,7 +47,7 @@ utiliser cette syntaxe pour ajouter une image :
<div lang="en-US">
```
base64 monimage.jpg | curl --data @- http://localhost:8080/api/images/monimage
base64 monimage.jpg | curl --data @- http://localhost:8080/api/images/monimage
```
</div>
@ -55,10 +55,10 @@ Si vous n'êtes pas particulièrement inspiré, vous pouvez ajouter ces images :
<div lang="en-US">
```
wget -O- https://you.p0m.fr/images/lynx4 | base64 | curl --data @- http://localhost:8080/api/images/lynx
wget -O- https://you.p0m.fr/images/otters | base64 | curl --data @- http://localhost:8080/api/images/otters
wget -O- https://you.p0m.fr/images/DNcrZ6u | base64 | curl --data @- http://localhost:8080/api/images/DNcrZ6u
wget -O- https://you.p0m.fr/images/raccoons | base64 | curl --data @- http://localhost:8080/api/images/raccoons
wget -O- https://you.p0m.fr/images/lynx4 | base64 | curl --data @- http://localhost:8080/api/images/lynx
wget -O- https://you.p0m.fr/images/otters | base64 | curl --data @- http://localhost:8080/api/images/otters
wget -O- https://you.p0m.fr/images/DNcrZ6u | base64 | curl --data @- http://localhost:8080/api/images/DNcrZ6u
wget -O- https://you.p0m.fr/images/raccoons | base64 | curl --data @- http://localhost:8080/api/images/raccoons
```
</div>
@ -73,7 +73,7 @@ On utilise l'option `-d` pour lancer le conteneur en tâche de fond :
<div lang="en-US">
```
docker container run -d -p 8080:8080 nemunaire/youp0m
docker container run -d -p 8080:8080 nemunaire/youp0m
```
</div>
@ -83,7 +83,7 @@ service (en fait, les sorties standard et d'erreur) :
<div lang="en-US">
```
docker container logs 0123456789abcdef
docker container logs 0123456789abcdef
```
</div>
@ -100,7 +100,7 @@ il s'agit des mêmes options :
<div lang="en-US">
```
docker container run -d -p 8080:8081 nemunaire/youp0m
docker container run -d -p 8080:8081 nemunaire/youp0m
```
</div>
@ -118,7 +118,7 @@ son identifiant dans la commande suivante :
<div lang="en-US">
```
docker container stop 0123456789abcdef
docker container stop 0123456789abcdef
```
</div>

View file

@ -8,7 +8,7 @@ conteneur avec la commande :
<div lang="en-US">
```
docker container run hello-world
docker container run hello-world
```
</div>
@ -27,7 +27,7 @@ Nous pouvons directement utiliser le client pour rechercher une image sur le
<div lang="en-US">
```
docker search mariadb
docker search mariadb
```
</div>
@ -36,7 +36,7 @@ pré-télécharger des images depuis le Store en utilisant la commande `pull` :
<div lang="en-US">
```
docker image pull ubuntu
docker image pull ubuntu
```
</div>
@ -60,7 +60,7 @@ nous-même), on utilise la commande `ls` sous le type d'objets `image` :
<div lang="en-US">
```
docker image ls
docker image ls
```
</div>
@ -89,7 +89,7 @@ un Hello World :
<div lang="en-US">
```
docker container run ubuntu /bin/echo "Hello World"
docker container run ubuntu /bin/echo "Hello World"
```
</div>
@ -104,7 +104,7 @@ tenter d'utiliser son gestionnaire de paquet `apk`, via :
<div lang="en-US">
```
docker container run alpine /sbin/apk stats
docker container run alpine /sbin/apk stats
```
</div>
@ -140,7 +140,7 @@ commande peut prendre des paramètres :
<div lang="en-US">
```
docker DOCKER_PARAMS container run RUN_OPTS image IMAGE_CMD IMAGE_ARGS ...
docker DOCKER_PARAMS container run RUN_OPTS image IMAGE_CMD IMAGE_ARGS ...
```
</div>
@ -148,7 +148,7 @@ Par exemple :
<div lang="en-US">
```
docker -H unix:///var/run/docker.sock container run -it alpine /bin/ash -c "echo foo"
docker -H unix:///var/run/docker.sock container run -it alpine /bin/ash -c "echo foo"
```
</div>
@ -167,10 +167,10 @@ sans quoi `bash` ne se lancera pas en mode interractif[^bashnointer].
<div lang="en-US">
```
42sh$ cat cmd
echo foo
42sh$ cat cmd | docker run -i busybox
foo
42sh$ cat cmd
echo foo
42sh$ cat cmd | docker run -i busybox
foo
```
</div>
@ -186,9 +186,9 @@ conteneurs en cours d'exécution :
<div lang="en-US">
```
42sh$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4c39fc049cd1 ubuntu "/bin/bash" 6 minutes ago Up 5 minutes suspicious_galileo
42sh$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4c39fc049cd1 ubuntu "/bin/bash" 6 minutes ago Up 5 minutes suspicious_galileo
```
</div>

View file

@ -18,7 +18,7 @@ Avant de continuer, assurez-vous que votre machine a bien démarré sur un noyau
<div lang="en-US">
```
x86_64
x86_64
```
</div>
@ -26,7 +26,7 @@ Assurez-vous également d'avoir un noyau récent, avec la commande `uname -r` :
<div lang="en-US">
```
4.18.11-gentoo
4.18.11-gentoo
```
</div>
@ -83,7 +83,7 @@ Vous devriez maintenant être capable de lancer la commande suivante :
<div lang="en-US">
```
docker version
docker version
```
</div>
@ -91,24 +91,24 @@ Une sortie similaire au bloc suivant devrait apparaître sur votre écran :
<div lang="en-US">
```
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Sun Sep 9 10:14:56 2018
OS/Arch: linux/amd64
Experimental: false
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Sun Sep 9 10:14:56 2018
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.06.1-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: e68fc7a
Built: Sun Sep 9 10:13:21 2018
OS/Arch: linux/amd64
Experimental: true
Server:
Engine:
Version: 18.06.1-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: e68fc7a
Built: Sun Sep 9 10:13:21 2018
OS/Arch: linux/amd64
Experimental: true
```
</div>
@ -139,7 +139,7 @@ directory.`, le deamon n'est sans doute pas lancé. Lancez-le :
<div lang="en-US">
```
sudo service docker restart
sudo service docker restart
```
</div>
@ -152,7 +152,7 @@ session** :
<div lang="en-US">
```
sudo gpasswd -a $USER docker
sudo gpasswd -a $USER docker
```
</div>

View file

@ -43,11 +43,11 @@ leur pilote. Pour consulter la liste de réseaux utilisables, lancez :
<div lang="en-US">
```
42sh$ docker network ls
NETWORK ID NAME DRIVER SCOPE
74cedd3ff385 bridge bridge local
d5d907add6e2 host host local
16b702ed01a0 none null local
42sh$ docker network ls
NETWORK ID NAME DRIVER SCOPE
74cedd3ff385 bridge bridge local
d5d907add6e2 host host local
16b702ed01a0 none null local
```
</div>
@ -79,7 +79,7 @@ relatives aux objets Docker `network` :
<div lang="en-US">
```
docker network create --driver bridge my_fic
docker network create --driver bridge my_fic
```
</div>
@ -89,7 +89,7 @@ réseau :
<div lang="en-US">
```
docker network connect NETWORK CONTAINER
docker network connect NETWORK CONTAINER
```
</div>
@ -109,7 +109,7 @@ obtiendrez en lisant l'aide :
<div lang="en-US">
```
docker container run --rm -e MYSQL_HOST="tcp(mysql_cntr_name:3306)" nemunaire/fic-admin -help
docker container run --rm -e MYSQL_HOST="tcp(mysql_cntr_name:3306)" nemunaire/fic-admin -help
```
</div>
@ -126,8 +126,8 @@ utilisant :
<div lang="en-US">
```
42sh$ docker container exec -it ficadmin_cntr_name /bin/bash
(incntnr)# ping mysql_cntr_name
42sh$ docker container exec -it ficadmin_cntr_name /bin/bash
(incntnr)# ping mysql_cntr_name
```
</div>

View file

@ -39,12 +39,12 @@ a pu voir durant ce premier cours.
<div lang="en-US">
```
42sh$ ./mycloud-run.sh
http://localhost:12345/
42sh$ #docker kill db
42sh$ ./mycloud-run.sh # le script relancera une base de données,
# sans avoir perdu les données
http://localhost:12345/
42sh$ ./mycloud-run.sh
http://localhost:12345/
42sh$ #docker kill db
42sh$ ./mycloud-run.sh # le script relancera une base de données,
# sans avoir perdu les données
http://localhost:12345/
```
</div>
@ -73,8 +73,8 @@ Voici une arborescence type:
<div lang="en-US">
```
login_x-TP1/
login_x-TP1/mycloud-run.sh
login_x-TP1/
login_x-TP1/mycloud-run.sh
```
</div>
@ -110,12 +110,12 @@ Si vous recevez un rapport avec l'erreur suivante :
<div lang="en-US">
```
[FAIL] Bad signature. Here is the gnupg output:
[FAIL] Bad signature. Here is the gnupg output:
gpg: Signature made Tue Jan 01 16:42:23 2014 CET
gpg: using RSA key 842807A84573CC96
gpg: requesting key E2CCD99DD37BD32E from hkp server pool.sks-keyservers.net
gpg: Can't check signature: No public key
gpg: Signature made Tue Jan 01 16:42:23 2014 CET
gpg: using RSA key 842807A84573CC96
gpg: requesting key E2CCD99DD37BD32E from hkp server pool.sks-keyservers.net
gpg: Can't check signature: No public key
```
</div>
@ -132,7 +132,7 @@ Si vous recevez un rapport avec l'erreur suivante :
<div lang="en-US">
```
[FAIL] The username of your key is not explicit, I can't find you.
[FAIL] The username of your key is not explicit, I can't find you.
```
</div>
@ -147,7 +147,7 @@ Si vous recevez un rapport concluant ainsi :
<div lang="en-US">
```
After analyzing your e-mail, I've decided to SKIP it.
After analyzing your e-mail, I've decided to SKIP it.
```
</div>

View file

@ -29,7 +29,7 @@ serveur web :
<div lang="en-US">
```
docker container run --rm -p 80:80 -v ~/Downloads:/usr/share/nginx/html:ro -d nginx
docker container run --rm -p 80:80 -v ~/Downloads:/usr/share/nginx/html:ro -d nginx
```
</div>
@ -49,8 +49,8 @@ volume :
<div lang="en-US">
```
docker volume create prod_youp0m
docker volume create prod_foodp0m
docker volume create prod_youp0m
docker volume create prod_foodp0m
```
</div>
@ -58,7 +58,7 @@ Ensuite, nous pouvons démarrer un conteneur utilisant, par exemple :
<div lang="en-US">
```
docker container run --mount source=prod_youp0m,target=/srv/images nemunaire/youp0m
docker container run --mount source=prod_youp0m,target=/srv/images nemunaire/youp0m
```
</div>
@ -66,8 +66,8 @@ On pourra également faire de même avec un conteneur MySQL :
<div lang="en-US">
```
docker container run --name mydb --mount source=prod_db,target=/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=my-secret-pw mysql
docker container run --name mydb --mount source=prod_db,target=/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=my-secret-pw mysql
```
</div>
@ -79,7 +79,7 @@ sauvegardes, vous pourriez le lancer comme ceci :
<div lang="en-US">
```
docker container run -it --volume-from mydb busybox /bin/bash
docker container run -it --volume-from mydb busybox /bin/bash
```
</div>
@ -94,7 +94,7 @@ exclusivement en RAM :
<div lang="en-US">
```
docker container run --mount type=tmpfs,target=/srv/images nemunaire/youp0m
docker container run --mount type=tmpfs,target=/srv/images nemunaire/youp0m
```
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View file

@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Docker layers</title>
<style>
body { background: white; text-align: center; }
table { width: 100%; }
</style>
</head>
<body>
<h1>Difference image/container</h1>
<table>
<tr>
<td>
<img src="image-layers.jpg" alt="Image layers">
</td>
<td>
<img src="container-layers.jpg" alt="Container layers">
</td>
</tr>
</table>
<hr>
<h1>Block Device <em>Union</em></h1>
<table>
<tr>
<td>
<img src="base_device.jpg" alt="Base device">
</td>
<td>
<img src="two_dm_container.jpg" alt="Base device">
</td>
</tr>
</table>
<hr>
<h1>Filesystem UnionFS</h1>
<table>
<tr>
<td>
<figure>
<img src="aufs_layers.jpg" alt="AUFS layers">
<figcaption>AUFS</figcaption>
</figure>
</td>
<td>
<figure>
<img src="overlay_constructs.jpg" alt="AUFS layers">
<figcaption>OverlayFS</figcaption>
</figure>
</td>
</tr>
</table>
<br>
<p style="text-align: left">
Images from <a href="https://docs.docker.com/">docs.docker.com</a>.
</p>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View file

@ -56,7 +56,7 @@ leur nom vous permettra par exemple de relancer une machine plus tard) :
<div lang="en-US">
```shell
docker-machine create --driver virtualbox echinoidea
docker-machine create --driver virtualbox echinoidea
```
</div>
@ -82,13 +82,13 @@ changer de daamon/machine avec une simple commande :
<div lang="en-US">
```shell
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS
$ eval $(docker-machine env echinoidea)
$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS
a814293b9f45 armbuild/busybox "/bin/sh" 18 seconds ago Up 10 minutes
0caddeed5037 armbuild/alpine "/bin/sh" 2 weeks ago Created
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS
$ eval $(docker-machine env echinoidea)
$ docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS
a814293b9f45 armbuild/busybox "/bin/sh" 18 seconds ago Up 10 minutes
0caddeed5037 armbuild/alpine "/bin/sh" 2 weeks ago Created
```
</div>
@ -142,9 +142,9 @@ virtuelle écoute :
<div lang="en-US">
```shell
(virt1) 42sh$ netstat -tpln | grep dockerd
Proto Recv-Q Send-Q Local Address Foreign Address PID/Program name
tcp 0 0 :::2376 :::* 980/dockerd
(virt1) 42sh$ netstat -tpln | grep dockerd
Proto Recv-Q Send-Q Local Address Foreign Address PID/Program name
tcp 0 0 :::2376 :::* 980/dockerd
```
</div>
@ -152,9 +152,9 @@ Essayons de renseigner simplement cette configuration à notre client Docker :
<div lang="en-US">
```shell
(main) 42sh$ docker -H tcp://$VM1_IP:2376/ info
Get http://$VM1_IP:2376/v1.32/info: net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x15\x03\x01\x00\x02\x02".
* Are you trying to connect to a TLS-enabled daemon without TLS?
(main) 42sh$ docker -H tcp://$VM1_IP:2376/ info
Get http://$VM1_IP:2376/v1.32/info: net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x15\x03\x01\x00\x02\x02".
* Are you trying to connect to a TLS-enabled daemon without TLS?
```
</div>
@ -174,11 +174,11 @@ nous n'avons qu'à recopier la clef et les certificats en place.
<div lang="en-US">
```shell
(main) 42sh$ mkdir remote/virt1
(main) 42sh$ scp "docker@$VM1_IP:.docker/*" remote/virt1
ca.pem
cert.pem
key.pem
(main) 42sh$ mkdir remote/virt1
(main) 42sh$ scp "docker@$VM1_IP:.docker/*" remote/virt1
ca.pem
cert.pem
key.pem
```
</div>
@ -186,7 +186,7 @@ Tentons maintenant de nous connecter au daemon distant en utilisant ces élémen
<div lang="en-US">
```shell
42sh$ DOCKER_CERT_PATH=remote/virt1/ docker -H tcp://$VM1_IP:2376/ --tlsverify info
42sh$ DOCKER_CERT_PATH=remote/virt1/ docker -H tcp://$VM1_IP:2376/ --tlsverify info
```
</div>

View file

@ -0,0 +1,15 @@
FROM debian
ENV CHRONOGRAF_VERSION 1.0.0
RUN apt-get update && apt-get install -y wget && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
wget -q https://dl.influxdata.com/chronograf/releases/chronograf_${CHRONOGRAF_VERSION}_amd64.deb && \
dpkg -i chronograf_${CHRONOGRAF_VERSION}_amd64.deb && \
rm -f chronograf_${CHRONOGRAF_VERSION}_amd64.deb
COPY chronograf.conf /etc/chronograf/chronograf.conf
EXPOSE 10000
VOLUME /var/lib/chronograf
CMD ["/opt/chronograf/chronograf"]

View file

@ -0,0 +1,2 @@
Bind="0.0.0.0:10000"
LocalDatabase="/var/lib/chronograf/chronograf.db"

View file

@ -0,0 +1,31 @@
version: '2'
services:
influxdb:
build: influxdb
ports:
- "8083:8083"
- "8086:8086"
volumes:
- influx-data:/var/lib/influxdb
networks:
- influx
chronograf:
build: chronograf
ports:
- "10000:10000"
volumes:
- chronograf-data:/var/lib/chronograf
networks:
- influx
volumes:
influx-data:
driver: local
chronograf-data:
driver: local
networks:
influx:
driver: bridge

View file

@ -0,0 +1,98 @@
version: '3'
services:
# FRONT
chronograf:
# Full tag list: https://hub.docker.com/r/library/chronograf/tags/
image: chronograf
deploy:
replicas: 3
placement:
constraints:
- node.role == manager
restart_policy:
condition: on-failure
environment:
INFLUXDB_URL: http://influxdb:8086
KAPACITOR_URL: http://kapacitor:9092
volumes:
# Mount for chronograf database
- chronograf-data:/var/lib/chronograf
ports:
# The WebUI for Chronograf is served on port 8888
- "8888:8888"
networks:
- influx
depends_on:
- kapacitor
- influxdb
# MIDDLE
kapacitor:
# Full tag list: https://hub.docker.com/r/library/kapacitor/tags/
image: kapacitor
deploy:
replicas: 1
placement:
constraints:
- node.role == manager
restart_policy:
condition: on-failure
environment:
HOSTNAME: kapacitor
KAPACITOR_INFLUXDB_0_URLS_0: http://influxdb:8086
volumes:
# Mount for kapacitor data directory
- kapacitor-data:/var/lib/kapacitor
# Mount for kapacitor configuration
#- /etc/kapacitor/config:/etc/kapacitor
ports:
# The API for Kapacitor is served on port 9092
- "9092:9092"
networks:
- influx
depends_on:
- influxdb
# BACK
telegraf:
# Full tag list: https://hub.docker.com/r/library/telegraf/tags/
image: telegraf
deploy:
mode: global
restart_policy:
condition: on-failure
volumes:
# Mount for telegraf configuration
- ./telegraf.conf:/etc/telegraf/telegraf.conf
# Mount for Docker API access
- /var/run/docker.sock:/var/run/docker.sock
networks:
- influx
depends_on:
- influxdb
# DATABASE
influxdb:
# Full tag list: https://hub.docker.com/r/library/influxdb/tags/
image: influxdb
deploy:
replicas: 1
placement:
constraints:
- node.role == manager
restart_policy:
condition: on-failure
volumes:
# Mount for influxdb data directory
- influxdb-data:/var/lib/influxdb
# Mount for influxdb configuration
#- /etc/influxdb/config:/etc/influxdb
ports:
# The API for InfluxDB is served on port 8086
- "8086:8086"
networks:
- influx
networks:
influx:
volumes:
chronograf-data:
kapacitor-data:
influxdb-data:

View file

@ -0,0 +1,35 @@
version: '3'
services:
influxdb:
image: influxdb
ports:
- "8083:8083"
- "8086:8086"
volumes:
- influx-data:/var/lib/influxdb
networks:
- influx
chronograf:
image: chronograf
ports:
- "8888:8888"
environment:
INFLUXDB_URL: http://influxdb:8086
KAPACITOR_URL: http://kapacitor:9092
volumes:
- chronograf-data:/var/lib/chronograf
networks:
- influx
depends_on:
- influxdb
volumes:
influx-data:
driver: local
chronograf-data:
driver: local
networks:
influx:

View file

@ -0,0 +1,15 @@
FROM debian
ENV INFLUXDB_VERSION 1.0.0
RUN apt-get update && apt-get install -y wget && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
wget -q https://dl.influxdata.com/influxdb/releases/influxdb_${INFLUXDB_VERSION}_amd64.deb && \
dpkg -i influxdb_${INFLUXDB_VERSION}_amd64.deb && \
rm -f influxdb_${INFLUXDB_VERSION}_amd64.deb
COPY influxdb.conf /etc/influxdb/influxdb.conf
EXPOSE 8083 8086
VOLUME /var/lib/influxdb
CMD ["influxd"]

View file

@ -0,0 +1,10 @@
[meta]
dir = "/var/lib/influxdb/meta"
[data]
dir = "/var/lib/influxdb/data"
engine = "tsm1"
wal-dir = "/var/lib/influxdb/wal"
[admin]
enabled = true

View file

@ -0,0 +1,22 @@
FROM debian
ENV INFLUXDB_VERSION 1.0.0
ENV CHRONOGRAF_VERSION 1.0.0
RUN apt-get update && apt-get install -y wget supervisor && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
wget -q https://dl.influxdata.com/influxdb/releases/influxdb_${INFLUXDB_VERSION}_amd64.deb && \
wget -q https://dl.influxdata.com/chronograf/releases/chronograf_${CHRONOGRAF_VERSION}_amd64.deb && \
dpkg -i influxdb_${INFLUXDB_VERSION}_amd64.deb chronograf_${CHRONOGRAF_VERSION}_amd64.deb && \
rm -f influxdb_${INFLUXDB_VERSION}_amd64.deb chronograf_${CHRONOGRAF_VERSION}_amd64.deb
EXPOSE 8083 8086 10000
VOLUME /var/lib/influxdb
VOLUME /var/lib/chronograf
COPY influxdb.conf /etc/influxdb/influxdb.conf
COPY chronograf.conf /etc/chronograf/chronograf.conf
COPY supervisor.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["/usr/bin/supervisord"]

View file

@ -0,0 +1,2 @@
Bind="0.0.0.0:10000"
LocalDatabase="/var/lib/chronograf/chronograf.db"

View file

@ -0,0 +1,10 @@
[meta]
dir = "/var/lib/influxdb/meta"
[data]
dir = "/var/lib/influxdb/data"
engine = "tsm1"
wal-dir = "/var/lib/influxdb/wal"
[admin]
enabled = true

View file

@ -0,0 +1,8 @@
[supervisord]
nodaemon=true
[program:influxdb]
command=/usr/bin/influxd
[program:chronograf]
command=/opt/chronograf/chronograf

View file

@ -0,0 +1,23 @@
FROM debian
ENV INFLUXDB_VERSION 1.0.0
ENV CHRONOGRAF_VERSION 1.0.0
RUN apt-get update && apt-get install -y wget && \
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
wget -q https://dl.influxdata.com/influxdb/releases/influxdb_${INFLUXDB_VERSION}_amd64.deb && \
wget -q https://dl.influxdata.com/chronograf/releases/chronograf_${CHRONOGRAF_VERSION}_amd64.deb && \
dpkg -i influxdb_${INFLUXDB_VERSION}_amd64.deb chronograf_${CHRONOGRAF_VERSION}_amd64.deb && \
rm -f influxdb_${INFLUXDB_VERSION}_amd64.deb chronograf_${CHRONOGRAF_VERSION}_amd64.deb
EXPOSE 8083 8086 10000
VOLUME /var/lib/influxdb
VOLUME /var/lib/chronograf
COPY influxdb.conf /etc/influxdb/influxdb.conf
COPY chronograf.conf /etc/chronograf/chronograf.conf
# start.sh should already be executable
COPY start.sh /usr/bin/start.sh
CMD ["start.sh"]

View file

@ -0,0 +1,2 @@
Bind="0.0.0.0:10000"
LocalDatabase="/var/lib/chronograf/chronograf.db"

View file

@ -0,0 +1,10 @@
[meta]
dir = "/var/lib/influxdb/meta"
[data]
dir = "/var/lib/influxdb/data"
engine = "tsm1"
wal-dir = "/var/lib/influxdb/wal"
[admin]
enabled = true

View file

@ -0,0 +1,9 @@
#!/bin/sh
influxd &
WAIT=$!
/opt/chronograf/chronograf &
WAIT="${WAIT} $!"
wait ${WAIT}

View file

@ -0,0 +1,24 @@
version: '2'
services:
nginx:
image: nginx
ports:
- "80:8080"
networks:
- ha
mysql:
image: mysql
volumes:
- mysql-data:/var/lib/mysql
networks:
- ha
volumes:
mysql-data:
driver: local
networks:
ha:
driver: bridge

View file

@ -0,0 +1,3 @@
[[outputs.influxdb]]
urls = ["http://influxdb:8086"] # required
database = "telegraf" # required

View file

@ -0,0 +1,11 @@
/var/log/telegraf/telegraf.log
{
rotate 6
daily
missingok
dateext
copytruncate
notifempty
compress
}

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -0,0 +1,208 @@
#! /usr/bin/env bash
# chkconfig: 2345 99 01
# description: Telegraf daemon
### BEGIN INIT INFO
# Provides: telegraf
# Required-Start: $all
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start telegraf at boot time
### END INIT INFO
# this init script supports three different variations:
# 1. New lsb that define start-stop-daemon
# 2. Old lsb that don't have start-stop-daemon but define, log, pidofproc and killproc
# 3. Centos installations without lsb-core installed
#
# In the third case we have to define our own functions which are very dumb
# and expect the args to be positioned correctly.
# Command-line options that can be set in /etc/default/telegraf. These will override
# any config file values.
TELEGRAF_OPTS=
USER=telegraf
GROUP=telegraf
if [ -r /lib/lsb/init-functions ]; then
source /lib/lsb/init-functions
fi
DEFAULT=/etc/default/telegraf
if [ -r $DEFAULT ]; then
source $DEFAULT
fi
if [ -z "$STDOUT" ]; then
STDOUT=/dev/null
fi
if [ ! -f "$STDOUT" ]; then
mkdir -p `dirname $STDOUT`
fi
if [ -z "$STDERR" ]; then
STDERR=/var/log/telegraf/telegraf.log
fi
if [ ! -f "$STDERR" ]; then
mkdir -p `dirname $STDERR`
fi
OPEN_FILE_LIMIT=65536
function pidofproc() {
if [ $# -ne 3 ]; then
echo "Expected three arguments, e.g. $0 -p pidfile daemon-name"
fi
if [ ! -f "$2" ]; then
return 1
fi
local pidfile=`cat $2`
if [ "x$pidfile" == "x" ]; then
return 1
fi
if ps --pid "$pidfile" | grep -q $(basename $3); then
return 0
fi
return 1
}
function killproc() {
if [ $# -ne 3 ]; then
echo "Expected three arguments, e.g. $0 -p pidfile signal"
fi
pid=`cat $2`
kill -s $3 $pid
}
function log_failure_msg() {
echo "$@" "[ FAILED ]"
}
function log_success_msg() {
echo "$@" "[ OK ]"
}
# Process name ( For display )
name=telegraf
# Daemon name, where is the actual executable
daemon=/usr/bin/telegraf
# pid file for the daemon
pidfile=/var/run/telegraf/telegraf.pid
piddir=`dirname $pidfile`
if [ ! -d "$piddir" ]; then
mkdir -p $piddir
chown $USER:$GROUP $piddir
fi
# Configuration file
config=/etc/telegraf/telegraf.conf
confdir=/etc/telegraf/telegraf.d
# If the daemon is not there, then exit.
[ -x $daemon ] || exit 5
case $1 in
start)
# Checked the PID file exists and check the actual status of process
if [ -e $pidfile ]; then
pidofproc -p $pidfile $daemon > /dev/null 2>&1 && status="0" || status="$?"
# If the status is SUCCESS then don't need to start again.
if [ "x$status" = "x0" ]; then
log_failure_msg "$name process is running"
exit 0 # Exit
fi
fi
# Bump the file limits, before launching the daemon. These will carry over to
# launched processes.
ulimit -n $OPEN_FILE_LIMIT
if [ $? -ne 0 ]; then
log_failure_msg "set open file limit to $OPEN_FILE_LIMIT"
fi
log_success_msg "Starting the process" "$name"
if which start-stop-daemon > /dev/null 2>&1; then
start-stop-daemon --chuid $USER:$GROUP --start --quiet --pidfile $pidfile --exec $daemon -- -pidfile $pidfile -config $config -config-directory $confdir $TELEGRAF_OPTS >>$STDOUT 2>>$STDERR &
else
su -s /bin/sh -c "nohup $daemon -pidfile $pidfile -config $config -config-directory $confdir $TELEGRAF_OPTS >>$STDOUT 2>>$STDERR &" $USER
fi
log_success_msg "$name process was started"
;;
stop)
# Stop the daemon.
if [ -e $pidfile ]; then
pidofproc -p $pidfile $daemon > /dev/null 2>&1 && status="0" || status="$?"
if [ "$status" = 0 ]; then
if killproc -p $pidfile SIGTERM && /bin/rm -rf $pidfile; then
log_success_msg "$name process was stopped"
else
log_failure_msg "$name failed to stop service"
fi
fi
else
log_failure_msg "$name process is not running"
fi
;;
reload)
# Reload the daemon.
if [ -e $pidfile ]; then
pidofproc -p $pidfile $daemon > /dev/null 2>&1 && status="0" || status="$?"
if [ "$status" = 0 ]; then
if killproc -p $pidfile SIGHUP; then
log_success_msg "$name process was reloaded"
else
log_failure_msg "$name failed to reload service"
fi
fi
else
log_failure_msg "$name process is not running"
fi
;;
restart)
# Restart the daemon.
$0 stop && sleep 2 && $0 start
;;
status)
# Check the status of the process.
if [ -e $pidfile ]; then
if pidofproc -p $pidfile $daemon > /dev/null; then
log_success_msg "$name Process is running"
exit 0
else
log_failure_msg "$name Process is not running"
exit 1
fi
else
log_failure_msg "$name Process is not running"
exit 3
fi
;;
version)
$daemon version
;;
*)
# For invalid arguments, print the usage message.
echo "Usage: $0 {start|stop|restart|status|version}"
exit 2
;;
esac

View file

@ -0,0 +1,17 @@
[Unit]
Description=The plugin-driven server agent for reporting metrics into InfluxDB
Documentation=https://github.com/influxdata/telegraf
After=network.target
[Service]
EnvironmentFile=-/etc/default/telegraf
User=telegraf
Environment='STDOUT=/var/log/telegraf/telegraf.log'
Environment='STDERR=/var/log/telegraf/telegraf.log'
ExecStart=/bin/sh -c "exec /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d ${TELEGRAF_OPTS} >>${STDOUT} 2>>${STDERR}"
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
KillMode=control-group
[Install]
WantedBy=multi-user.target

View file

@ -27,14 +27,14 @@ un serveur web, qui sera bien plus représentatif de ce que l'on pourra obtenir.
Précédemment, nous lancions notre serveur web favori avec :
```shell
docker container run --name mywebs -d nginx
docker container run --name mywebs -d nginx
```
La même commande, mais déployée à partir d'un nœud manager, vers un nœud
*workers*, est :
```shell
docker service create --name myWebS nginx
docker service create --name myWebS nginx
```
Allons-y, essayons !
@ -42,9 +42,9 @@ Allons-y, essayons !
On peut consulter l'état du service avec, comme d'habitude `ls` :
```shell
42sh$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
iyue3rgd0ohs myWebS replicated 1/1 nginx:latest
42sh$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
iyue3rgd0ohs myWebS replicated 1/1 nginx:latest
```
Vous pouvez constater que sur l'un des nœuds, sur lequel votre serveur aura été
@ -56,7 +56,7 @@ Rien de très excitant pour le moment, car nous ne pouvons pas vraiment accéder
d'ajouter une redirection de port :
```shell
docker service update --publish-add 80 myWebS
docker service update --publish-add 80 myWebS
```
À chaque modification de configuration, les conteneurs lancés au sein du
@ -101,13 +101,13 @@ Ce qui se fait souvent avec beaucoup de douleur hors de Docker, se résume ici
:
```shell
docker service update --replicas 3 myWebS
docker service update --replicas 3 myWebS
```
Roulement de tambours .......
```shell
docker service ps myWebS
docker service ps myWebS
```
nous montre bien, a priori 3 tâches en cours d'exécution pour ce service !
@ -127,7 +127,7 @@ Notre système de monitoring est une *stack* lui aussi, d'ailleurs, nous pouvons
la lancer grâce à notre `docker-compose.yml` :
```shell
docker stack deploy --compose-file docker-compose.yml tic
docker stack deploy --compose-file docker-compose.yml tic
```
### Règle de déploiement
@ -136,23 +136,23 @@ Par rapport à `docker-compose`, nous pouvons indiquer dans ce fichier des
paramètres qui ne serviront qu'au déploiement de notre tâche.
```yaml
version: '3'
services:
redis:
image: redis:alpine
version: '3'
services:
redis:
image: redis:alpine
deploy:
replicas: 6
update_config:
parallelism: 2
delay: 10s
restart_policy:
condition: on-failure
placement:
constraints:
- node.role == manager
resources:
memory: 50M
deploy:
replicas: 6
update_config:
parallelism: 2
delay: 10s
restart_policy:
condition: on-failure
placement:
constraints:
- node.role == manager
resources:
memory: 50M
```
Certaines informations comme les ressources, permettent à l'orchestrateur de

View file

@ -78,7 +78,7 @@ ce n'est pas plus compliqué que de faire :
<div lang="en-US">
```shell
docker swarm init
docker swarm init
```
</div>
@ -99,7 +99,7 @@ commande, vous pouvez retrouver le jeton avec :
<div lang="en-US">
```shell
docker swarm join-token worker
docker swarm join-token worker
```
</div>
@ -120,8 +120,8 @@ utilisant `docker-machine`.
<div lang="en-US">
```shell
eval $(docker-machine env echinoidea)
docker swarm join --token SWMTKN-1-...-... 10.10.10.42:2377
eval $(docker-machine env echinoidea)
docker swarm join --token SWMTKN-1-...-... 10.10.10.42:2377
```
</div>
@ -129,11 +129,11 @@ Une fois rejoint, vous devriez voir apparaître un nouveau nœud *worker* dans :
<div lang="en-US">
```shell
42sh$ eval $(docker-machine env -u)
42sh$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
y9skzvuf989hjrkciu8mnsy echinoidea Ready Active
ovgh6r32kgcbswb2we48br1 * wales Ready Active Leader
42sh$ eval $(docker-machine env -u)
42sh$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
y9skzvuf989hjrkciu8mnsy echinoidea Ready Active
ovgh6r32kgcbswb2we48br1 * wales Ready Active Leader
```
</div>

View file

@ -12,10 +12,10 @@ que l'on a réussi à faire précédemment en utilisant le `Dockerfile` suivant
<div lang="en-US">
```
FROM ubuntu:latest
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y nano
RUN apt-get update
RUN apt-get install -y nano
```
</div>
@ -33,7 +33,7 @@ commande `build` :
<div lang="en-US">
```
docker image build --tag=my_editor .
docker image build --tag=my_editor .
```
</div>
@ -42,7 +42,7 @@ constater l'existence de notre éditeur favori :
<div lang="en-US">
```
docker container run -it my_editor /bin/bash
docker container run -it my_editor /bin/bash
```
</div>
@ -56,9 +56,9 @@ Cela signifie que l'exemple suivant **ne fonctionne pas** :
<div lang="en-US">
```
COPY db.sql /db.sql
RUN service mysqld start
RUN mysql -u root -p toor virli < /db.sql
COPY db.sql /db.sql
RUN service mysqld start
RUN mysql -u root -p toor virli < /db.sql
```
</div>
@ -70,8 +70,8 @@ Pour avoir le résultat escompté, il faut exécuter les commandes ensemble :
<div lang="en-US">
```
COPY db.sql /db.sql
RUN service mysqld start && mysql -u root -p toor virli < /db.sql
COPY db.sql /db.sql
RUN service mysqld start && mysql -u root -p toor virli < /db.sql
```
</div>
@ -85,12 +85,12 @@ Construisons maintenant un conteneur avec un serveur web :
<div lang="en-US">
```
FROM my_editor
FROM my_editor
RUN apt-get update
RUN apt-get install -y nginx
RUN apt-get update
RUN apt-get install -y nginx
EXPOSE 80
EXPOSE 80
```
</div>
@ -103,9 +103,9 @@ redirection de port aléatoire sur la machine hôte vers votre conteneur :
<div lang="en-US">
```
docker image build --tag=my_webserver .
docker container run -it -P my_webserver /bin/bash
service nginx start
docker image build --tag=my_webserver .
docker container run -it -P my_webserver /bin/bash
service nginx start
```
</div>
@ -125,14 +125,14 @@ si aucune commande n'est passée lors du `run`, par exemple :
<div lang="en-US">
```
CMD nginx -g "daemon off;"
CMD nginx -g "daemon off;"
```
</div>
<div lang="en-US">
```
docker image build --tag=my_nginx .
docker container run -d -P my_nginx
docker image build --tag=my_nginx .
docker container run -d -P my_nginx
```
</div>

View file

@ -13,8 +13,8 @@ Petit indice, les requêtes SQL sont les suivantes :
<div lang="en-US">
```
DELETE FROM "data_source";
INSERT INTO "data_source" VALUES(1,1,0,'influxdb','influx','direct','http://${}:8086/','user','pass','metrics',0,'','',0,'null','2015-10-29 09:00:00','2015-10-29 09:05:00');
DELETE FROM "data_source";
INSERT INTO "data_source" VALUES(1,1,0,'influxdb','influx','direct','http://${}:8086/','user','pass','metrics',0,'','',0,'null','2015-10-29 09:00:00','2015-10-29 09:05:00');
```
</div>

View file

@ -102,10 +102,10 @@ votre InfluxDB écoute sur le port 8086 local :
<div lang="en-US">
```bash
TELEGRAF_VERSION=1.8.0
wget https://dl.influxdata.com/telegraf/releases/telegraf-${TELEGRAF_VERSION}_linux_amd64.tar.gz
tar xf telegraf-${TELEGRAF_VERSION}_linux_amd64.tar.gz
TELEGRAF_CONFIG_PATH=./telegraf/etc/telegraf/telegraf.conf ./telegraf/usr/bin/telegraf
TELEGRAF_VERSION=1.8.0
wget https://dl.influxdata.com/telegraf/releases/telegraf-${TELEGRAF_VERSION}_linux_amd64.tar.gz
tar xf telegraf-${TELEGRAF_VERSION}_linux_amd64.tar.gz
TELEGRAF_CONFIG_PATH=./telegraf/etc/telegraf/telegraf.conf ./telegraf/usr/bin/telegraf
```
</div>
@ -116,9 +116,9 @@ Dans l'interface sélectionnez la base `telegraf` puis explorez les valeurs :
<div lang="en-US">
```sql
SHOW MEASUREMENTS
SHOW FIELD KEYS
SELECT usage_idle FROM cpu WHERE cpu = 'cpu-total' ORDER BY time DESC LIMIT 5
SHOW MEASUREMENTS
SHOW FIELD KEYS
SELECT usage_idle FROM cpu WHERE cpu = 'cpu-total' ORDER BY time DESC LIMIT 5
```
</div>

View file

@ -56,9 +56,9 @@ Lorsqu'une ligne devient complexe, allez à la ligne :
<div lang="en-US">
```
RUN apt-get update && apt-get install -y \
nginx \
php5-fpm
RUN apt-get update && apt-get install -y \
nginx \
php5-fpm
```
</div>
@ -71,12 +71,12 @@ exemple :
<div lang="en-US">
```
RUN apt-get update && apt-get install -y \
bzr \
cvs \
git \
mercurial \
subversion
RUN apt-get update && apt-get install -y \
bzr \
cvs \
git \
mercurial \
subversion
```
</div>
@ -155,8 +155,8 @@ L'entrypoint peut être utilisé de deux manières différentes :
<div lang="en-US">
```
ENTRYPOINT ["nginx"]
CMD ["-g daemon off;"]
ENTRYPOINT ["nginx"]
CMD ["-g daemon off;"]
```
</div>
@ -167,20 +167,20 @@ CMD ["-g daemon off;"]
<div lang="en-US">
```shell
#!/bin/bash
set -e
#!/bin/bash
set -e
if [ "$1" = 'postgres' ]; then
chown -R postgres "$PGDATA"
if [ "$1" = 'postgres' ]; then
chown -R postgres "$PGDATA"
if [ -z "$(ls -A "$PGDATA")" ]; then
gosu postgres initdb
fi
if [ -z "$(ls -A "$PGDATA")" ]; then
gosu postgres initdb
fi
exec gosu postgres "$@"
fi
exec gosu postgres "$@"
fi
exec "$@"
exec "$@"
```
</div>

View file

@ -7,7 +7,7 @@ Pour créer une image, commençons par entrer dans un nouveau conteneur :
<div lang="en-US">
```
docker container run -it ubuntu /bin/bash
docker container run -it ubuntu /bin/bash
```
</div>
@ -20,7 +20,7 @@ pas incluses dans le conteneur.
<div lang="en-US">
```
apt-get update
apt-get update
```
</div>
@ -34,7 +34,7 @@ Installons maintenant un programme :
<div lang="en-US">
```
apt-get install nano
apt-get install nano
```
</div>
@ -43,7 +43,7 @@ autre terminal :
<div lang="en-US">
```
docker container ls
docker container ls
```
</div>
@ -58,7 +58,7 @@ commencer directement de votre image avec `nano` :
<div lang="en-US">
```
docker container commit CONTAINER my_nano
docker container commit CONTAINER my_nano
```
</div>
@ -68,7 +68,7 @@ d'`ubuntu` :
<div lang="en-US">
```
docker container run -it my_nano /bin/bash
docker container run -it my_nano /bin/bash
```
</div>

View file

@ -25,15 +25,15 @@ cela dépendra de votre avancée dans le projet) :
<div lang="en-US">
```
login_x-TP2/influxdb/Dockerfile
login_x-TP2/influxdb/influxdb.conf
login_x-TP2/chronograf
login_x-TP2/chronograf/Dockerfile
login_x-TP2/chronograf/chronograf.conf
login_x-TP2/mymonitoring
login_x-TP2/mymonitoring/Dockerfile
login_x-TP2/mymonitoring/chronograf.conf
login_x-TP2/mymonitoring/influxdb.conf
login_x-TP2/mymonitoring/supervisor.conf
login_x-TP1_5/influxdb/Dockerfile
login_x-TP1_5/influxdb/influxdb.conf
login_x-TP1_5/chronograf
login_x-TP1_5/chronograf/Dockerfile
login_x-TP1_5/chronograf/chronograf.conf
login_x-TP1_5/mymonitoring
login_x-TP1_5/mymonitoring/Dockerfile
login_x-TP1_5/mymonitoring/chronograf.conf
login_x-TP1_5/mymonitoring/influxdb.conf
login_x-TP1_5/mymonitoring/supervisor.conf
```
</div>

View file

@ -31,7 +31,7 @@ conteneur influxdb de la première partie est toujours lancé).
<div lang="en-US">
```shell
docker run --rm --link YOUR_INFLUX_CNTR_NAME:influxdb chronograf
docker run --rm --link YOUR_INFLUX_CNTR_NAME:influxdb chronograf
```
</div>
@ -52,7 +52,7 @@ suivantes :
<div lang="en-US">
```sql
SELECT used, available, cached FROM mem WHERE tmpltime()
SELECT mean(usage_idle) FROM cpu WHERE tmpltime() GROUP BY time(20s), cpu
SELECT used, available, cached FROM mem WHERE tmpltime()
SELECT mean(usage_idle) FROM cpu WHERE tmpltime() GROUP BY time(20s), cpu
```
</div>

View file

@ -83,9 +83,6 @@ cela. Mais plein de gens ont cette problématique et l'application `supervisor`
répond parfaitement à notre problématique !
## `HEALTHCHECK`
## `supervisor`
Première étape : installer `supervisor`, le paquet se trouve dans les dépôts.