fabric8io / fabric8

fabric8 is an open source microservices platform based on Docker, Kubernetes and Jenkins
http://fabric8.io/
1.76k stars 504 forks source link

allow the @ServiceName injection to use http or https as the protocol depending on the service port (80 / 443)? #3808

Open jstrachan opened 9 years ago

jstrachan commented 9 years ago

so gogs can be configured to use http or https; we've code that would like to use whichever flavour is being used.

https://github.com/fabric8io/fabric8/blob/master/forge/fabric8-forge-core/src/main/java/io/fabric8/forge/rest/main/GitUserHelper.java#L44-44

I added @Protocol("http") as otherwise this results in URLs of the form: "tcp://foo.bar" which don't work too well in browsers.

What would be nice is if we know its either http or https then use one of those protocols and pick the right protocol based on the port number (e.g. if 443 then use https otherwise default to http).

I kinda hoped the env vars could expose the protocol; but seems to always be "TCP". e.g.:

            "GOGS_HTTP_SERVICE_PORT_443_TCP_PROTO=tcp",

Ah - looks like we're not setting the protocol string on the gogs service; lets try that and see if it helps...

jstrachan commented 9 years ago

am patching the mvn plugin to allow fabric8.service.protocol to be used...

jimmidyson commented 9 years ago

Service protocol can only be tcp or UDP AFAIK. This is for the kube proxy to set up port listeners.

On 08:23, Fri, 24 Apr 2015 James Strachan notifications@github.com wrote:

am patching the mvn plugin to allow fabric8.service.protocol to be used...

— Reply to this email directly or view it on GitHub https://github.com/fabric8io/fabric8/issues/3808#issuecomment-95832611.

jstrachan commented 9 years ago

ah crap! :(

jstrachan commented 9 years ago

OK maybe we need a @HttpProtocol annotation for the CDI stuff; to pick the most suitable http protocol for injecting URLs?

jimmidyson commented 9 years ago

Perhaps a bit more generic, can imagine ssh, ftp, git, etc all being options? Defaulting to http seems sane though.

On Fri, 24 Apr 2015 at 08:25 James Strachan notifications@github.com wrote:

OK maybe we need a @HttpProtocol annotation for the CDI stuff; to pick the most suitable http protocol for injecting URLs?

— Reply to this email directly or view it on GitHub https://github.com/fabric8io/fabric8/issues/3808#issuecomment-95833277.

jstrachan commented 9 years ago

Yeah, maybe a @ProtocolFromPort that uses the actual port number of the service to determine 80 = http, 443 = https etc?

jstrachan commented 9 years ago

If a service exposes ssh and http this could be confusing ;). Maybe we need to use a @HttpProtocol annotation to pick https if possible or http if not for the protocol?

jstrachan commented 9 years ago

For specific protocols, like ssh, folks can use code>@Protocol("ssh")</code its only for things like http/https that a service may or may not be configured to use https; so if not fall back to http (e.g. for gogs).

iocanel commented 9 years ago

I think that we should just add an option to the existing annotation Protocol annotation and if explicitly set, we should attempt a "port to protocol" conversion.