mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-07-18 12:29:18 +00:00
rolling updates streamline
This commit is contained in:
committed by
Jérôme Petazzoni
parent
11387f1330
commit
f0b48935fa
@@ -1,6 +1,6 @@
|
||||
name: healthchecks
|
||||
|
||||
# Health checks
|
||||
# Health checks and auto-rollbacks
|
||||
|
||||
(New in Docker Engine 1.12)
|
||||
|
||||
@@ -61,7 +61,7 @@ name: healthchecks
|
||||
|
||||
---
|
||||
|
||||
## Automated rollbacks
|
||||
## Enabling health checks and auto-rollbacks
|
||||
|
||||
Here is a comprehensive example using the CLI:
|
||||
|
||||
@@ -109,7 +109,9 @@ We will use the following Compose file (`stacks/dockercoins+healthcheck.yml`):
|
||||
|
||||
---
|
||||
|
||||
## Enabling auto-rollback
|
||||
## Enabling auto-rollback in dockercoins
|
||||
|
||||
We need to update our services with a healthcheck.
|
||||
|
||||
.exercise[
|
||||
|
||||
@@ -118,7 +120,7 @@ We will use the following Compose file (`stacks/dockercoins+healthcheck.yml`):
|
||||
cd ~/container.training/stacks
|
||||
```
|
||||
|
||||
- Deploy the updated stack:
|
||||
- Deploy the updated stack with healthchecks built-in:
|
||||
```bash
|
||||
docker stack deploy --compose-file dockercoins+healthcheck.yml dockercoins
|
||||
```
|
||||
@@ -129,33 +131,13 @@ This will also scale the `hasher` service to 7 instances.
|
||||
|
||||
---
|
||||
|
||||
## Visualizing a rolling update
|
||||
|
||||
First, let's make an "innocent" change and deploy it.
|
||||
|
||||
.exercise[
|
||||
|
||||
- Update the `sleep` delay in the code:
|
||||
```bash
|
||||
sed -i "s/sleep 0.1/sleep 0.2/" dockercoins/hasher/hasher.rb
|
||||
```
|
||||
|
||||
- Build, ship, and run the new image:
|
||||
```bash
|
||||
export TAG=v0.5
|
||||
docker-compose -f dockercoins+healthcheck.yml build
|
||||
docker-compose -f dockercoins+healthcheck.yml push
|
||||
docker service update dockercoins_hasher \
|
||||
--image=127.0.0.1:5000/hasher:$TAG
|
||||
```
|
||||
|
||||
]
|
||||
|
||||
---
|
||||
|
||||
## Visualizing an automated rollback
|
||||
|
||||
And now, a breaking change that will cause the health check to fail:
|
||||
Here's a good example of why healthchecks are necessary.
|
||||
|
||||
This breaking change will prevent the app from listening on the correct port.
|
||||
|
||||
The container still runs fine, it just won't accept connections on port 80.
|
||||
|
||||
.exercise[
|
||||
|
||||
@@ -166,7 +148,7 @@ And now, a breaking change that will cause the health check to fail:
|
||||
|
||||
- Build, ship, and run the new image:
|
||||
```bash
|
||||
export TAG=v0.6
|
||||
export TAG=v0.5
|
||||
docker-compose -f dockercoins+healthcheck.yml build
|
||||
docker-compose -f dockercoins+healthcheck.yml push
|
||||
docker service update dockercoins_hasher \
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
# Rolling updates
|
||||
|
||||
- Let's change a scaled service: `worker`
|
||||
- Let's change a scaled service: `hasher`
|
||||
|
||||
.exercise[
|
||||
|
||||
- Edit `worker/worker.py`
|
||||
|
||||
- Locate the `sleep` instruction and change the delay
|
||||
- Update the `sleep` delay in the code to 0.2:
|
||||
```bash
|
||||
sed -i "s/sleep 0.1/sleep 0.2/" dockercoins/hasher/hasher.rb
|
||||
```
|
||||
|
||||
- Build, ship, and run our changes:
|
||||
```bash
|
||||
export TAG=v0.4
|
||||
docker-compose -f dockercoins.yml build
|
||||
docker-compose -f dockercoins.yml push
|
||||
docker stack deploy -c dockercoins.yml dockercoins
|
||||
docker service update dockercoins_hasher \
|
||||
--image=127.0.0.1:5000/hasher:$TAG
|
||||
```
|
||||
|
||||
]
|
||||
@@ -46,7 +48,7 @@ If you had stopped the workers earlier, this will automatically restart them.
|
||||
|
||||
By default, SwarmKit does a rolling upgrade, one instance at a time.
|
||||
|
||||
We should therefore see the workers being updated one my one.
|
||||
We should therefore see the workers being updated one by one.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class: btp-manual
|
||||
|
||||
## Integration with Compose
|
||||
## Integrtaion with Compose
|
||||
|
||||
- We saw how to manually build, tag, and push images to a registry
|
||||
|
||||
@@ -22,7 +22,7 @@ class: btp-manual
|
||||
|
||||
---
|
||||
|
||||
# Integration with Compose
|
||||
# Swarm Stacks
|
||||
|
||||
- Compose is great for local development
|
||||
|
||||
@@ -55,26 +55,11 @@
|
||||
|
||||
.exercise[
|
||||
|
||||
- Edit the file `webui/files/index.html`:
|
||||
- Update the size of text on our webui:
|
||||
```bash
|
||||
vi dockercoins/webui/files/index.html
|
||||
sed -i "s/15px/50px/" dockercoins/webui/files/index.html
|
||||
```
|
||||
|
||||
<!-- ```wait <title>``` -->
|
||||
|
||||
- Locate the `font-size` CSS attribute and increase it (at least double it)
|
||||
|
||||
<!--
|
||||
```keys /font-size```
|
||||
```keys ^J```
|
||||
```keys lllllllllllllcw45px```
|
||||
```keys ^[``` ]
|
||||
```keys :wq```
|
||||
```keys ^J```
|
||||
-->
|
||||
|
||||
- Save and exit
|
||||
|
||||
]
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user