Skip to content

Instantly share code, notes, and snippets.

@prayagsingh
Forked from jakubhajek/stack-canary.yml
Created April 27, 2020 11:07
Show Gist options
  • Save prayagsingh/0cecde5bb7f0ba75f59285977dd4f3c0 to your computer and use it in GitHub Desktop.
Save prayagsingh/0cecde5bb7f0ba75f59285977dd4f3c0 to your computer and use it in GitHub Desktop.
The example of canary deployment using Traefik 2.x
# docker stack deploy -c stack-canary.yml canary --with-registry-auth --prune
version: "3.7"
services:
app1:
image: jakubhajek/app1-node:v1
healthcheck:
test: wget --quiet --tries=1 --spider http://localhost:3000/ || exit 1
interval: 3s
timeout: 1s
retries: 1
start_period: 5s
networks:
- proxy-main
deploy:
mode: replicated
replicas: 2
update_config:
failure_action: rollback
parallelism: 1
delay: 5s
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
resources:
limits:
memory: 128M
labels:
- "traefik.enable=true"
- "traefik.http.routers.app1.rule=Host(`canary.labs.cometari.eu`)"
- "traefik.http.routers.app1.tls.certresolver=le"
- "traefik.http.routers.app1.entrypoints=websecure"
# Canary approach
- "traefik.http.routers.app1.service=canary@file"
- "traefik.http.services.app1_svc.loadbalancer.server.port=3000"
app2:
image: jakubhajek/app1-node:v2
healthcheck:
test: wget --quiet --tries=1 --spider http://localhost:3000/ || exit 1
interval: 3s
timeout: 1s
retries: 1
start_period: 5s
networks:
- proxy-main
deploy:
mode: replicated
replicas: 2
resources:
limits:
memory: 128M
labels:
- "traefik.enable=true"
- "traefik.http.services.app2_svc.loadbalancer.server.port=3000"
networks:
proxy-main:
external: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment