Skip to content

Instantly share code, notes, and snippets.

@eveld
Last active April 24, 2020 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eveld/a47b9291dcf25c0e77a8ca9b99564c99 to your computer and use it in GitHub Desktop.
Save eveld/a47b9291dcf25c0e77a8ca9b99564c99 to your computer and use it in GitHub Desktop.
job "api" {
datacenters = ["ian-esxi-tst"]
type = "service"
group "api" {
count = 1
network {
mode = "bridge"
port "http" {
to = 9090
static = 20345
}
}
service {
name = "api"
port = "9090"
connect {
sidecar_service {
proxy {
upstreams {
destination_name = "database"
local_bind_port = 5432
}
}
}
}
}
task "api" {
driver = "docker"
config {
image = "nicholasjackson/fake-service:v0.9.0"
}
env {
NAME = "api"
MESSAGE = "ok"
LISTEN_ADDR = "0.0.0.0:9090"
UPSTREAM_URIS = "http://localhost:5432"
TIMING_VARIANCE = "25"
HTTP_CLIENT_KEEP_ALIVES = "true"
}
resources {
cpu = 100
memory = 256
}
}
}
}
job "database" {
datacenters = ["ian-esxi-tst"]
type = "service"
group "database" {
count = 1
network {
mode = "bridge"
}
service {
name = "database"
port = "5432"
connect {
sidecar_service {}
}
}
task "database" {
driver = "docker"
config {
image = "nicholasjackson/fake-service:v0.9.0"
}
env {
NAME = "database"
MESSAGE = "ok"
LISTEN_ADDR = "0.0.0.0:5432"
TIMING_VARIANCE = "25"
HTTP_CLIENT_KEEP_ALIVES = "true"
}
resources {
cpu = 100
memory = 256
}
}
}
}
job "gateway-cloud" {
datacenters = ["cloud"]
region = "cloud"
type = "service"
group "gateways" {
count = 1
network {
mode = "bridge"
port "https" {
static = 443
to = 443
}
}
constraint {
operator = "distinct_hosts"
value = "true"
}
task "gateway" {
driver = "docker"
env {
CONSUL_HTTP_ADDR="${attr.unique.network.ip-address}:8500"
CONSUL_GRPC_ADDR="${attr.unique.network.ip-address}:8502"
}
config {
image = "nicholasjackson/consul-envoy:v1.7.2-v0.14.1"
command = "consul"
args = [
"connect", "envoy",
"-mesh-gateway",
"-register",
"-wan-address", "192.168.10.100:443",
"--",
"-l", "debug"
]
}
}
}
}
job "gateway-onprem" {
datacenters = ["onprem"]
region = "onprem"
type = "service"
group "gateways" {
count = 1
network {
mode = "bridge"
port "https" {
static = 443
to = 443
}
}
constraint {
operator = "distinct_hosts"
value = "true"
}
task "gateway" {
driver = "docker"
env {
CONSUL_HTTP_ADDR="${attr.unique.network.ip-address}:8500"
CONSUL_GRPC_ADDR="${attr.unique.network.ip-address}:8502"
}
config {
image = "nicholasjackson/consul-envoy:v1.7.2-v0.14.1"
command = "consul"
args = [
"connect", "envoy",
"-mesh-gateway",
"-register",
"-wan-address", "192.168.5.100:443",
"--",
"-l", "debug"
]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment