Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

more flexible container name -> hostname derivation #1018

Closed
rade opened this issue Jun 25, 2015 · 13 comments
Closed

more flexible container name -> hostname derivation #1018

rade opened this issue Jun 25, 2015 · 13 comments
Assignees
Milestone

Comments

@rade
Copy link
Member

rade commented Jun 25, 2015

See the discussion in #1006.

The idea proposed there is to derive the hostname from the container name in the proxy via a configurable regexps. Defaults to ".*" and could be set to "^$" for disabling hostname derivation (i.e. if the regexps matches nothing then we shouldn't set the hostname). Should support sub-matches, e.g. "aws-[0-9]+-\(.*\)".

We could have an env-var equivalent for weave run. Overkill?

@rade rade changed the title more flexibility in container name -> hostname derivation more flexible container name -> hostname derivation Jun 26, 2015
@rade rade modified the milestone: current Jul 2, 2015
@paulbellamy
Copy link
Contributor

In the submatch example, what would the hostname for aws-1234-db1 be? aws-1234-db1 or db1? What if there are multiple match-groups? Or should we have them supply a replacement regexp as well?

@rade
Copy link
Member Author

rade commented Jul 3, 2015

Assume one match group.

Re replacement regexp... yes.

@paulbellamy
Copy link
Contributor

So, command-line usage will look like:
weave launch --hostname-regexp 'aws-[0-9]+-(.*)' --hostname-replacement 'my-app-\1'
where --hostname-replacement is optional. Seems a bit verbose.

Could do a sed-style replacement:
weave launch --hostname-regexp '/aws-[0-9]+-(.*)/my-app-\1/'
But could be less familiar for users.

@rade
Copy link
Member Author

rade commented Jul 6, 2015

I'd go for sed style.

You mean weave launch*-proxy*

@rade
Copy link
Member Author

rade commented Jul 6, 2015

--hostname-from-container-name?

@paulbellamy
Copy link
Contributor

--hostname-from-container-name sounds like a boolean flag
--hostname-default '/aws-.../'?

@rade
Copy link
Member Author

rade commented Jul 6, 2015

just --hostname?

@paulbellamy
Copy link
Contributor

is this going on both weave launch and weave launch-proxy, or just on weave launch-proxy? If it's just on launch-proxy, then --hostname with a reasonable help text sounds fine, but on launch it seems a bit vague.

@rade
Copy link
Member Author

rade commented Jul 6, 2015

Only on launch-proxy. launch passes args to the router only.

@squaremo
Copy link
Contributor

squaremo commented Jul 6, 2015

(Cross-posted from #1006)

Now your user has two problems.

There are very few situations in which it's reasonable to ask a user to input a regular expression as an option (and even those have UX problems -- escaping for example). If container names aren't really suitable as hostnames, perhaps trying to use container names as hostnames is a mistake.

@rade
Copy link
Member Author

rade commented Jul 6, 2015

If container names aren't really suitable as hostnames, perhaps trying to use container names as hostnames is a mistake.

They are suitable in most cases. We are just making them suitable in even more cases.

There are very few situations in which it's reasonable to ask a user to input a regular expression as an option

Yep. I would expect few users ever needing to touch this option.

@squaremo
Copy link
Contributor

squaremo commented Jul 6, 2015

There are very few situations in which it's reasonable to ask a user to input a regular expression as an option

Yep. I would expect few users ever needing to touch this option.

I think you mistook my meaning. Let me put it another way: think hard about your assumptions if you find yourself wanting to use regular expressions in a user interface.

@rade
Copy link
Member Author

rade commented Jul 6, 2015

You don't have to use the automatic hostname derivation. It's there purely for convenience, and for the situations where the hostname cannot be specified directly (@tomwilkie ran into that on ECS, I believe).

@2opremio 2opremio self-assigned this Jul 13, 2015
2opremio pushed a commit that referenced this issue Jul 13, 2015
Provides a new "--hostname=substitution" flag to WeaveProxy, where
'substitution' is a sed-style substitution command. 'substitution' will be
applied to container names at launch-time, as a means to control what hostnames will
be registered in WeaveDNS.

The substitution is implemented with
https://golang.org/pkg/regexp/#Regexp.ReplaceAllString . Thus, references to
regexp substitution groups should be prepended with a dollar sign.

For instance, if we provide "--hostname='/aws-[0-9]+-(.*)/my-app-$1/'", running
a container named 'aws-12798186823-foo' through WeaveProxy will lead to WeaveDNS
registering 'my-app-foo'.

Closes #1018
2opremio pushed a commit that referenced this issue Jul 13, 2015
Provides a new "--hostname=substitution" flag to WeaveProxy, where
'substitution' is a sed-style substitution command. 'substitution' will be
applied to container names at launch-time, as a means to control what hostnames will
be registered in WeaveDNS.

The substitution is implemented with
https://golang.org/pkg/regexp/#Regexp.ReplaceAllString . Thus, references to
regexp substitution groups should be prepended with a dollar sign.

For instance, if we provide "--hostname='/aws-[0-9]+-(.*)/my-app-$1/'", running
a container named 'aws-12798186823-foo' through WeaveProxy will lead to WeaveDNS
registering 'my-app-foo'.

Closes #1018
2opremio pushed a commit that referenced this issue Jul 13, 2015
Provides a new "--hostname=substitution" flag to WeaveProxy, where
'substitution' is a sed-style substitution command. 'substitution' will be
applied to container names at launch-time, as a means to control what hostnames will
be registered in WeaveDNS.

The substitution is implemented with
https://golang.org/pkg/regexp/#Regexp.ReplaceAllString . Thus, references to
regexp substitution groups should be prepended with a dollar sign.

For instance, if we provide "--hostname='/aws-[0-9]+-(.*)/my-app-$1/'", running
a container named 'aws-12798186823-foo' through WeaveProxy will lead to WeaveDNS
registering 'my-app-foo'.

Closes #1018
2opremio pushed a commit that referenced this issue Jul 14, 2015
Provides a new "--hostname=substitution" flag to WeaveProxy, where
'substitution' is a sed-style substitution command. 'substitution' will be
applied to container names at launch-time, as a means to control what hostnames will
be registered in WeaveDNS.

The substitution is implemented with
https://golang.org/pkg/regexp/#Regexp.ReplaceAllString . Thus, references to
regexp substitution groups should be prepended with a dollar sign.

For instance, if we provide "--hostname='/aws-[0-9]+-(.*)/my-app-$1/'", running
a container named 'aws-12798186823-foo' through WeaveProxy will lead to WeaveDNS
registering 'my-app-foo'.

Closes #1018
2opremio pushed a commit that referenced this issue Jul 14, 2015
Provides a new "--hostname=substitution" flag to WeaveProxy, where
'substitution' is a sed-style substitution command. 'substitution' will be
applied to container names at launch-time, as a means to control what hostnames will
be registered in WeaveDNS.

The substitution is implemented with
https://golang.org/pkg/regexp/#Regexp.ReplaceAllString . Thus, references to
regexp substitution groups should be prepended with a dollar sign.

For instance, if we provide "--hostname='/aws-[0-9]+-(.*)/my-app-$1/'", running
a container named 'aws-12798186823-foo' through WeaveProxy will lead to WeaveDNS
registering 'my-app-foo'.

Closes #1018
2opremio pushed a commit that referenced this issue Jul 14, 2015
Provides to new two new flags: `--hostname-match <regexp>`
and `--hostname-replacement <replacement>`. When launching a container, its name
matched against regular expression `<regexp>`. Then, based on that match,
`<replacement>` will be used to generate a hostname, which will ultimately be
handed over to weaveDNS for registration.

The substitution is implemented with
https://golang.org/pkg/regexp/#Regexp.ReplaceAllString . Thus, references to
regexp substitution groups should be prepended with a dollar sign.

For instance, if we provide `--hostname-match '^aws-[0-9]+-(.*)$'` and
`--hostname-replacement 'my-app-$1'`, running a container named
`aws-12798186823-foo` through WeaveProxy will lead to WeaveDNS registering
`my-app-foo`.

Closes #1018
rade added a commit that referenced this issue Jul 14, 2015
…ivation

[proxy] More flexible container name -> hostname derivation

Closes #1018.
@rade rade modified the milestones: current, 1.1.0 Jul 15, 2015
@rade rade modified the milestones: 1.1.0, current Jul 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants