github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/website/content/docs/job-specification/upstreams.mdx (about) 1 --- 2 layout: docs 3 page_title: upstreams Stanza - Job Specification 4 sidebar_title: upstreams 5 description: |- 6 The "upstreams" stanza allows specifying options for configuring 7 upstream services 8 --- 9 10 # `upstreams` Stanza 11 12 <Placement 13 groups={[ 14 'job', 15 'group', 16 'service', 17 'connect', 18 'sidecar_service', 19 'proxy', 20 'upstreams', 21 ]} 22 /> 23 24 The `upstreams` stanza allows configuring various options for managing upstream 25 services that a [Consul 26 Connect](/docs/integrations/consul-connect) proxy routes to. It 27 is valid only within the context of a `proxy` stanza. 28 29 For Consul-specific details see the [Consul Connect 30 Guide](https://learn.hashicorp.com/consul/getting-started/connect#register-a-dependent-service-and-proxy). 31 32 ```hcl 33 job "countdash" { 34 datacenters = ["dc1"] 35 36 group "dashboard" { 37 network { 38 mode = "bridge" 39 40 port "http" { 41 static = 9002 42 to = 9002 43 } 44 } 45 46 service { 47 name = "count-dashboard" 48 port = "9002" 49 50 connect { 51 sidecar_service { 52 proxy { 53 upstreams { 54 destination_name = "count-api" 55 local_bind_port = 8080 56 datacenter = "dc1" 57 local_bind_address = "127.0.0.1" 58 } 59 } 60 } 61 } 62 } 63 64 task "dashboard" { 65 driver = "docker" 66 67 env { 68 COUNTING_SERVICE_URL = "http://${NOMAD_UPSTREAM_ADDR_count_api}" 69 } 70 71 config { 72 image = "hashicorpnomad/counter-dashboard:v3" 73 } 74 } 75 } 76 } 77 78 ``` 79 80 ## `upstreams` Parameters 81 82 - `destination_name` `(string: <required>)` - Name of the upstream service. 83 - `local_bind_port` - `(int: <required>)` - The port the proxy will receive 84 connections for the upstream on. 85 - `datacenter` `(string: "")` - The Consul datacenter in which to issue the 86 discovery query. Defaults to the empty string, which Consul interprets as the 87 local Consul datacenter. 88 - `local_bind_address` - `(string: "")` - The address the proxy will receive 89 connections for the upstream on. 90 91 The `NOMAD_UPSTREAM_ADDR_<destination_name>` environment variables may be used 92 to interpolate the upstream's `host:port` address. 93 94 Applications are encouraged to connect to `127.0.0.1` and a well defined port 95 (eg 6379 for Redis) by default. Then when using Consul Connect the application 96 can be deployed with the Redis upstream's `local_bind_port = 6379` and require 97 no explicit configuration. 98 99 ## `upstreams` Examples 100 101 The following example is an upstream config with the name of the destination service 102 and a local bind port. 103 104 ```hcl 105 upstreams { 106 destination_name = "count-api" 107 local_bind_port = 8080 108 } 109 ``` 110 111 [job]: /docs/job-specification/job 'Nomad job Job Specification' 112 [group]: /docs/job-specification/group 'Nomad group Job Specification' 113 [task]: /docs/job-specification/task 'Nomad task Job Specification' 114 [interpolation]: /docs/runtime/interpolation 'Nomad interpolation' 115 [sidecar_service]: /docs/job-specification/sidecar_service 'Nomad sidecar service Specification' 116 [upstreams]: /docs/job-specification/upstreams 'Nomad upstream config Specification'