Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ingress-gateway: add initial demo files for ingress gateways #6

Merged
merged 3 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" {
nickethier marked this conversation as resolved.
Show resolved Hide resolved

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need this if network mode is "host"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agh good catch! Old habits die hard..

}
}

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}"
}
}
}
}