github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/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              }
    57            }
    58          }
    59        }
    60      }
    61  
    62      task "dashboard" {
    63        driver = "docker"
    64  
    65        env {
    66          COUNTING_SERVICE_URL = "http://${NOMAD_UPSTREAM_ADDR_count_api}"
    67        }
    68  
    69        config {
    70          image = "hashicorpnomad/counter-dashboard:v1"
    71        }
    72      }
    73    }
    74  }
    75  
    76  ```
    77  
    78  ## `upstreams` Parameters
    79  
    80  - `destination_name` `(string: <required>)` - Name of the upstream service.
    81  - `local_bind_port` - `(int: <required>)` - The port the proxy will receive
    82    connections for the upstream on.
    83  
    84  The `NOMAD_UPSTREAM_ADDR_<destination_name>` environment variables may be used
    85  to interpolate the upstream's `host:port` address.
    86  
    87  Applications are encouraged to connect to `127.0.0.1` and a well defined port
    88  (eg 6379 for Redis) by default. Then when using Consul Connect the application
    89  can be deployed with the Redis upstream's `local_bind_port = 6379` and require
    90  no explicit configuration.
    91  
    92  ## `upstreams` Examples
    93  
    94  The following example is an upstream config with the name of the destination service
    95  and a local bind port.
    96  
    97  ```hcl
    98      upstreams {
    99        destination_name = "count-api"
   100        local_bind_port = 8080
   101      }
   102  ```
   103  
   104  [job]: /docs/job-specification/job 'Nomad job Job Specification'
   105  [group]: /docs/job-specification/group 'Nomad group Job Specification'
   106  [task]: /docs/job-specification/task 'Nomad task Job Specification'
   107  [interpolation]: /docs/runtime/interpolation 'Nomad interpolation'
   108  [sidecar_service]: /docs/job-specification/sidecar_service 'Nomad sidecar service Specification'
   109  [upstreams]: /docs/job-specification/upstreams 'Nomad upstream config Specification'