Support multiple domains per datacenter
It would be extremely helpful for us if consul supported multiple domains per datacenter. This would help us be able to segment the clients connected to the cluster while still considering them part of a single datacenter.
For example, on the server(s) it would support something like
{ "datacenter": "us-west-1", "domain": ["dev.internal", "qa.internal"] }
If ClientA had
{ "datacenter": "us-west-1", "domain": "dev.internal", "service": { "name": "foo" } }
and ClientB had
{ "datacenter": "us-west-1", "domain": "qa.internal", "service": { "name": "foo" } }
foo.service.us-west-1.dev.internal would resolve to ClientA foo.service.us-west-1.qa.internal would resolve to ClientB
Or perhaps support something similar via tags?
Basically we want to avoid running multiple clusters of consul servers for each "environment" in a datacenter. We also want to avoid having to add the environment name to the service names. If we did dev.foo.service.us-west-1.internal (using a 'dev' tag) it creates a higher chance of error that the app code sets the wrong environment.
p.s., this may be similar to https://github.com/hashicorp/consul/issues/208 but it seemed different enough that I opened another ticket.
Does this mean a single node exists in the dev and qa clusters at the same time? I am rather confused as to the use case.
+1. I posted yesterday to the consul mailing list about this.
The drawback of running multiple clusters of consul servers, is if an agent wants access to multiple clusters you'd also have to run multiple agents. That could get messy. For example, Bamboo is our build server. It's "production". A QA host might need to access production Bamboo but QA everything else. There are other services that are shared amongst multiple environments, so a "hard scope" doesn't work for us.
This domain idea is solid. What I'd like to see is another layer between service name and datacenter name.
Instead of:
foobar-mysql.service.chicago.consul
I would love:
foobar-mysql.service.qa.chicago.consul
The environment could be optional, returning results from service-providers with the same environment by default (just how datacenter works).
I don't want to use tags either because it breaks down when tags mean different things. For example, QA and Production might both have MySQL masters and slaves. I can't do:
master.qa.foobar-mysql.service.consul
Because multiple tags aren't supported in DNS queries (maybe that's one way to solve this problem, though). But I think we would like things a little more error-proof on the client side. Currently if QA and Production both publish the service foobar-mysql and a client uses foobar-mysql.service.consul they would get results across both environments. That's what we want to avoid.
Just realized I should correct one thing above. We probably wouldn't have the "multiple agents need to run" problem for agents that need to access multiple environments. They would use their own datacenter+environment by default and could be explicit when they need something else.
So datacenter value could work if 1) people are willing to run multiple server clusters (not ideal) or 2) if Consul supported multiple datacenter values in a cluster. These options apply if the layer between service name and datacenter described above isn't desired.
It seems in general people want the namespacing that data centers provide, but without the need to run multiple clusters per environment (prod, qa, stage). I think domains are redundant to data centers to solve this, since they are both namespacing mechanisms.
Instead, I think multi-tenancy of environments is wanted. I'll think on this, but it is a challenging problem. For now, the simplest approach is to run multiple instances of Consul (1 per environment) on the same physical hardware.
the simplest approach is to run multiple instances of Consul (1 per environment) on the same physical hardware.
Agreed. We have 13 environments. We add and remove them fairly frequently, usually due to a team branching and needing their own dev or qa environment. So you can see that this may be simple, but doesn't scale all that well.
Does this mean a single node exists in the dev and qa clusters at the same time?
No. It means that there is a node in a dev cluster & another node in a qa cluster. We want the app code to just look for "foo.service.internal" and not have to worry about which cluster it is connected to.
It seems in general people want the namespacing that data centers provide, but without the need to run multiple clusters per environment
Yes
the simplest approach is to run multiple instances of Consul (1 per environment) on the same physical hardware.
This is actually quite difficult to do with Chef in a way that provides a good HA solution. Also, if an instance in AWS goes down we lose 1/3 of servers across all environments instead of just the one. :(
Got it. A better solution to multi-tenancy seems to be the consensus. I agree whole heartedly. I'll start thinking about how to support this nicely.
Unfortunately, even with multi-tenancy, losing a server would affect all the environments. No way to solve that if the hardware is shared.
I'll start thinking about how to support this nicely.
You rock!
Unfortunately, even with multi-tenancy, losing a server would affect all the environments.
Yup. But at least it would only be for cross-dc queries to the dc that lost a node. :(
multi-tenancy would be great! I just planned to run multiple clusters, but if consul supports that out of the box, it would save a lot of headaches (for us :smile: ).
This would help us a lot as well. We also have a number of distinct environments / domains within the same datacenter that are firewalled off from each other; setting up many consul server clusters is our current approach but it's not ideal for many reasons.
I'm looking at the use case for larger enterprises, where multiple teams contribute to an eco-system of services. Individual teams within the company are considered 'tenants' and should be able to contribute and manage services they own, without impacting others. One thought is to use hierarchies of consul - where tenants use a private consul cluster for project internal orchestration. This approach will still require a common, multi-tenant top-level consul cluster to discover 'published' services from other teams. This all starts with the question - is consul a good fit for these types of use cases?
@tdeckers Typically, you want to treat Consul as a shared platform within a large organization. Teams individual manage and expose their services, but they do it on a shared cluster. Having tons of independent Consul clusters will quickly become a burden to operators, as there is so many more Consul servers to reason about. The goal is to get the ACLs to the point where they are sufficiently advanced enough to enable even the most complex multi-tenant use cases.
+1
We have a use case here where we would really need some sort of enforceable name spaces for services. So mechanism to restrict a particular agent to manage services only within a defined name space would be greatly appreciated.
+100 time, much appreciated!
Hi Is this still Open? or This can be done by today's ACL support on consul? if so I would like to know some example configuration.
Hi @nati this is still in work. ACLs are getting much richer for the upcoming 0.6 release. You can see the upcoming documentation here - https://github.com/hashicorp/consul/blob/master/website/source/docs/internals/acl.html.markdown.
@slackpad that sounds great! I was going to try and hack it by creating a namespace/directory for each tenant and then restricting accordingly. But the benefits of preventing leaking via service registration and DNS have convinced me I should hold off.
If there's some way to help with the development let me know. I'd like to try and do more than add another +1 :smile:
The ACL updates are welcomed but we lose the possibility of discovering many environments for example on demand.
@scalp42 I'm not sure I follow. The ACLs should be rich enough for you to provide read-only access to services if so desired. Do you have a specific use case in mind that we wouldn't hit?
I'm not sure how ACL will help with DNS-based discovery that doesn't use SRV records (because, say, service ports are known) but just vanilla name resolution. There is a distinction between ACL management of service registration for different tenants and lookup. What if I want some kind of domain name convention such that I can support search in /etc/resolv.conf? This is where multiple subdomains within the same Consul cluster comes in handy. For example, I have this /etc/resolv.conf
nameserver 127.0.0.1
search mine.services.consul shared.services.consul
I'm looking to connect to service foo which happens to not be running under my domain, it'd just fall back onto the shared domain. This lookup part has nothing to do with tenancy. Rather, it's about logical grouping. I don't really need ACL on the lookup.