Skip to content

Commit

Permalink
docs: add documentation for proxy.expose configuration
Browse files Browse the repository at this point in the history
This changeset adds documentation changes for `proxy.expose` and
the `proxy.expose.path` stanzas in the jobspec.

The examples are centered around proposed changes for the "countdash"
`dashboard-service` in [demo-consul-101](github.com/hashicorp/demo-consul-101/pull/6).
The dashboard service will now serve two additonal endpoints

- `/health/api`
- `/metrics`

which should serve nicely as expose-able paths.
  • Loading branch information
shoenig committed Mar 23, 2020
1 parent 9da0de2 commit 9233ee6
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 33 deletions.
2 changes: 2 additions & 0 deletions website/data/docs-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,15 @@ export default [
'dispatch_payload',
'env',
'ephemeral_disk',
'expose',
'group',
'job',
'logs',
'meta',
'migrate',
'network',
'parameterized',
'path',
'periodic',
'proxy',
'reschedule',
Expand Down
99 changes: 99 additions & 0 deletions website/pages/docs/job-specification/expose.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
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 configuring options for the default Envoy sidecar
proxy managed by Nomad for [Consul Connect](/guides/integrations/consul-connect).
It is valid only within the context of a `proxy` stanza. Detailed 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)

```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 {
checks = true
}
}
}
}
}
}
}
```

## `expose` Parameters

- `checks` `(bool: false)` - Automatically generate expose path configuration for
HTTP and gRPC type checks defined for the service. Other types of checks are
not supported by the expose stanza.
- `path` <code>([Path]: nil)</code> - A list of [Envoy Expose Path Configurations](/docs/job-specification/path)
to expose through Envoy.

## `expose` Examples

The following example is an expose configuration that is configured to automatically
expose compatible service checks, as well as a custom path for a `/metrics` endpoint.

```hcl
service {
name = "count-dashboard"
port = "9001"
connect {
sidecar_service {
proxy {
expose {
checks = true
path {
path = "/metrics"
protocol = "http"
local_path_port = 9001
listener_port = "expose"
}
}
}
}
}
check {
address_mode = "driver"
name = "api-expose-check"
tls_skip_verify = true
type = "http"
port = "expose"
interval = "3s"
timeout = "2s"
method = "GET"
path = "/health/api"
}
}
```

[path]: /docs/job-specification/path 'Nomad expose path Specification'
97 changes: 97 additions & 0 deletions website/pages/docs/job-specification/path.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
layout: docs
page_title: path Stanza - Job Specification
sidebar_title: path
description: |-
The "path" stanza allows specifying a custom Envoy expose path configuration
when using the default Envoy proxy in the Consul Connect integration
---

# `path` Stanza

<Placement
groups={['job', 'group', 'service', 'connect', 'sidecar_service', 'proxy', 'expose', 'path']}
/>

The `path` stanza allows specifying a custom Envoy expose path configuration when
using the default Envoy sidecar proxy managed by Nomad for [Consul Connect](/guides/integrations/consul-connect).
It is valid only within the context of an `expose` stanza. Detailed 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)

```hcl
job "expose-path-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 = "/health/api"
protocol = "http"
local_path_port = 9001
listener_port = "expose"
}
}
}
}
}
}
}
}
```

### `path` Parameters

- `path` `(string: required)` - The HTTP path to expose. The path must be prefixed
with a slash (e.g. `/health`).
- `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.
- `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 the task's network namespace.

## `path` Examples

The following example is an expose configuration that manually exposes three
endpoints of the Connect enabled service.

```hcl
proxy {
expose {
path {
path = "/health/api"
protocol = "http"
local_path_port = 9001
listener_port = "expose"
}
path {
path = "/metrics"
protocol = "http"
local_path_port = 9001
listener_port = "expose"
}
path {
path = "/v2/health"
protocol = "http2"
local_path_port = 9002
listener_port = "expose"
}
}
}
```

[port]: /docs/job-specification/network#port-parameters 'Nomad Port Parameters'
70 changes: 37 additions & 33 deletions website/pages/docs/job-specification/proxy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,46 @@ Connect](/guides/integrations/consul-connect). It is valid only
within the context of a `sidecar_service` stanza.

```hcl
job "countdash" {
datacenters = ["dc1"]
group "api" {
network {
mode = "bridge"
}
job "countdash" {
datacenters = ["dc1"]
group "api" {
network {
mode = "bridge"
}
service {
name = "count-api"
port = "9001"
connect {
sidecar_service {}
}
}
task "web" {
driver = "docker"
config {
image = "test/test:v1"
}
}
}
}
service {
name = "count-api"
port = "9001"
connect {
sidecar_service {
proxy {}
}
}
}
task "web" {
driver = "docker"
config {
image = "test/test:v1"
}
}
}
}
```

## `proxy` Parameters

- `local_service_address` `(string: "127.0.0.1")` - The address the local service binds to. Useful to
customize in clusters with mixed Connect and non-Connect services.
- `local_service_port` <code>(int:[port][])</code> - The port the local service binds to.
- `local_service_port` `(int:[port][])` - The port the local service binds to.
Usually the same as the parent service's port, it is useful to customize in clusters with mixed
Connect and non-Connect services
- `upstreams` <code>([upstreams][]: nil)</code> - Used to configure details of each upstream service that
this sidecar proxy communicates with.
- `config` <code>(map: nil)</code> - Proxy configuration that's opaque to Nomad and
- `expose` <code>([expose]: nil)</code> - Used to configure expose path configuration for Envoy.
See Consul's [Expose Paths Configuration Reference](https://www.consul.io/docs/connect/registration/service-registration.html#expose-paths-configuration-reference)
for more information.
- `config` `(map: nil)` - Proxy configuration that's opaque to Nomad and
passed directly to Consul. See [Consul Connect's
documentation](https://www.consul.io/docs/connect/proxies/envoy#dynamic-configuration)
for details.
Expand All @@ -64,15 +68,14 @@ within the context of a `sidecar_service` stanza.
The following example is a proxy specification that includes upstreams configuration.

```hcl
sidecar_service {
proxy {
upstreams {
destination_name = "count-api"
local_bind_port = 8080
}
}
}
sidecar_service {
proxy {
upstreams {
destination_name = "count-api"
local_bind_port = 8080
}
}
}
```

[job]: /docs/job-specification/job 'Nomad job Job Specification'
Expand All @@ -82,3 +85,4 @@ The following example is a proxy specification that includes upstreams configura
[sidecar_service]: /docs/job-specification/sidecar_service 'Nomad sidecar service Specification'
[upstreams]: /docs/job-specification/upstreams 'Nomad upstream config Specification'
[port]: /docs/job-specification/network#port-parameters 'Nomad network port configuration'
[expose]: /docs/job-specification/expose 'Nomad proxy expose configuration'

0 comments on commit 9233ee6

Please sign in to comment.