Skip to content

Comments

Update to Consul V1.0.1#11

Open
diemonster wants to merge 16 commits intomasterfrom
v1.0.1
Open

Update to Consul V1.0.1#11
diemonster wants to merge 16 commits intomasterfrom
v1.0.1

Conversation

@diemonster
Copy link
Contributor

@diemonster diemonster commented Nov 30, 2017

This PR updates Consul to use the latest 1.0.1 version, which introduced several new pieces of functionality and/or breaking changes. Several runtime configuration options for Consul needed to be changed as a result, with some new features added as well.

Details

  • Added Consul's new aws -retry-join functionality, which can target a tagged cluster for new node joins. This is an improvement over using an ELB for bootstrapping a Consul cluster.
  • Enabled host networking for Consul server containers, and configured DNS to listen on port 53 rather than an overly complex port mapping from 8600 as we had previously.
  • Split HelloWorld's dev environment and Consul into two separate environments with link enabled.
  • Set min_count for Consul's environment to ensure that server instances are not scaled down
  • Created persistent data volume for Consul's data-dir, which allows manual outage mitigation as detailed here.

Testing

Extensive manual testing on Layer0 v0.10.3; will need future testing on v0.11.0.

TODO

  • Remove hardcoded AMIs for Consul and Dev environments (must be completed after Layer0 v0.11.0 refactor)
  • Add environment link example in documentation

Copy link

@jparsons04 jparsons04 left a comment

Choose a reason for hiding this comment

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

Some nitty things and other external considerations to think about.

README.md Outdated

When you have multiple services in a Layer0 environment, how do you get them to connect to each other? One simple answer is that you hardcode service endpoints (i.e. a Loadbalancer URL) in your application configurations. That may be OK for testing, but ultimately hardcoding endpoints is not portable, annoying to maintain, and not in line with the [guidelines of a 12-factor app](https://12factor.net/). A much better solution is to use a service like Consul, which along with another tool called Registrator, can automatically detect your services when they come online and add them to a service registry. You can then 'discover' these services using catalog endpoints via [DNS](https://www.consul.io/docs/agent/dns.html) or [HTTP](https://www.consul.io/docs/agent/http.html).

For a practical applications of Consul, see our [Layer0 Consul Documentation](http://docs.xfra.ims.io/guides/consul/).

Choose a reason for hiding this comment

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

[sort of nit] This sentence doesn't make sense grammatically and the link is now out of date.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True. Docs are still WIP, I'll get to those tmrw.

environment_id = "${layer0_environment.consul.id}"
}

resource "layer0_environment" "consul" {

Choose a reason for hiding this comment

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

Just want to make a future note that adding the consul environment in this module will likely have implications for the layer0 walkthroughs that consume this module (for instance, if the walkthroughs have terraform files that make their own consul environment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This environment is created by the HelloWorld application, I kept the Consul module behavior (of not creating an environment by itself) as-is.

name = "consul"
// TODO: Remove hardcoded AMI
ami = "ami-f5fc2c8d"
min_count = 3
Copy link

Choose a reason for hiding this comment

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

in the future, would be nice to have min_count determined internally by scheduler...

i consider it dangerous that users need to manually set this based on sum of discrete ECS instances that will end up getting spun up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree this is not ideal, and we're talking about ways to make it less dangerous within our current Layer0 refactor. That being said, there is an argument for the explicitness here and how such apps are not designed to run on Layer0 in the first place.

{
"name": "consul-agent",
"image": "consul:${consul_version}",
"privileged": true,
Copy link

Choose a reason for hiding this comment

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

guessing this is to bind to port 53?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

Copy link

Choose a reason for hiding this comment

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

i see the port 53 binding on the Server template, not not the Agent. is the Server the only one that actually needs this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It makes things a lot easier for the Server specifically because dealing w the Docker bridge IP is a pain. As for the Agent, technically containers local to it can use the Agent's exposed dns port for resolution as well. As such, I considered having the Agent follow the same port mapping pattern as Server but I opted not to in order to keep changes to a minimum. Could be convinced otherwise, though...

Copy link

Choose a reason for hiding this comment

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

well this does make sense if you are using the Agent specifically for DNS service discovery... so yeah... i'll buy that... but an example of that in your getting started would be cool

{
"name": "registrator",
"image": "gliderlabs/registrator:latest",
"privileged": true,
Copy link

Choose a reason for hiding this comment

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

why does registrator also need to be privileged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because it already requires mounting the docker socket http://gliderlabs.github.io/registrator/latest/ (see their runtime params), which is effectively privileged behavior anyway. I prefer making this overall behavior more explicit.

@diemonster diemonster changed the title WIP: Update to Consul V1.0.1 Update to Consul V1.0.1 Dec 5, 2017
@andycmaj
Copy link

so i think the one remaining thing that's preventing me from consuming this as a module is that the consul LB is private and doesn't expose http:80 by default, and there aren't variables to control that.

here is the change i needed to make to be able to consume this:
screencapture at mon dec 11 16 57 59 pst 2017

environment = "${var.environment_id}"
deploy = "${layer0_deploy.consul.id}"
load_balancer = "${layer0_load_balancer.consul.id}"
size = "t2.medium" // https://www.consul.io/docs/guides/performance.html#minimum-server-requirements

Choose a reason for hiding this comment

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

FYI i don't think size works for previous (<=0.10.3) versions of L0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants