-
Notifications
You must be signed in to change notification settings - Fork 670
more flexible container name -> hostname derivation #1018
Comments
In the submatch example, what would the hostname for |
Assume one match group. Re replacement regexp... yes. |
So, command-line usage will look like: Could do a sed-style replacement: |
I'd go for sed style. You mean |
|
|
just |
is this going on both |
Only on |
(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. |
They are suitable in most cases. We are just making them suitable in even more cases.
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. |
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). |
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
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
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
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
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
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
…ivation [proxy] More flexible container name -> hostname derivation Closes #1018.
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?The text was updated successfully, but these errors were encountered: