From c4d76ba367c349a669d6df25e00c9e0afd887724 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Petazzoni?= Date: Thu, 12 Oct 2017 09:04:56 +0200 Subject: [PATCH] =?UTF-8?q?Backport=20#92=20(thanks=20@bretfisher=20?= =?UTF-8?q?=F0=9F=91=8D=F0=9F=8F=BB)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/healthchecks.md | 26 +++++---------------- stacks/dockercoins+healthchecks.yml | 35 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 21 deletions(-) create mode 100644 stacks/dockercoins+healthchecks.yml diff --git a/docs/healthchecks.md b/docs/healthchecks.md index 5435e1af..7a62e005 100644 --- a/docs/healthchecks.md +++ b/docs/healthchecks.md @@ -1,7 +1,5 @@ name: healthchecks -class: healthchecks - # Health checks (New in Docker Engine 1.12) @@ -22,8 +20,6 @@ class: healthchecks --- -class: healthchecks - ## Defining health checks - In a Dockerfile, with the [HEALTHCHECK](https://docs.docker.com/engine/reference/builder/#healthcheck) instruction @@ -48,8 +44,6 @@ class: healthchecks --- -class: healthcheck - ## Using health checks - With `docker run`, health checks are purely informative @@ -67,8 +61,6 @@ class: healthcheck --- -class: healthcheck - ## Automated rollbacks Here is a comprehensive example using the CLI: @@ -94,8 +86,6 @@ docker service update \ --- -class: healthcheck - ## Implementing auto-rollback in practice We will use the following Compose file (`stacks/dockercoins+healthchecks.yml`): @@ -118,15 +108,13 @@ We will use the following Compose file (`stacks/dockercoins+healthchecks.yml`): --- -class: healthcheck - ## Enabling auto-rollback .exercise[ - Go to the `stacks` directory: ```bash - cd ~/orchestration-workshop/ + cd ~/orchestration-workshop/stacks ``` - Deploy the updated stack: @@ -140,8 +128,6 @@ This will also scale the `hasher` service to 7 instances. --- -class: healthcheck - ## Visualizing a rolling update First, let's make an "innocent" change and deploy it. @@ -155,18 +141,17 @@ First, let's make an "innocent" change and deploy it. - Build, ship, and run the new image: ```bash + export TAG=v0.3 docker-compose -f dockercoins+healthchecks.yml build docker-compose -f dockercoins+healthchecks.yml push docker service update dockercoins_hasher \ - --detach=false --image=127.0.0.1:5000/hasher:latest + --detach=false --image=127.0.0.1:5000/hasher:$TAG ``` ] --- -class: healthcheck - ## Visualizing an automated rollback And now, a breaking change that will cause the health check to fail: @@ -180,18 +165,17 @@ And now, a breaking change that will cause the health check to fail: - Build, ship, and run the new image: ```bash + export TAG=v0.4 docker-compose -f dockercoins+healthchecks.yml build docker-compose -f dockercoins+healthchecks.yml push docker service update dockercoins_hasher \ - --detach=false --image=127.0.0.1:5000/hasher:latest + --detach=false --image=127.0.0.1:5000/hasher:$TAG ``` ] --- -class: healthcheck - ## Command-line options available for health checks, rollbacks, etc. Batteries included, but swappable diff --git a/stacks/dockercoins+healthchecks.yml b/stacks/dockercoins+healthchecks.yml new file mode 100644 index 00000000..0f01d557 --- /dev/null +++ b/stacks/dockercoins+healthchecks.yml @@ -0,0 +1,35 @@ +version: "3" + +services: + rng: + build: dockercoins/rng + image: ${REGISTRY-127.0.0.1:5000}/rng:${TAG-latest} + deploy: + mode: global + + hasher: + build: dockercoins/hasher + image: ${REGISTRY-127.0.0.1:5000}/hasher:${TAG-latest} + deploy: + replicas: 7 + update_config: + delay: 5s + failure_action: rollback + max_failure_ratio: .5 + monitor: 5s + parallelism: 1 + + webui: + build: dockercoins/webui + image: ${REGISTRY-127.0.0.1:5000}/webui:${TAG-latest} + ports: + - "8000:80" + + redis: + image: redis + + worker: + build: dockercoins/worker + image: ${REGISTRY-127.0.0.1:5000}/worker:${TAG-latest} + deploy: + replicas: 10