Include Traefik Tags for Canary Allocations
All checks were successful
Build and Push Docker Image / build (push) Successful in 2m6s
All checks were successful
Build and Push Docker Image / build (push) Successful in 2m6s
This commit is contained in:
@@ -3,6 +3,34 @@
|
|||||||
|
|
||||||
locals {
|
locals {
|
||||||
HOST = "cbraaten.dev"
|
HOST = "cbraaten.dev"
|
||||||
|
|
||||||
|
# shared by both production and canary allocations so Traefik never
|
||||||
|
# loses sight of the router during a rolling switchover
|
||||||
|
traefik_tags = [
|
||||||
|
# ----- router for the naked domain -----
|
||||||
|
"traefik.enable=true",
|
||||||
|
"traefik.http.routers.blog.rule=Host(`${local.HOST}`)",
|
||||||
|
"traefik.http.routers.blog.entrypoints=websecure",
|
||||||
|
"traefik.http.routers.blog.tls=true",
|
||||||
|
"traefik.http.routers.blog.service=blog-svc",
|
||||||
|
|
||||||
|
# ----- router for the www domain -----
|
||||||
|
"traefik.http.routers.blog-www.rule=Host(`www.${local.HOST}`)",
|
||||||
|
"traefik.http.routers.blog-www.entrypoints=websecure",
|
||||||
|
"traefik.http.routers.blog-www.tls=true",
|
||||||
|
"traefik.http.routers.blog-www.middlewares=redirect-www-to-root",
|
||||||
|
|
||||||
|
# ----- middleware that does the 301 redirect -----
|
||||||
|
"traefik.http.middlewares.redirect-www-to-root.redirectregex.regex=^https?://www\\.${local.HOST}(.*)",
|
||||||
|
"traefik.http.middlewares.redirect-www-to-root.redirectregex.replacement=https://${local.HOST}$${1}",
|
||||||
|
"traefik.http.middlewares.redirect-www-to-root.redirectregex.permanent=true",
|
||||||
|
|
||||||
|
# ----- service and health check -----
|
||||||
|
"traefik.http.services.blog-svc.loadbalancer.healthcheck.path=/healthz",
|
||||||
|
"traefik.http.services.blog-svc.loadbalancer.healthcheck.interval=5s",
|
||||||
|
"traefik.http.services.blog-svc.loadbalancer.healthcheck.timeout=2s",
|
||||||
|
"traefik.http.services.blog-svc.loadbalancer.healthcheck.hostname=${local.HOST}",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "image_tag" {
|
variable "image_tag" {
|
||||||
@@ -31,35 +59,8 @@ job "blog" {
|
|||||||
provider = "consul"
|
provider = "consul"
|
||||||
port = "http"
|
port = "http"
|
||||||
|
|
||||||
tags = [
|
tags = local.traefik_tags
|
||||||
# ----- router for the naked domain -----
|
canary_tags = local.traefik_tags
|
||||||
"traefik.enable=true",
|
|
||||||
"traefik.http.routers.blog.rule=Host(`${local.HOST}`)",
|
|
||||||
"traefik.http.routers.blog.entrypoints=websecure",
|
|
||||||
"traefik.http.routers.blog.tls=true",
|
|
||||||
"traefik.http.routers.blog.service=blog-svc",
|
|
||||||
|
|
||||||
# ----- router for the www domain (new) -----
|
|
||||||
"traefik.http.routers.blog-www.rule=Host(`www.${local.HOST}`)",
|
|
||||||
"traefik.http.routers.blog-www.entrypoints=websecure",
|
|
||||||
"traefik.http.routers.blog-www.tls=true",
|
|
||||||
"traefik.http.routers.blog-www.middlewares=redirect-www-to-root",
|
|
||||||
|
|
||||||
# ----- middleware that does the 301 redirect -----
|
|
||||||
"traefik.http.middlewares.redirect-www-to-root.redirectregex.regex=^https?://www\\.${local.HOST}(.*)",
|
|
||||||
"traefik.http.middlewares.redirect-www-to-root.redirectregex.replacement=https://${local.HOST}$${1}",
|
|
||||||
"traefik.http.middlewares.redirect-www-to-root.redirectregex.permanent=true",
|
|
||||||
|
|
||||||
# ----- service and health check -----
|
|
||||||
"traefik.http.services.blog-svc.loadbalancer.healthcheck.path=/healthz",
|
|
||||||
"traefik.http.services.blog-svc.loadbalancer.healthcheck.interval=5s",
|
|
||||||
"traefik.http.services.blog-svc.loadbalancer.healthcheck.timeout=2s",
|
|
||||||
"traefik.http.services.blog-svc.loadbalancer.healthcheck.hostname=${local.HOST}",
|
|
||||||
]
|
|
||||||
|
|
||||||
# canary allocations register with these tags instead, so Traefik
|
|
||||||
# does not route production traffic to them before promotion
|
|
||||||
canary_tags = ["canary"]
|
|
||||||
|
|
||||||
check {
|
check {
|
||||||
name = "blog-health"
|
name = "blog-health"
|
||||||
|
|||||||
@@ -119,7 +119,22 @@
|
|||||||
"traefik.http.services.blog-svc.loadbalancer.healthcheck.hostname=cbraaten.dev"
|
"traefik.http.services.blog-svc.loadbalancer.healthcheck.hostname=cbraaten.dev"
|
||||||
],
|
],
|
||||||
"CanaryTags": [
|
"CanaryTags": [
|
||||||
"canary"
|
"traefik.enable=true",
|
||||||
|
"traefik.http.routers.blog.rule=Host(`cbraaten.dev`)",
|
||||||
|
"traefik.http.routers.blog.entrypoints=websecure",
|
||||||
|
"traefik.http.routers.blog.tls=true",
|
||||||
|
"traefik.http.routers.blog.service=blog-svc",
|
||||||
|
"traefik.http.routers.blog-www.rule=Host(`www.cbraaten.dev`)",
|
||||||
|
"traefik.http.routers.blog-www.entrypoints=websecure",
|
||||||
|
"traefik.http.routers.blog-www.tls=true",
|
||||||
|
"traefik.http.routers.blog-www.middlewares=redirect-www-to-root",
|
||||||
|
"traefik.http.middlewares.redirect-www-to-root.redirectregex.regex=^https?://www\\.cbraaten.dev(.*)",
|
||||||
|
"traefik.http.middlewares.redirect-www-to-root.redirectregex.replacement=https://cbraaten.dev${1}",
|
||||||
|
"traefik.http.middlewares.redirect-www-to-root.redirectregex.permanent=true",
|
||||||
|
"traefik.http.services.blog-svc.loadbalancer.healthcheck.path=/healthz",
|
||||||
|
"traefik.http.services.blog-svc.loadbalancer.healthcheck.interval=5s",
|
||||||
|
"traefik.http.services.blog-svc.loadbalancer.healthcheck.timeout=2s",
|
||||||
|
"traefik.http.services.blog-svc.loadbalancer.healthcheck.hostname=cbraaten.dev"
|
||||||
],
|
],
|
||||||
"EnableTagOverride": false,
|
"EnableTagOverride": false,
|
||||||
"PortLabel": "http",
|
"PortLabel": "http",
|
||||||
|
|||||||
Reference in New Issue
Block a user