mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-02-14 17:49:59 +00:00
Backport #92 (thanks @bretfisher 👍🏻)
This commit is contained in:
@@ -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
|
||||
|
||||
35
stacks/dockercoins+healthchecks.yml
Normal file
35
stacks/dockercoins+healthchecks.yml
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user