Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ea04c0f
Resolve #23 by adding CONSUL_DATACENTER_NAME env
tjcelaya Dec 7, 2017
cc21275
Mention the environment variable in the README
tjcelaya Dec 8, 2017
189414c
Resolves #47 by adding CONSUL_RETRY_JOIN_WAN
tjcelaya Dec 8, 2017
23c8c60
Remove debugging output
tjcelaya Dec 8, 2017
abad90e
Fix the environment value now that we've collected the error message
tjcelaya Dec 8, 2017
b15de52
Environment variable documentation and moving examples.
tjcelaya Dec 11, 2017
ee400d6
Triton datacenter autodetection
tjcelaya Dec 11, 2017
5c4c2d4
README update for envs
tjcelaya Dec 11, 2017
33ceafc
Merge updates to #46
tjcelaya Dec 11, 2017
32ed8fc
more things
tjcelaya Dec 13, 2017
5bec8ff
it was bind_addr all along
tjcelaya Dec 13, 2017
25de3dd
Always set the alternate addresses for now, might move all of these b…
tjcelaya Dec 13, 2017
0c3db58
Fix the CONSUL_BIND_ADDR check
tjcelaya Dec 14, 2017
b44294b
Add self-anti-affinity
tjcelaya Dec 14, 2017
3ebb138
Fix silly config error
tjcelaya Dec 15, 2017
24ae977
Move env vars section
tjcelaya Dec 15, 2017
2f2893d
Resolve merge conflicts
tjcelaya Dec 18, 2017
ac0d6e2
Split up triton from multi-dc triton examples
tjcelaya Dec 19, 2017
a84a860
Remove fake multi-dc docker-compose example
tjcelaya Dec 19, 2017
667f0e2
Fix test Dockerfile paths
tjcelaya Dec 19, 2017
5ab7825
Fix multi-dc clean target
tjcelaya Dec 19, 2017
efb1e9b
Fix template name
tjcelaya Dec 19, 2017
ff95e50
Try a new multi-dc layout
tjcelaya Dec 19, 2017
db96dd7
Separate the triton and triton-multi-dc setup scripts
tjcelaya Dec 19, 2017
eb360fc
make the check function easier to use
tjcelaya Dec 19, 2017
3c6f336
Fix account id query command
tjcelaya Dec 19, 2017
8b27a61
Path and script name change in README
tjcelaya Dec 19, 2017
06bc9ea
Clarify README
tjcelaya Dec 19, 2017
6759213
Fix duplicate env vars from merge conflict resolution
tjcelaya Dec 20, 2017
9ea5646
Fix usage output description
tjcelaya Dec 20, 2017
ecc75ed
Fix description again
tjcelaya Dec 21, 2017
658d4e7
Remove the build key from examples/compose/docker-compose.yml
tjcelaya Dec 21, 2017
4cf52d9
Revert ./setup.sh change
tjcelaya Dec 21, 2017
dc5018f
Typo
tjcelaya Dec 21, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ services:

In our experience, including a Consul cluster within a project's `docker-compose.yml` can help developers understand and test how a service should be discovered and registered within a wider infrastructure context.

#### Environment Variables

- `CONSUL_DATACENTER_NAME`: sets the name of the data center in which the Consul cluster is running.
- `CONSUL_RETRY_JOIN_WAN`: sets the remote datacenter addresses to join. Must be a valid HCL list (i.e. comma-separated quoted addresses). See Consul's [configuration documentation](https://www.consul.io/docs/agent/options.html#retry_join_wan) for more information.
- The following error will occur if `CONSUL_RETRY_JOIN_WAN` is provided but improperly formatted:
```
==> Error parsing /etc/consul/consul.hcl: ... unexpected token while parsing list: IDENT
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for pointing out the error message.

### Clients

ContainerPilot utilizes Consul's [HTTP Agent API](https://www.consul.io/api/agent.html) for a handful of endpoints, such as `UpdateTTL`, `CheckRegister`, `ServiceRegister` and `ServiceDeregister`. Connecting ContainerPilot to Consul can be achieved by running Consul as a client to a cluster (mentioned above). It's easy to run this Consul client agent from ContainerPilot itself.
Expand Down
8 changes: 8 additions & 0 deletions bin/consul-manage
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ set -eo pipefail
preStart() {
_log "Updating consul advertise address"
sed -i "s/CONTAINERPILOT_CONSUL_IP/${CONTAINERPILOT_CONSUL_IP}/" /etc/consul/consul.hcl

_log "Updating consul datacenter name"
sed -i "s/CONSUL_DATACENTER_NAME/${CONSUL_DATACENTER_NAME:-dc1}/" /etc/consul/consul.hcl

if [ ! -z "$CONSUL_RETRY_JOIN_WAN" ]; then
_log "Updating consul retry_join_wan field"
echo "retry_join_wan = [${CONSUL_RETRY_JOIN_WAN}]" >> /etc/consul/consul.hcl
fi
}

#
Expand Down
1 change: 1 addition & 0 deletions etc/consul.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bind_addr = "CONTAINERPILOT_CONSUL_IP"
datacenter = "CONSUL_DATACENTER_NAME"
data_dir = "/data"
client_addr = "0.0.0.0"
ports {
Expand Down
30 changes: 28 additions & 2 deletions local-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,39 @@ services:
# created user-defined network and internal DNS for the name "consul".
# Nodes will use Docker DNS for the service (passed in via the CONSUL
# env var) to find each other and bootstrap the cluster.
consul:
consul1:
build: .
image: autopilotpattern/consul:${TAG:-latest}
restart: always
mem_limit: 128m
ports:
- 8500
environment:
- CONSUL=consul
- CONSUL=consul1
- CONSUL_DATACENTER_NAME=dc1
command: >
/usr/local/bin/containerpilot

# The following service block defines a nearly-identical deployment in a
# fictional second datacenter. This can be used to test multi-datacenter
# behavior in Consul.
# NOTE: CONSUL_RETRY_JOIN_WAN *must* be a valid HCL list,
# e.g.:
# "1.1.1.1"
# or
# "1.1.1.1","2.2.2.2"

consul2:
image: autopilotpattern/consul:${TAG:-latest}
restart: always
mem_limit: 128m
ports:
- 8500
environment:
- CONSUL=consul2
- CONSUL_DATACENTER_NAME=dc2
- CONSUL_RETRY_JOIN_WAN="consul1"
command: >
/usr/local/bin/containerpilot
links:
- consul1