Skip to content

Commit

Permalink
Merge pull request #6 from hashicorp/ingress-gateway-examples
Browse files Browse the repository at this point in the history
ingress-gateway: add initial demo files for ingress gateways
shoenig authored Aug 26, 2020

Verified

This commit was signed with the committer’s verified signature.
fiji-flo Florian Dieminger
2 parents 44f44b1 + 394bde8 commit 4287966
Showing 2 changed files with 197 additions and 0 deletions.
97 changes: 97 additions & 0 deletions ingress-gateway/ig-bridge-demo.nomad
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
job "ig-bridge-demo" {

datacenters = ["dc1"]

# This group will have a task providing the ingress gateway automatically
# created by Nomad. The ingress gateway is based on the Envoy proxy being
# managed by the docker driver.
group "ingress-group" {

network {
mode = "bridge"

# This example will enable plain HTTP traffic to access the uuid-api connect
# native example service on port 8080.
port "inbound" {
static = 8080
to = 8080
}
}

service {
name = "my-ingress-service"
port = "8080"

connect {
gateway {

# Consul gateway [envoy] proxy options.
proxy {
# The following options are automatically set by Nomad if not
# explicitly configured when using bridge networking.
#
# envoy_gateway_no_default_bind = true
# envoy_gateway_bind_addresses "uuid-api" {
# address = "0.0.0.0"
# port = <associated listener.port>
# }
#
# Additional options are documented at
# https://www.nomadproject.io/docs/job-specification/gateway#proxy-parameters
}

# Consul Ingress Gateway Configuration Entry.
ingress {
# Nomad will automatically manage the Configuration Entry in Consul
# given the parameters in the ingress block.
#
# Additional options are documented at
# https://www.nomadproject.io/docs/job-specification/gateway#ingress-parameters
listener {
port = 8080
protocol = "tcp"
service {
name = "uuid-api"
}
}
}
}
}
}
}

# The UUID generator from the connect-native demo is used as an example service.
# The ingress gateway above makes access to the service possible over normal HTTP.
# For example,
#
# $ curl $(dig +short @127.0.0.1 -p 8600 uuid-api.ingress.dc1.consul. ANY):8080
group "generator" {
network {
mode = "host"
port "api" {}
}

service {
name = "uuid-api"
port = "${NOMAD_PORT_api}"

connect {
native = true
}
}

task "generate" {
driver = "docker"

config {
image = "hashicorpnomad/uuid-api:v3"
network_mode = "host"
}

env {
BIND = "0.0.0.0"
PORT = "${NOMAD_PORT_api}"
}
}
}
}
100 changes: 100 additions & 0 deletions ingress-gateway/ig-demo.nomad
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
job "ig-demo" {

datacenters = ["dc1"]

# This group will have a task providing the ingress gateway automatically
# created by Nomad. The ingress gateway is based on the Envoy proxy being
# managed by the docker driver.
group "ingress-group" {

network {
mode = "host"

# This example will enable plain HTTP traffic to access the uuid-api connect
# native example service on port 8080.
port "inbound" {
static = 8080
}

# When running an ingress gateway in host networking mode, the underlying
# Envoy proxy creates an admin interface listener bound to localhost that
# requires the allocation of a port.
port "envoy" {
static = 19001
}
}

service {
name = "my-ingress-service"

# The Envoy proxy admin interface listener will use the service port to
# determine its localhost bind address.
port = "envoy"

connect {
gateway {

# Consul gateway [envoy] proxy options.
proxy {
# Envoy proxy options are documented at
# https://www.nomadproject.io/docs/job-specification/gateway#proxy-parameters
connect_timeout = "500ms"
}

# Consul Ingress Gateway Configuration Entry.
ingress {
# Nomad will automatically manage the Configuration Entry in Consul
# given the parameters in the ingress block.
#
# Additional options are documented at
# https://www.nomadproject.io/docs/job-specification/gateway#ingress-parameters
listener {
port = 8080
protocol = "tcp"
service {
name = "uuid-api"
}
}
}
}
}
}
}

# The UUID generator from the connect-native demo is used as an example service.
# The ingress gateway above makes access to the service possible over normal HTTP.
# For example,
#
# $ curl $(dig +short @127.0.0.1 -p 8600 uuid-api.ingress.dc1.consul. ANY):8080
group "generator" {
network {
mode = "host"
port "api" {
to = -1
}
}

service {
name = "uuid-api"
port = "${NOMAD_PORT_api}"

connect {
native = true
}
}

task "generate" {
driver = "docker"

config {
image = "hashicorpnomad/uuid-api:v3"
network_mode = "host"
}

env {
BIND = "0.0.0.0"
PORT = "${NOMAD_PORT_api}"
}
}
}
}

0 comments on commit 4287966

Please sign in to comment.