2019-09-05 18:08:31 +00:00
|
|
|
---
|
2020-02-06 23:45:31 +00:00
|
|
|
layout: docs
|
2020-04-07 12:28:30 +00:00
|
|
|
page_title: sidecar_task Stanza - Job Specification
|
2020-02-06 23:45:31 +00:00
|
|
|
sidebar_title: sidecar_task
|
2019-09-05 18:08:31 +00:00
|
|
|
description: |-
|
|
|
|
The "sidecar_task" stanza allows specifying options for configuring
|
|
|
|
the task of the sidecar proxies used in Consul Connect integration
|
|
|
|
---
|
|
|
|
|
|
|
|
# `sidecar_task` Stanza
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
<Placement groups={['job', 'group', 'service', 'connect', 'sidecar_task']} />
|
2019-09-05 18:08:31 +00:00
|
|
|
|
2019-09-06 05:52:11 +00:00
|
|
|
The `sidecar_task` stanza allows configuring various options for the proxy
|
|
|
|
sidecar managed by Nomad for [Consul
|
2020-03-20 21:00:59 +00:00
|
|
|
Connect](/docs/integrations/consul-connect) integration such as
|
2019-09-06 05:52:11 +00:00
|
|
|
resource requirements, kill timeouts and more as defined below. It is valid
|
|
|
|
only within the context of a [`connect`][connect] stanza.
|
2019-09-05 18:08:31 +00:00
|
|
|
|
|
|
|
```hcl
|
2020-05-07 20:16:27 +00:00
|
|
|
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 = "hashicorpnomad/counter-api:v2"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-05 18:08:31 +00:00
|
|
|
```
|
|
|
|
|
2019-09-06 05:52:11 +00:00
|
|
|
## Default Envoy proxy sidecar
|
|
|
|
|
|
|
|
Nomad automatically includes a default Envoy proxy sidecar task whenever a
|
|
|
|
group service has a [`sidecar_service`][sidecar_service] stanza.
|
|
|
|
|
|
|
|
The default sidecar task is equivalent to:
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
sidecar_task {
|
|
|
|
name = "connect-proxy-<service>"
|
|
|
|
|
2020-04-02 01:18:41 +00:00
|
|
|
lifecycle {
|
|
|
|
hook = "prestart"
|
|
|
|
sidecar = true
|
|
|
|
}
|
|
|
|
|
2019-09-06 05:52:11 +00:00
|
|
|
driver = "docker"
|
|
|
|
config {
|
2019-10-03 00:58:10 +00:00
|
|
|
image = "${meta.connect.sidecar_image}"
|
2019-09-06 05:52:11 +00:00
|
|
|
args = [
|
|
|
|
"-c",
|
|
|
|
"${NOMAD_SECRETS_DIR}/envoy_bootstrap.json",
|
|
|
|
"-l",
|
|
|
|
"${meta.connect.log_level}"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
logs {
|
|
|
|
max_files = 2
|
|
|
|
max_file_size = 2 # MB
|
|
|
|
}
|
|
|
|
|
|
|
|
resources {
|
|
|
|
cpu = 250 # MHz
|
|
|
|
memory = 128 # MB
|
|
|
|
}
|
|
|
|
|
|
|
|
shutdown_delay = "5s"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
The `meta.connect.sidecar_image` and `meta.connect.log_level` are [_client_
|
2019-09-06 05:52:11 +00:00
|
|
|
configurable][nodemeta] variables with the following defaults:
|
|
|
|
|
2019-10-17 22:32:38 +00:00
|
|
|
- `sidecar_image` - `"envoyproxy/envoy:v1.11.2@sha256:a7769160c9c1a55bb8d07a3b71ce5d64f72b1f665f10d81aa1581bc3cf850d09"` - The official upstream Envoy Docker image.
|
2020-08-05 21:01:03 +00:00
|
|
|
- `log_level` - `"info"` - Envoy sidecar log level. "`debug`" is useful for
|
|
|
|
debugging Connect related issues.
|
2019-09-06 05:52:11 +00:00
|
|
|
|
2019-09-05 18:08:31 +00:00
|
|
|
## `sidecar_task` Parameters
|
2020-02-06 23:45:31 +00:00
|
|
|
|
2019-09-06 05:52:11 +00:00
|
|
|
- `name` `(string: "connect-proxy-<service>")` - Name of the task. Defaults to
|
|
|
|
including the name of the service it is a proxy for.
|
2019-09-05 18:08:31 +00:00
|
|
|
|
2019-09-06 05:52:11 +00:00
|
|
|
- `driver` `(string: "docker")` - Driver used for the sidecar task.
|
2019-09-05 18:08:31 +00:00
|
|
|
|
2019-09-06 05:52:11 +00:00
|
|
|
- `user` `(string: nil)` - Determines which user is used to run the task, defaults
|
2020-02-06 23:45:31 +00:00
|
|
|
to the same user the Nomad client is being run as.
|
2019-09-05 18:08:31 +00:00
|
|
|
|
2019-09-06 05:52:11 +00:00
|
|
|
- `config` `(map: nil)` - Configuration provided to the driver for initialization.
|
2019-09-05 18:08:31 +00:00
|
|
|
|
2019-09-06 05:52:11 +00:00
|
|
|
- `env` `(map: nil)` - Map of environment variables used by the driver.
|
2019-09-05 18:08:31 +00:00
|
|
|
|
2019-09-06 05:52:11 +00:00
|
|
|
- `resources` <code>([Resources][resources])</code> - Resources needed by the sidecar task.
|
2019-09-05 18:08:31 +00:00
|
|
|
|
2019-09-06 05:52:11 +00:00
|
|
|
- `meta` `(map: nil)` - Arbitrary metadata associated with this task that's opaque to Nomad.
|
2019-09-05 18:08:31 +00:00
|
|
|
|
|
|
|
- `logs` <code>([Logs][]: nil)</code> - Specifies logging configuration for the
|
|
|
|
`stdout` and `stderr` of the task.
|
|
|
|
|
2019-09-06 05:52:11 +00:00
|
|
|
- `kill_timeout` `(string: "5s")` - Time between signalling a task that will be
|
|
|
|
killed and killing it.
|
2019-09-05 18:08:31 +00:00
|
|
|
|
2019-09-06 05:52:11 +00:00
|
|
|
- `shutdown_delay` `(string: "5s")` - Delay between deregistering the task from
|
|
|
|
Consul and sending it a signal to shutdown.
|
2019-09-05 18:08:31 +00:00
|
|
|
|
|
|
|
- `kill_signal` `(string:SIGINT)` - Kill signal to use for the task, defaults to SIGINT.
|
|
|
|
|
|
|
|
## `sidecar_task` Examples
|
2020-02-06 23:45:31 +00:00
|
|
|
|
2019-09-05 18:08:31 +00:00
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
2020-02-06 23:45:31 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
[connect]: /docs/job-specification/connect 'Nomad connect Job Specification'
|
|
|
|
[job]: /docs/job-specification/job 'Nomad job Job Specification'
|
|
|
|
[group]: /docs/job-specification/group 'Nomad group Job Specification'
|
|
|
|
[task]: /docs/job-specification/task 'Nomad task Job Specification'
|
|
|
|
[interpolation]: /docs/runtime/interpolation 'Nomad interpolation'
|
|
|
|
[sidecar_service]: /docs/job-specification/sidecar_service 'Nomad sidecar service Specification'
|
|
|
|
[resources]: /docs/job-specification/resources 'Nomad resources Job Specification'
|
|
|
|
[logs]: /docs/job-specification/logs 'Nomad logs Job Specification'
|
|
|
|
[nodemeta]: /docs/configuration/client#meta
|