Recommend approach for multiple environments

1,838 views
Skip to first unread message

scalp42

unread,
Aug 28, 2015, 4:21:50 PM8/28/15
to Consul

I'm in the process of migrating to Consul and I was wondering what was the correct approach for this scenario:

  • a single consul cluster
  • multiple environments (prod, dev etc)

The possible ways:

  • should services rely heavily on tags to differentiate them ?
    •  assuming a service myservice with prod tag (prod.myservice.service.consul)
    • {{range service "myservice"}}
      {{if .Tags.Contains("prod") }}
      {{.Address}}
      {{end}}
      {{end}}


  • use the datacenter concept so you can specifically query in consul-template ?
  • rely on the node name and split on it, assuming a node name myservice-prod-i4252

I know DCs are not replicated out of the box but I'm assuming it should not matter in that case.


On side note, would the following find prod nodes AND prod nodes tagged master ? (the "or" at the beginning is confusing me)


{{range service "myservice"}}
{{if or (.Tags.Contains "prod") (.Tags.Contains "master") }}
{{.Address}}
{{end}}
{{end}}


Any insight would be welcomed, thanks in advance.

Alvaro Miranda Aguilera

unread,
Aug 30, 2015, 8:28:30 AM8/30/15
to consu...@googlegroups.com
Hello

Even if you have 1 datacenter, wouldn't be cleaner have separate
consul DC for PROD/DEV/TEST ?

instead of:

prod.myservice.service.consul

You can have:
myservice.service.prod
myservice.service.test
myservice.service.dev

Maybe is overkill, but it feels easy so send traffic to the wrong node
if all are mysql.service.consul

If you haven't read this, is a nice post:
https://hashicorp.com/blog/neofonie-consul-cs.html


Thanks
Alvaro.
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in violation
> of those guidelines may result in your removal from this mailing list.
>
> GitHub Issues: https://github.com/hashicorp/consul/issues
> IRC: #consul on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Consul" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to consul-tool...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/consul-tool/746d78c8-c331-41c9-a6e3-4ce4258433a7%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

scalp42

unread,
Aug 31, 2015, 2:23:28 PM8/31/15
to Consul
Hi,

Thanks for the answer.

This is what I meant by querying multiple DCs through consul-templates.

The issue is that unless I'm wrong, I need to have at the minimum 3 consul "servers" per env right? Or is it a logical separation?

For example, assuming I have a Consul cluster up in an environment "infra" (bootstrapped with dc "infra"). If I install Consul agent on machines located in "prod" environment, how do I point them toward the "infra" Consul servers yet making sure they appear in the "prod" DC (logical) ?

Thanks in advance.

scalp42

unread,
Aug 31, 2015, 2:54:41 PM8/31/15
to Consul
Just came across https://github.com/hashicorp/consul/issues/290#issuecomment-52568475

Running dozen Consul clusters if you have dozen environments will not scale for me, so I think I'll default to using tags unless I'm missing something.

Alvaro Miranda Aguilera

unread,
Sep 3, 2015, 1:47:49 AM9/3/15
to consu...@googlegroups.com
On Tue, Sep 1, 2015 at 6:23 AM, scalp42 <scal...@gmail.com> wrote:
>> myservice.service.prod
>> myservice.service.test
>> myservice.service.dev

Saw you other email, but I will reply this first.

When you join those DC, you will be able to see what is on the other
datacenters too.

So web.service.test can reach db.service.test or db.service.dev if you require.

Alvaro Miranda Aguilera

unread,
Sep 3, 2015, 1:50:01 AM9/3/15
to consu...@googlegroups.com
Hi there

Yeah, valid point.

I was thinking in the way that create 3 smalls vm, or 3 docker
containers ( on different host ) and the pros will outpace the cons.

But it's a valid point.

Thanks for sharing your thinking.
Alvaro.
> https://groups.google.com/d/msgid/consul-tool/ba49c37a-c6f7-4846-9284-0a3585467049%40googlegroups.com.
Message has been deleted

bitmask777

unread,
Aug 18, 2016, 2:50:11 PM8/18/16
to Consul
@scalp42 Same issue here and considering the tagging approach. How did going with tags work out for you?
Reply all
Reply to author
Forward
0 new messages