github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/docs/job-specification/sidecar_task.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: sidecar_task Stanza - Job Specification
     4  sidebar_title: sidecar_task
     5  description: |-
     6    The "sidecar_task" stanza allows specifying options for configuring
     7    the task of the sidecar proxies used in Consul Connect integration
     8  ---
     9  
    10  # `sidecar_task` Stanza
    11  
    12  <Placement groups={['job', 'group', 'service', 'connect', 'sidecar_task']} />
    13  
    14  The `sidecar_task` stanza allows configuring various options for the proxy
    15  sidecar managed by Nomad for [Consul
    16  Connect](/docs/integrations/consul-connect) integration such as
    17  resource requirements, kill timeouts and more as defined below. It is valid
    18  only within the context of a [`connect`][connect] stanza.
    19  
    20  ```hcl
    21  job "countdash" {
    22    datacenters = ["dc1"]
    23  
    24    group "api" {
    25      network {
    26        mode = "bridge"
    27      }
    28  
    29      service {
    30        name = "count-api"
    31        port = "9001"
    32  
    33        connect {
    34          sidecar_service = {}
    35  
    36          sidecar_task {
    37            resources {
    38              cpu    = 500
    39              memory = 1024
    40            }
    41          }
    42        }
    43      }
    44  
    45      task "web" {
    46        driver = "docker"
    47  
    48        config {
    49          image = "hashicorpnomad/counter-api:v2"
    50        }
    51      }
    52    }
    53  }
    54  ```
    55  
    56  ## Default Envoy proxy sidecar
    57  
    58  Nomad automatically includes a default Envoy proxy sidecar task whenever a
    59  group service has a [`sidecar_service`][sidecar_service] stanza.
    60  
    61  The default sidecar task is equivalent to:
    62  
    63  ```hcl
    64     sidecar_task {
    65       name   = "connect-proxy-<service>"
    66  
    67       lifecycle {
    68         hook = "prestart"
    69         sidecar = true
    70       }
    71  
    72       driver = "docker"
    73       config {
    74         image = "${meta.connect.sidecar_image}"
    75         args  = [
    76           "-c",
    77           "${NOMAD_SECRETS_DIR}/envoy_bootstrap.json",
    78           "-l",
    79           "${meta.connect.log_level}"
    80         ]
    81       }
    82  
    83       logs {
    84         max_files     = 2
    85         max_file_size = 2 # MB
    86       }
    87  
    88       resources {
    89         cpu    = 250 # MHz
    90         memory = 128 # MB
    91       }
    92  
    93       shutdown_delay = "5s"
    94     }
    95  ```
    96  
    97  The `meta.connect.sidecar_image` and `meta.connect.log_level` are [_client_
    98  configurable][nodemeta] variables with the following defaults:
    99  
   100  - `sidecar_image` - `"envoyproxy/envoy:v1.11.2@sha256:a7769160c9c1a55bb8d07a3b71ce5d64f72b1f665f10d81aa1581bc3cf850d09"` - The official upstream Envoy Docker image.
   101  - `sidecar_log_level` - `"info"` - Envoy sidecar log level. "`debug`" is useful
   102    for debugging Connect related issues.
   103  
   104  ## `sidecar_task` Parameters
   105  
   106  - `name` `(string: "connect-proxy-<service>")` - Name of the task. Defaults to
   107    including the name of the service it is a proxy for.
   108  
   109  - `driver` `(string: "docker")` - Driver used for the sidecar task.
   110  
   111  - `user` `(string: nil)` - Determines which user is used to run the task, defaults
   112    to the same user the Nomad client is being run as.
   113  
   114  - `config` `(map: nil)` - Configuration provided to the driver for initialization.
   115  
   116  - `env` `(map: nil)` - Map of environment variables used by the driver.
   117  
   118  - `resources` <code>([Resources][resources])</code> - Resources needed by the sidecar task.
   119  
   120  - `meta` `(map: nil)` - Arbitrary metadata associated with this task that's opaque to Nomad.
   121  
   122  - `logs` <code>([Logs][]: nil)</code> - Specifies logging configuration for the
   123    `stdout` and `stderr` of the task.
   124  
   125  - `kill_timeout` `(string: "5s")` - Time between signalling a task that will be
   126    killed and killing it.
   127  
   128  - `shutdown_delay` `(string: "5s")` - Delay between deregistering the task from
   129    Consul and sending it a signal to shutdown.
   130  
   131  - `kill_signal` `(string:SIGINT)` - Kill signal to use for the task, defaults to SIGINT.
   132  
   133  ## `sidecar_task` Examples
   134  
   135  The following example configures resources for the sidecar task and other configuration.
   136  
   137  ```hcl
   138     sidecar_task {
   139       resources {
   140         cpu = 500
   141         memory = 1024
   142       }
   143  
   144       env {
   145         FOO = "abc"
   146       }
   147  
   148       shutdown_delay = "5s"
   149     }
   150  
   151  ```
   152  
   153  [connect]: /docs/job-specification/connect 'Nomad connect Job Specification'
   154  [job]: /docs/job-specification/job 'Nomad job Job Specification'
   155  [group]: /docs/job-specification/group 'Nomad group Job Specification'
   156  [task]: /docs/job-specification/task 'Nomad task Job Specification'
   157  [interpolation]: /docs/runtime/interpolation 'Nomad interpolation'
   158  [sidecar_service]: /docs/job-specification/sidecar_service 'Nomad sidecar service Specification'
   159  [resources]: /docs/job-specification/resources 'Nomad resources Job Specification'
   160  [logs]: /docs/job-specification/logs 'Nomad logs Job Specification'
   161  [nodemeta]: /docs/configuration/client#meta