2019-09-05 18:08:31 +00:00
|
|
|
---
|
2020-02-06 23:45:31 +00:00
|
|
|
layout: docs
|
|
|
|
page_title: upstreams Stanza - Job Specification
|
|
|
|
sidebar_title: upstreams
|
2019-09-05 18:08:31 +00:00
|
|
|
description: |-
|
|
|
|
The "upstreams" stanza allows specifying options for configuring
|
|
|
|
upstream services
|
|
|
|
---
|
|
|
|
|
|
|
|
# `upstreams` Stanza
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
<Placement
|
|
|
|
groups={[
|
|
|
|
'job',
|
|
|
|
'group',
|
|
|
|
'service',
|
|
|
|
'connect',
|
|
|
|
'sidecar_service',
|
|
|
|
'proxy',
|
|
|
|
'upstreams'
|
|
|
|
]}
|
|
|
|
/>
|
2019-09-05 18:08:31 +00:00
|
|
|
|
2019-09-06 05:52:11 +00:00
|
|
|
The `upstreams` stanza allows configuring various options for managing upstream
|
|
|
|
services that a [Consul
|
2020-03-20 21:00:59 +00:00
|
|
|
Connect](/docs/integrations/consul-connect) proxy routes to. It
|
2019-09-06 05:52:11 +00:00
|
|
|
is valid only within the context of a `proxy` stanza.
|
|
|
|
|
|
|
|
For Consul-specific details see the [Consul Connect
|
|
|
|
Guide](https://learn.hashicorp.com/consul/getting-started/connect#register-a-dependent-service-and-proxy).
|
2019-09-05 18:08:31 +00:00
|
|
|
|
|
|
|
```hcl
|
|
|
|
job "countdash" {
|
|
|
|
datacenters = ["dc1"]
|
|
|
|
|
|
|
|
group "dashboard" {
|
|
|
|
network {
|
|
|
|
mode = "bridge"
|
|
|
|
|
|
|
|
port "http" {
|
|
|
|
static = 9002
|
|
|
|
to = 9002
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
service {
|
|
|
|
name = "count-dashboard"
|
|
|
|
port = "9002"
|
|
|
|
|
|
|
|
connect {
|
|
|
|
sidecar_service {
|
|
|
|
proxy {
|
|
|
|
upstreams {
|
|
|
|
destination_name = "count-api"
|
|
|
|
local_bind_port = 8080
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task "dashboard" {
|
|
|
|
driver = "docker"
|
|
|
|
|
|
|
|
env {
|
|
|
|
COUNTING_SERVICE_URL = "http://${NOMAD_UPSTREAM_ADDR_count_api}"
|
|
|
|
}
|
|
|
|
|
|
|
|
config {
|
|
|
|
image = "hashicorpnomad/counter-dashboard:v1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
## `upstreams` Parameters
|
|
|
|
|
2019-09-06 05:52:11 +00:00
|
|
|
- `destination_name` `(string: <required>)` - Name of the upstream service.
|
|
|
|
- `local_bind_port` - `(int: <required>)` - The port the proxy will receive
|
2019-09-05 18:08:31 +00:00
|
|
|
connections for the upstream on.
|
|
|
|
|
2019-09-06 05:52:11 +00:00
|
|
|
The `NOMAD_UPSTREAM_ADDR_<destination_name>` environment variables may be used
|
|
|
|
to interpolate the upstream's `host:port` address.
|
|
|
|
|
|
|
|
Applications are encouraged to connect to `127.0.0.1` and a well defined port
|
|
|
|
(eg 6379 for Redis) by default. Then when using Consul Connect the application
|
|
|
|
can be deployed with the Redis upstream's `local_bind_port = 6379` and require
|
|
|
|
no explicit configuration.
|
2019-09-05 18:08:31 +00:00
|
|
|
|
|
|
|
## `upstreams` Examples
|
|
|
|
|
|
|
|
The following example is an upstream config with the name of the destination service
|
|
|
|
and a local bind port.
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
upstreams {
|
|
|
|
destination_name = "count-api"
|
|
|
|
local_bind_port = 8080
|
|
|
|
}
|
2020-02-06 23:45:31 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
[job]: /docs/job-specification/job 'Nomad job Job Specification'
|
|
|
|
[group]: /docs/job-specification/group 'Nomad group Job Specification'
|
|
|
|
[task]: /docs/job-specification/task 'Nomad task Job Specification'
|
|
|
|
[interpolation]: /docs/runtime/interpolation 'Nomad interpolation'
|
|
|
|
[sidecar_service]: /docs/job-specification/sidecar_service 'Nomad sidecar service Specification'
|
|
|
|
[upstreams]: /docs/job-specification/upstreams 'Nomad upstream config Specification'
|