diff --git a/nomad/app_dynamic.hcl b/nomad/app_dynamic.hcl index fe81c5b..91b68ed 100644 --- a/nomad/app_dynamic.hcl +++ b/nomad/app_dynamic.hcl @@ -1,7 +1,6 @@ job "dynamic-app" { - datacenters = ["core"] + datacenters = ["dc1"] type = "service" - namespace = "demo" group "dynamic-app" { count = 1 @@ -15,6 +14,14 @@ job "dynamic-app" { service { name = "dynamic-app" port = "web" + + check { + type = "http" + method = "GET" + interval = "10s" + timeout = "2s" + path = "/health" + } } restart { attempts = 10 diff --git a/nomad/app_hardcoded.hcl b/nomad/app_hardcoded.hcl index e9da48e..bbb2170 100644 --- a/nomad/app_hardcoded.hcl +++ b/nomad/app_hardcoded.hcl @@ -1,7 +1,6 @@ job "dynamic-app" { - datacenters = ["core"] + datacenters = ["dc1"] type = "service" - namespace = "demo" group "dynamic-app" { count = 1 diff --git a/nomad/app_static.hcl b/nomad/app_static.hcl index b2c2535..d738e65 100644 --- a/nomad/app_static.hcl +++ b/nomad/app_static.hcl @@ -1,7 +1,6 @@ job "dynamic-app" { - datacenters = ["core"] + datacenters = ["dc1"] type = "service" - namespace = "demo" group "dynamic-app" { count = 1 diff --git a/nomad/app_transit.hcl b/nomad/app_transit.hcl index 0528714..8f95828 100644 --- a/nomad/app_transit.hcl +++ b/nomad/app_transit.hcl @@ -1,7 +1,6 @@ job "dynamic-app" { - datacenters = ["core"] + datacenters = ["dc1"] type = "service" - namespace = "demo" group "dynamic-app" { count = 1 diff --git a/nomad/app_transit_connect.hcl b/nomad/app_transit_connect.hcl index 7c5a5fe..ff8621e 100644 --- a/nomad/app_transit_connect.hcl +++ b/nomad/app_transit_connect.hcl @@ -1,7 +1,6 @@ job "dynamic-app" { - datacenters = ["core"] + datacenters = ["dc1"] type = "service" - namespace = "demo" group "dynamic-app" { count = 1 diff --git a/nomad/app_transit_connect_traefik.hcl b/nomad/app_transit_connect_traefik.hcl new file mode 100644 index 0000000..5c5abec --- /dev/null +++ b/nomad/app_transit_connect_traefik.hcl @@ -0,0 +1,102 @@ +job "dynamic-app" { + datacenters = ["dc1"] + type = "service" + namespace = "demo" + + group "dynamic-app" { + count = 1 + + restart { + attempts = 10 + interval = "5m" + delay = "25s" + mode = "delay" + } + + network { + mode = "bridge" + // port "web" { + // to = 8080 + // } + } + + vault { + policies = ["nomad-dynamic-app"] + change_mode = "signal" + change_signal = "SIGINT" + } + + + service { + name = "dynamic-app" + port = "8080" + tags = ["traefik.enable=true", + "traefik.http.routers.dynamic-app.rule=Host(`dynamic-app.127.0.0.1.nip.io`)", + "traefik.http.routers.dynamic-app.entrypoints=http", + "traefik.http.routers.dynamic-app.tls=false", + "traefik.connsulcatalog.connect=true" + ] + connect { + sidecar_service { + proxy { + upstreams { + destination_name = "mysql-server" + local_bind_port = 3306 + } + } + } + } + check { + expose = true + type = "http" + name = "heatlh" + method = "GET" + interval = "10s" + timeout = "2s" + path = "/health" + } + } + + task "dynamic-app" { + driver = "docker" + + config { + image = "docker.io/mabunixda/dynamic-vault-app" + volumes = [ + "local/config.ini:/usr/src/app/config/config.ini" + ] + ports = [8080] + } + + template { + destination = "local/config.ini" + data = <