-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Service registration for IPv6 docker addresses (Fixes #3785) #3790
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
795d84e
Service registration for IPv6 docker addresses
42wim dea460b
* Change use_ipv6_address to advertise_ipv6_address.
42wim cdd55e4
Update documentation
42wim d0dd6ef
Add IPv6 support to travis docker
42wim 51bf06f
Add AdvertiseIPv6Address test
42wim e486a27
docker: Skip IPv6 test if IPv6 disabled
schmichael 5ff86f0
Add changelog entry for #3790
schmichael File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,9 +104,6 @@ does not automatically enable service discovery. | |
`address_mode="driver"`. Numeric ports may be used when in driver addressing | ||
mode. | ||
|
||
Docker and IPv6 containers: This setting is required if you want to register | ||
the port of the (IPv6) service. See [below for examples.](#IPv6 docker containers) | ||
|
||
- `tags` `(array<string>: [])` - Specifies the list of tags to associate with | ||
this service. If this is not supplied, no tags will be assigned to the service | ||
when it is registered. | ||
|
@@ -127,10 +124,6 @@ does not automatically enable service discovery. | |
addresses. Task will fail if driver network cannot be determined. Only | ||
implemented for Docker and rkt. | ||
|
||
Docker and IPv6 containers: If you want to register the IPv6 address | ||
of the container you'll have to enable this and specify `use_ipv6_address` | ||
in the docker driver configuration. See [below for examples.](#IPv6 docker containers) | ||
|
||
- `host` - Use the host IP and port. | ||
|
||
### `check` Parameters | ||
|
@@ -147,10 +140,6 @@ scripts. | |
[below for details.](#using-driver-address-mode) Unlike `port`, this setting | ||
is *not* inherited from the `service`. | ||
|
||
Docker and IPv6 containers: If you want to check the IPv6 address | ||
of the container you'll have to enable this and specify `use_ipv6_address` | ||
in the docker driver configuration. See [below for examples.](#IPv6 docker containers) | ||
|
||
- `args` `(array<string>: [])` - Specifies additional arguments to the | ||
`command`. This only applies to script-based health checks. | ||
|
||
|
@@ -197,9 +186,6 @@ scripts. | |
default. In Nomad 0.7.1 or later numeric ports may be used if | ||
`address_mode="driver"` is set on the check. | ||
|
||
Docker and IPv6 containers: Using a numeric port is required if you want to | ||
check the port of (IPv6) service. See [below for examples.](#IPv6 docker containers) | ||
|
||
- `protocol` `(string: "http")` - Specifies the protocol for the http-based | ||
health checks. Valid options are `http` and `https`. | ||
|
||
|
@@ -477,17 +463,21 @@ In this case Nomad doesn't need to assign Redis any host ports. The `service` | |
and `check` stanzas can both specify the port number to advertise and check | ||
directly since Nomad isn't managing any port assignments. | ||
|
||
### IPv6 docker containers | ||
### IPv6 Docker containers | ||
|
||
The [Docker](/docs/drivers/docker.html#advertise_ipv6_address) driver supports the | ||
`advertise_ipv6_address` parameter in it's configuration. | ||
|
||
The [Docker](/docs/drivers/docker.html#use_ipv6_address) driver support the | ||
`use_ipv6_address` parameter in it's configuration. | ||
For the `service`stanza is no explicit `address_mode` required. | ||
Services default to the `auto` address mode. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
Besides enabling this parameter you have to set `address_mode` parameter in | ||
both `service` and `check` stanzas to `driver`. | ||
Unlike services, checks do not have an `auto` address mode as there's no way | ||
for Nomad to know which is the best address to use for checks. Consul needs | ||
access to the address for any HTTP or TCP checks. | ||
|
||
You also have explicily specify the `port` that will be registered and checked. | ||
So you have to set `address_mode` parameter in the `check` stanza to `driver`. | ||
|
||
For example | ||
For example using `auto` address mode: | ||
|
||
```hcl | ||
job "example" { | ||
|
@@ -499,7 +489,51 @@ job "example" { | |
|
||
config { | ||
image = "redis:3.2" | ||
use_ipv6_address = true | ||
advertise_ipv6_address = true | ||
port_map { | ||
db = 6379 | ||
} | ||
} | ||
|
||
resources { | ||
cpu = 500 # 500 MHz | ||
memory = 256 # 256MB | ||
network { | ||
mbits = 10 | ||
port "db" {} | ||
} | ||
} | ||
|
||
service { | ||
name = "ipv6-redis" | ||
port = db | ||
check { | ||
name = "ipv6-redis-check" | ||
type = "tcp" | ||
interval = "10s" | ||
timeout = "2s" | ||
port = db | ||
address_mode = "driver" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Or using `address_mode=driver` for `service` and `check` with numeric ports: | ||
|
||
```hcl | ||
job "example" { | ||
datacenters = ["dc1"] | ||
group "cache" { | ||
|
||
task "redis" { | ||
driver = "docker" | ||
|
||
config { | ||
image = "redis:3.2" | ||
advertise_ipv6_address = true | ||
# No port map required! | ||
} | ||
|
||
|
@@ -529,9 +563,8 @@ job "example" { | |
} | ||
``` | ||
|
||
With IPv6 Nomad doesn't need to assign Redis any host ports. The `service` | ||
and `check` stanzas can both specify the port number to advertise and check | ||
directly since Nomad isn't managing any port assignments. | ||
The `service` and `check` stanzas can both specify the port number to | ||
advertise and check directly since Nomad isn't managing any port assignments. | ||
|
||
|
||
- - - | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, it seems like we probably want to set
auto = true
here as well. While this complicates the already unfortunately confusingadvertise = "auto"
logic, I think it will do what users expect by automatically advertising the routable address for the container when it's possible to discover it.Perhaps a better question is: It should be exceedingly rare that someone wants
use_ipv6_address = true
andadvertise = "host"
, correct?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this has been addressed; leaving for historical purposes)