-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7440 from hashicorp/docs-connect-expose
docs: add documentation for proxy.expose configuration
- Loading branch information
Showing
4 changed files
with
211 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
--- | ||
layout: docs | ||
page_title: expose Stanza - Job Specification | ||
sidebar_title: expose | ||
description: |- | ||
The "expose" stanza allows specifying options for configuring Envoy expose | ||
paths used in Consul Connect integration | ||
--- | ||
|
||
# `expose` Stanza | ||
|
||
<Placement | ||
groups={['job', 'group', 'service', 'connect', 'sidecar_service', 'proxy', 'expose']} | ||
/> | ||
|
||
The `expose` stanza allows configuration of additional listeners for the default Envoy sidecar | ||
proxy managed by Nomad for [Consul Connect](/guides/integrations/consul-connect). These | ||
listeners create a bypass of the Connect TLS and network namespace isolation, enabling | ||
non-Connect enabled services to make requests to specific paths through the sidecar proxy. | ||
|
||
The `expose` configuration is valid within the context of a `proxy` stanza. Additional | ||
information about Expose Path configurations for Envoy can be found in Consul's | ||
[Expose Paths Configuration Reference](https://www.consul.io/docs/connect/registration/service-registration.html#expose-paths-configuration-reference). | ||
|
||
Service [check](https://nomadproject.io/docs/job-specification/service/#check-parameters) | ||
configurations can use their [expose](/docs/job-specification/service#expose) | ||
parameter to automatically generate expose path configurations for HTTP and gRPC checks. | ||
|
||
```hcl | ||
job "expose-example" { | ||
datacenters = ["dc1"] | ||
group "dashboard" { | ||
network { | ||
mode = "bridge" | ||
port "expose" { | ||
to = -1 | ||
} | ||
} | ||
service { | ||
name = "count-dashboard" | ||
port = "9001" | ||
connect { | ||
sidecar_service { | ||
proxy { | ||
expose { | ||
path { | ||
path = "/metrics" | ||
protocol = "http" | ||
local_path_port = 9001 | ||
listener_port = "expose" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
check { | ||
name = "dashboard-health" | ||
type = "http" | ||
port = "expose" | ||
path = "/health" | ||
interval = "10s" | ||
timeout = "3s" | ||
expose = true | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## `expose` Parameters | ||
|
||
- `path` <code>([Path]: nil)</code> - A list of [Envoy Expose Path Configurations](/docs/job-specification/path) | ||
to expose through Envoy. | ||
|
||
### `path` Parameters | ||
|
||
- `path` `(string: required)` - The HTTP or gRPC path to expose. The path must be prefixed | ||
with a slash. | ||
- `protocol` `(string: required)` - Sets the protocol of the listener. Must be | ||
`http` or `http2`. For gRPC use `http2`. | ||
- `local_path_port` `(int: required)` - The port the service is listening to for connections to | ||
the configured `path`. Typically this will be the same as the `service.port` value, but | ||
could be different if for example the exposed path is intended to resolve to another task | ||
in the task group. | ||
- `listener_port` <code>([Port]: required)</code> - The name of the port to use | ||
for the exposed listener. The port should be configured to [map inside](/docs/job-specification/network#to) | ||
the task's network namespace. | ||
|
||
|
||
## `expose` Examples | ||
|
||
The following example is configured to expose the `/metrics` endpoint of the Connect-enabled | ||
`count-dashboard` service, using the `HTTP` protocol. `count-dashboard` is expected | ||
to listen inside its namespace to port `9001`, and external services will be able to | ||
reach its `/metrics` endpoint by connecting to the [network interface](https://nomadproject.io/docs/configuration/client/#network_interface) | ||
of the node on the allocated `metrics` [Port](/docs/job-specification/network#port-parameters). | ||
|
||
```hcl | ||
service { | ||
name = "count-dashboard" | ||
port = "9001" | ||
connect { | ||
sidecar_service { | ||
proxy { | ||
expose { | ||
path { | ||
path = "/metrics" | ||
protocol = "http" | ||
local_path_port = 9001 | ||
listener_port = "metrics" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## `path` Examples | ||
|
||
The following example is an expose configuration that exposes a `/metrics` endpoint | ||
using the `http2` protocol (typical for gRPC), and an HTTP `/v2/health` endpoint. | ||
|
||
```hcl | ||
proxy { | ||
expose { | ||
path { | ||
path = "/metrics" | ||
protocol = "http2" | ||
local_path_port = 9001 | ||
listener_port = "expose" | ||
} | ||
path { | ||
path = "/v2/health" | ||
protocol = "http" | ||
local_path_port = 9001 | ||
listener_port = "expose" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Exposing Service Checks | ||
|
||
A common use case for `expose` is for exposing endpoints used in Consul service check | ||
definitions. For these cases the [expose](/docs/job-specification/service#expose) | ||
parameter in the service check stanza can be used to automatically generate the | ||
expose path configuration. | ||
|
||
```hcl | ||
check { | ||
type = "http" | ||
name = "dashboard-health" | ||
port = "expose" | ||
path = "/health" | ||
interval = "10s" | ||
timeout = "3s" | ||
expose = true | ||
} | ||
``` | ||
|
||
[path]: /docs/job-specification/expose#path-parameters 'Nomad Expose Path Parameters' | ||
[port]: /docs/job-specification/network#port-parameters 'Nomad Port Parameters' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters