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