diff --git a/website/source/docs/job-specification/connect.html.md b/website/source/docs/job-specification/connect.html.md new file mode 100644 index 000000000..c7760afc6 --- /dev/null +++ b/website/source/docs/job-specification/connect.html.md @@ -0,0 +1,97 @@ +--- +layout: "docs" +page_title: "connect Stanza - Job Specification" +sidebar_current: "docs-job-specification-connect" +description: |- + The "connect" stanza allows specifying options for Consul Connect integration +--- + +# `connect` Stanza + + + + + + +
Placement + job -> group -> service -> **connect** +
+ +The `connect` stanza allows configuring various options for +[Consul Connect](/guides/integrations/consul-connect/index.html). It is +valid only within the context of a service definition at the task group +level. + +```hcl + 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" + } + } + } + } + +``` + +## `connect` Parameters + +- `native` `(bool: false)` native should be set to true if a service implements Connect directly + and does not need a sidecar. This is not common. + +- `sidecar_service` - ([sidecar_service][]: nil) - This is used to configure the sidecar + service injected by Nomad for Consul Connect. + +- `sidecar_task` - ([sidecar_task][]:nil) - This modifies the configuration of the Envoy + proxy task. + +## `connect` Examples + +The following example is a minimal connect stanza with defaults + +```hcl + connect { + sidecar_service {} + } +``` + +The following example includes specifying upstreams. + +```hcl + connect { + sidecar_service { + proxy { + upstreams { + destination_name = "count-api" + local_bind_port = 8080 + } + } + } + } + ``` + +### Interpolation + +TODO do we need this + +[job]: /docs/job-specification/job.html "Nomad job Job Specification" +[group]: /docs/job-specification/group.html "Nomad group Job Specification" +[task]: /docs/job-specification/task.html "Nomad task Job Specification" +[interpolation]: /docs/runtime/interpolation.html "Nomad interpolation" +[sidecar_service]: /docs/job-specification/sidecar_service.html "Nomad sidecar service Specification" +[sidecar_task]: /docs/job-specification/sidecar_task.html "Nomad sidecar task config Specification" \ No newline at end of file diff --git a/website/source/docs/job-specification/index.html.md b/website/source/docs/job-specification/index.html.md index c9556f4d8..339c0e834 100644 --- a/website/source/docs/job-specification/index.html.md +++ b/website/source/docs/job-specification/index.html.md @@ -129,5 +129,20 @@ job "docs" { } ``` +Note that starting with Nomad 0.10, the `service` stanza can also be specified at the group level. This +allows job specification authors to create and register services with Consul Connect support. A service +stanza specified at the group level must include a [connect][] stanza, like the following snippet. + +```hcl +service { + name = "count-api" + port = "9001" + + connect { + sidecar_service {} + } + } +``` [hcl]: https://github.com/hashicorp/hcl "HashiCorp Configuration Language" [job]: /docs/job-specification/job.html "Nomad job Job Specification" +[connect]: /docs/job-specification/connect.html "Connect Stanza Specification" diff --git a/website/source/docs/job-specification/proxy.html.md b/website/source/docs/job-specification/proxy.html.md new file mode 100644 index 000000000..c5c08a52b --- /dev/null +++ b/website/source/docs/job-specification/proxy.html.md @@ -0,0 +1,80 @@ +--- +layout: "docs" +page_title: "proxy Stanza - Job Specification" +sidebar_current: "docs-job-specification-proxy" +description: |- + The "proxy" stanza allows specifying options for configuring + sidecar proxies used in Consul Connect integration +--- + +# `proxy` Stanza + + + + + + +
Placement + job -> group -> service -> connect -> sidecar_service -> **proxy** +
+ +The `proxy` stanza allows configuring various options for +the sidecar proxy managed by Nomad for Consul Connect integration. +It is valid only within the context of a `sidecar_service` stanza. + +```hcl + 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" + } + } + } + } + +``` + +## `proxy` Parameters + +- `upstreams` ([upstreams][]: nil) Used to configure details of each upstream service that + this sidecar proxy communicates with. +- `config` - (map: nil) - Proxy configuration that's opaque to Nomad and passed directly to Consul. + + +## `proxy` Examples + +The following example is a proxy specification that includes upstreams configuration. + +```hcl + sidecar_service { + proxy { + upstreams { + destination_name = "count-api" + local_bind_port = 8080 + } + } + } + + ``` + +[job]: /docs/job-specification/job.html "Nomad job Job Specification" +[group]: /docs/job-specification/group.html "Nomad group Job Specification" +[task]: /docs/job-specification/task.html "Nomad task Job Specification" +[interpolation]: /docs/runtime/interpolation.html "Nomad interpolation" +[sidecar_service]: /docs/job-specification/sidecar_service.html "Nomad sidecar service Specification" +[upstreams]: /docs/job-specification/upstreams.html "Nomad upstream config Specification" \ No newline at end of file diff --git a/website/source/docs/job-specification/sidecar_service.html.md b/website/source/docs/job-specification/sidecar_service.html.md new file mode 100644 index 000000000..8a5efc372 --- /dev/null +++ b/website/source/docs/job-specification/sidecar_service.html.md @@ -0,0 +1,88 @@ +--- +layout: "docs" +page_title: "sidecar_service Stanza - Job Specification" +sidebar_current: "docs-job-specification-sidecar-service" +description: |- + The "sidecar_service" stanza allows specifying options for configuring + sidecar proxies used in Consul Connect integration +--- + +# `sidecar_service` Stanza + + + + + + +
Placement + job -> group -> service -> connect -> **sidecar_service** +
+ +The `sidecar_service` stanza allows configuring various options for +the sidecar proxy managed by Nomad for Consul Connect integration. +It is valid only within the context of a connect stanza. + +```hcl + 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" + } + } + } + } + +``` + +## `sidecar_service` Parameters + +- `port` `(string: )` Port label for sidecar service. + +- `proxy` - ([proxy][]: nil) - This is used to configure the sidecar proxy service. + + +## `sidecar_service` Examples + +The following example is a minimal `sidecar_service` stanza with defaults + +```hcl + connect { + sidecar_service {} + } +``` + +The following example includes specifying upstreams. + +```hcl + sidecar_service { + proxy { + upstreams { + destination_name = "count-api" + local_bind_port = 8080 + } + } + } + + ``` + +[job]: /docs/job-specification/job.html "Nomad job Job Specification" +[group]: /docs/job-specification/group.html "Nomad group Job Specification" +[task]: /docs/job-specification/task.html "Nomad task Job Specification" +[interpolation]: /docs/runtime/interpolation.html "Nomad interpolation" +[sidecar_service]: /docs/job-specification/sidecar_service.html "Nomad sidecar service Specification" +[proxy]: /docs/job-specification/proxy.html "Nomad sidecar proxy config Specification" \ No newline at end of file diff --git a/website/source/docs/job-specification/sidecar_task.html.md b/website/source/docs/job-specification/sidecar_task.html.md new file mode 100644 index 000000000..0f123bcd1 --- /dev/null +++ b/website/source/docs/job-specification/sidecar_task.html.md @@ -0,0 +1,110 @@ +--- +layout: "docs" +page_title: "sidecar_service Stanza - Job Specification" +sidebar_current: "docs-job-specification-sidecar-task" +description: |- + The "sidecar_task" stanza allows specifying options for configuring + the task of the sidecar proxies used in Consul Connect integration +--- + +# `sidecar_task` Stanza + + + + + + +
Placement + job -> group -> service -> connect -> **sidecar_task** +
+ +The `sidecar_task` stanza allows configuring various options for +the sidecar proxy managed by Nomad for Consul Connect integration. +It is valid only within the context of a connect stanza. + +```hcl + job "countdash" { + datacenters = ["dc1"] + group "api" { + network { + mode = "bridge" + } + + service { + name = "count-api" + port = "9001" + + connect { + sidecar_service {} + sidecar_task { + resources { + cpu = 500 + memory = 1024 + } + } + } + } + task "web" { + driver = "docker" + config { + image = "test/test:v1" + } + } + } + } + +``` + +## `sidecar_task` Parameters +- `name` `(string: )` - Name of the task. + +- `driver` `(string: )` - Driver used for the sidecar task. + +- `user` `(string:nil)` - Determines which user is used to run the task, defaults + to the same user the Nomad client is being run as. + +- `config` `(map:nil )` - Configuration provided to the driver for initialization. + +- `env` `(map:nil )` - Map of environment variables used by the driver. + +- `resources` [resources][] - Resources needed by this task. + +- `meta` `(map:nil )` - Arbitary metadata associated with this task that's opaque to Nomad. + +- `logs` ([Logs][]: nil) - Specifies logging configuration for the + `stdout` and `stderr` of the task. + +- `kill_timeout` `(int:)` - Time between signalling a task that will be killed and killing it. + +- `shutdown_delay` `(int:)` - Delay between deregistering the task from Consul and sendint it a + signal to shutdown. + +- `kill_signal` `(string:SIGINT)` - Kill signal to use for the task, defaults to SIGINT. + + +## `sidecar_task` Examples +The following example configures resources for the sidecar task and other configuration. + +```hcl + sidecar_task { + resources { + cpu = 500 + memory = 1024 + } + + env { + FOO = "abc" + } + + shutdown_delay = "5s" + } + + ``` + +[job]: /docs/job-specification/job.html "Nomad job Job Specification" +[group]: /docs/job-specification/group.html "Nomad group Job Specification" +[task]: /docs/job-specification/task.html "Nomad task Job Specification" +[interpolation]: /docs/runtime/interpolation.html "Nomad interpolation" +[sidecar_service]: /docs/job-specification/sidecar_service.html "Nomad sidecar service Specification" +[resources]: /docs/job-specification/resources.html "Nomad resources Job Specification" +[logs]: /docs/job-specification/logs.html "Nomad logs Job Specification" \ No newline at end of file diff --git a/website/source/docs/job-specification/upstreams.html.md b/website/source/docs/job-specification/upstreams.html.md new file mode 100644 index 000000000..b0ca10ae5 --- /dev/null +++ b/website/source/docs/job-specification/upstreams.html.md @@ -0,0 +1,95 @@ +--- +layout: "docs" +page_title: "upstreams Stanza - Job Specification" +sidebar_current: "docs-job-specification-upstreams" +description: |- + The "upstreams" stanza allows specifying options for configuring + upstream services +--- + +# `upstreams` Stanza + + + + + + +
Placement + job -> group -> service -> connect -> sidecar_service -> proxy -> **upstreams** +
+ +The `upstreams` stanza allows configuring various options for +managing upstream services that the proxy routes to. +It is valid only within the context of a `proxy` stanza. + +```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 + +- `destination_name` `(string: nil)` - Name of the upstream service. +- `local_bind_port` - (int: nil) - The port the proxy will receive + connections for the upstream on. + + +## `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 + } + ``` + +[job]: /docs/job-specification/job.html "Nomad job Job Specification" +[group]: /docs/job-specification/group.html "Nomad group Job Specification" +[task]: /docs/job-specification/task.html "Nomad task Job Specification" +[interpolation]: /docs/runtime/interpolation.html "Nomad interpolation" +[sidecar_service]: /docs/job-specification/sidecar_service.html "Nomad sidecar service Specification" +[upstreams]: /docs/job-specification/upstreams.html "Nomad upstream config Specification" \ No newline at end of file diff --git a/website/source/layouts/docs.erb b/website/source/layouts/docs.erb index 317fa7610..f22617826 100644 --- a/website/source/layouts/docs.erb +++ b/website/source/layouts/docs.erb @@ -371,6 +371,9 @@ > check_restart + > + connect +
  • > constraint
  • @@ -410,6 +413,9 @@ > periodic + > + proxy +
  • > reschedule
  • @@ -422,6 +428,12 @@ > service + > + sidecar_service + + > + sidecar_task + > spread @@ -434,6 +446,9 @@ > update + > + upstreams + > vault