github.com/zhizhiboom/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/website/source/docs/configuration/server_join.html.md (about)

     1  ---
     2  layout: "docs"
     3  page_title: "server_join Stanza - Agent Configuration"
     4  sidebar_current: "docs-configuration--server-join"
     5  description: |-
     6    The "server_join" stanza specifies how the Nomad agent will discover and connect to Nomad servers.
     7  ---
     8  
     9  # `server_join` Stanza
    10  
    11  <table class="table table-bordered table-striped">
    12    <tr>
    13      <th width="120">Placement</th>
    14      <td>
    15        <code>server -> **server_join**</code>
    16        <br>
    17        <code>client -> **server_join**</code>
    18      </td>
    19    </tr>
    20  </table>
    21  
    22  The `server_join` stanza specifies how the Nomad agent will discover and connect
    23  to Nomad servers.
    24  
    25  ```hcl
    26  server_join {
    27    retry_join = [ "1.1.1.1", "2.2.2.2" ]
    28    retry_max = 3
    29    retry_interval = "15s"
    30  }
    31  ```
    32  
    33  ## `server_join` Parameters
    34  
    35  -   `retry_join` `(array<string>: [])` - Specifies a list of server addresses to
    36    join. This is similar to [`start_join`](#start_join), but will continue to
    37    be attempted even if the initial join attempt fails, up to
    38    [retry_max](#retry_max). Further, `retry_join` is available to
    39    both Nomad servers and clients, while `start_join` is only defined for Nomad
    40    servers.  This is useful for cases where we know the address will become
    41    available eventually.  Use `retry_join` with an array as a replacement for
    42    `start_join`, **do not use both options**.
    43  
    44      Address format includes both using IP addresses as well as an interface to the
    45    [go-discover](https://github.com/hashicorp/go-discover) library for doing
    46    automated cluster joining using cloud metadata. See the [Cloud Auto-join](#cloud-auto-join) 
    47    section below for more information.
    48  
    49      ```
    50    server_join {
    51      retry_join = [ "1.1.1.1", "2.2.2.2" ]
    52    }
    53    ```
    54  
    55      Using the `go-discover` interface, this can be defined both in a client or
    56    server configuration as well as provided as a command-line argument.
    57  
    58      ```
    59    server_join {
    60      retry_join = [ "provider=aws tag_key=..." ]
    61    }
    62    ```
    63  
    64      See the [server address format](#server-address-format) for more information
    65    about expected server address formats.
    66  
    67  - `retry_interval` `(string: "30s")` - Specifies the time to wait between retry
    68    join attempts.
    69  
    70  - `retry_max` `(int: 0)` - Specifies the maximum number of join attempts to be
    71    made before exiting with a return code of 1. By default, this is set to 0
    72    which is interpreted as infinite retries.
    73  
    74  - `start_join` `(array<string>: [])` - Specifies a list of server addresses to
    75    join on startup. If Nomad is unable to join with any of the specified
    76    addresses, agent startup will fail. See the
    77    [server address format](#server-address-format) section for more information
    78    on the format of the string. This field is defined only for Nomad servers and
    79    will result in a configuration parse error if included in a client
    80    configuration.
    81  
    82  ## Server Address Format
    83  
    84  This section describes the acceptable syntax and format for describing the
    85  location of a Nomad server. There are many ways to reference a Nomad server,
    86  including directly by IP address and resolving through DNS.
    87  
    88  ### Directly via IP Address
    89  
    90  It is possible to address another Nomad server using its IP address. This is
    91  done in the `ip:port` format, such as:
    92  
    93  ```
    94  1.2.3.4:5678
    95  ```
    96  
    97  If the port option is omitted, it defaults to the Serf port, which is 4648
    98  unless configured otherwise:
    99  
   100  ```
   101  1.2.3.4 => 1.2.3.4:4648
   102  ```
   103  
   104  ### Via Domains or DNS
   105  
   106  It is possible to address another Nomad server using its DNS address. This is
   107  done in the `address:port` format, such as:
   108  
   109  ```
   110  nomad-01.company.local:5678
   111  ```
   112  
   113  If the port option is omitted, it defaults to the Serf port, which is 4648
   114  unless configured otherwise:
   115  
   116  ```
   117  nomad-01.company.local => nomad-01.company.local:4648
   118  ```
   119  
   120  ### Via the go-discover interface
   121  
   122  As of Nomad 0.8.4, `retry_join` accepts a unified interface using the
   123  [go-discover](https://github.com/hashicorp/go-discover) library for doing
   124  automated cluster joining using cloud metadata. See [Cloud
   125  Auto-join][cloud_auto_join] for more information.
   126  
   127  ```
   128  "provider=aws tag_key=..." => 1.2.3.4:4648
   129  ```
   130  
   131  ## Cloud Auto-join
   132  
   133  The following sections describe the Cloud Auto-join `retry_join` options that are specific 
   134  to a subset of supported cloud providers. For information on all providers, see further 
   135  documentation in [go-discover](https://github.com/hashicorp/go-discover).
   136  
   137  ### Amazon EC2
   138  
   139  This returns the first private IP address of all servers in the given
   140  region which have the given `tag_key` and `tag_value`.
   141  
   142  
   143  ```json
   144  {
   145    "retry_join": ["provider=aws tag_key=... tag_value=..."]
   146  }
   147  ```
   148  
   149  - `provider` (required) - the name of the provider ("aws" in this case).
   150  - `tag_key` (required) - the key of the tag to auto-join on.
   151  - `tag_value` (required) - the value of the tag to auto-join on.
   152  - `region` (optional) - the AWS region to authenticate in.
   153  - `addr_type` (optional) - the type of address to discover: `private_v4`, `public_v4`, `public_v6`. Default is `private_v4`. (>= 1.0)
   154  - `access_key_id` (optional) - the AWS access key for authentication (see below for more information about authenticating).
   155  - `secret_access_key` (optional) - the AWS secret access key for authentication (see below for more information about authenticating).
   156  
   157  #### Authentication &amp; Precedence
   158  
   159  - Static credentials `access_key_id=... secret_access_key=...`
   160  - Environment variables (`AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`)
   161  - Shared credentials file (`~/.aws/credentials` or the path specified by `AWS_SHARED_CREDENTIALS_FILE`)
   162  - ECS task role metadata (container-specific).
   163  - EC2 instance role metadata.
   164  
   165    The only required IAM permission is `ec2:DescribeInstances`, and it is
   166    recommended that you make a dedicated key used only for auto-joining. If the
   167    region is omitted it will be discovered through the local instance's [EC2
   168    metadata
   169    endpoint](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-identity-documents.html).
   170  
   171  ### Microsoft Azure
   172  
   173    This returns the first private IP address of all servers in the given region
   174    which have the given `tag_key` and `tag_value` in the tenant and subscription, or in
   175    the given `resource_group` of a `vm_scale_set` for Virtual Machine Scale Sets.
   176  
   177  
   178    ```json
   179  {
   180    "retry_join": ["provider=azure tag_name=... tag_value=... tenant_id=... client_id=... subscription_id=... secret_access_key=..."]
   181  }
   182  ```
   183  
   184  - `provider` (required) - the name of the provider ("azure" in this case).
   185  - `tenant_id` (required) - the tenant to join machines in.
   186  - `client_id` (required) - the client to authenticate with.
   187  - `secret_access_key` (required) - the secret client key.
   188  
   189  Use these configuration parameters when using tags:
   190  - `tag_name` - the name of the tag to auto-join on.
   191  - `tag_value` - the value of the tag to auto-join on.
   192  
   193  Use these configuration parameters when using Virtual Machine Scale Sets (Consul 1.0.3 and later):
   194  - `resource_group` - the name of the resource group to filter on.
   195  - `vm_scale_set` - the name of the virtual machine scale set to filter on.
   196  
   197      When using tags the only permission needed is the `ListAll` method for `NetworkInterfaces`. When using
   198      Virtual Machine Scale Sets the only role action needed is `Microsoft.Compute/virtualMachineScaleSets/*/read`.
   199  
   200  ### Google Compute Engine
   201  
   202  This returns the first private IP address of all servers in the given
   203  project which have the given `tag_value`.
   204  ```
   205  
   206  ```json
   207  {
   208  "retry_join": ["provider=gce project_name=... tag_value=..."]
   209  }
   210  ```
   211  
   212  - `provider` (required) - the name of the provider ("gce" in this case).
   213  - `tag_value` (required) - the value of the tag to auto-join on.
   214  - `project_name` (optional) - the name of the project to auto-join on. Discovered if not set.
   215  - `zone_pattern` (optional) - the list of zones can be restricted through an RE2 compatible regular expression. If omitted, servers in all zones are returned.
   216  - `credentials_file` (optional) - the credentials file for authentication. See below for more information.
   217  
   218  #### Authentication &amp; Precedence
   219  
   220  - Use credentials from `credentials_file`, if provided.
   221  - Use JSON file from `GOOGLE_APPLICATION_CREDENTIALS` environment variable.
   222  - Use JSON file in a location known to the gcloud command-line tool.
   223  - On Windows, this is `%APPDATA%/gcloud/application_default_credentials.json`.
   224  - On other systems, `$HOME/.config/gcloud/application_default_credentials.json`.
   225  - On Google Compute Engine, use credentials from the metadata
   226  server. In this final case any provided scopes are ignored.
   227  
   228  Discovery requires a [GCE Service
   229  Account](https://cloud.google.com/compute/docs/access/service-accounts).
   230  Credentials are searched using the following paths, in order of precedence.
   231