-
Notifications
You must be signed in to change notification settings - Fork 782
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
Expose tagged addresses #604
Comments
Don't have time to work on this immediately but this is a good idea! |
Hey @slackpad Can you link me to the API for this? I don't see it documented on consul.io. |
@sethvargo it's the |
@deltaroe is there currently a way to expose the wan address of a node inside a consul template? Let's say we have node in dc1, with two different ip addresses. Imagine this template on a node in dc2:
I've tried using |
@alexef not that I know of right now. Based on the previous comments it looks like there was a hangup in deciding if consul-template should redo the wan translation logic itself or to push it into consul itself to do the translation centrally. In my case I just wanted the raw untranslated value and I was going to do the translation elsewhere. The raw value is in the response consul gives to consul-template, but consul-template doesn't expose it as far as I could tell. It's not been a blocker to me yet, but will be shortly. Exposing the raw attribute looks easy enough and if it does become a blocker I'll see if my limited go knowledge will be useful enough to get the raw value at least added. The translation logic you're looking for is a different issue |
Thank you so much @deltaroe for the insight. For the record, I'm currently exploring this hack: setting the wan address on the service definition as a tag, then parsing the tag in the template (feels like sharpening an arrow with a stone):
I have zero go skills yet, but I'll follow up the discussion here and try to help as much as I can. |
Decided to take a stab at this, but pretty quickly hit a wall that the go consul api doesn't expose the taggedaddresses attribute. It's in the HTTP API, just hasn't been exposed further. I think I'm going to take the approach @alexef did rather than proceed. |
Update on this one - hashicorp/consul#2275 will make Consul translate addresses internally, so consul-template will "just work" for the most common use case where you want the addresses translated in your templates. I'll get the tagged addresses exposed under hashicorp/consul#2273, and add a new "lan" tag so you can get the raw LAN address even under the above change, and then it should be possible to get all the addresses under consul-template. |
The upstream changes are now in - hashicorp/consul#2280. |
Thanks @slackpad - I'm not seeing how this will "just work" though? Do we need to set that header somewhere? |
I can do the CT side when I get a chance here in a bit. If your agent is configured with For people who want to do something special with tagged addresses, I think we can expose them in the template language directly, so you can get at |
@sethvargo @slackpad i think this part it is totally missing on consul-template documentation, right? |
gives me
gives me
|
Hi @deltaroe Please read the documentation on Go's templating format. You can find the link to it in the README under the "Templating Language" section. That documentation has examples for accessing values in a map. https://github.com/hashicorp/consul-template#templating-language |
@sethvargo |
@sethvargo I'm still not able to understand how to do this, on Go Documentation it is too hard to catch it. |
|
For taggedaddresses in particular service use
|
@imbdb, @vasekboch ... Thanks for adding the examples. I just added an example of using the ServiceTaggedAddresses to the official docs. Hopefully it will help more people figure this out. |
tagged address support has been added to consul as of 0.6.4. Would love to see it exposed in consul-template. Most of the time the translate_wan_addresess feature will handle exposing the right address, but I have one use case where both lan and wan addresses are needed.
I can put together a PR, but my go is not strong and I don't need it right away so if someone gets to it first that would be great.
The text was updated successfully, but these errors were encountered: