openshift / origin

Conformance test suite for OpenShift
http://www.openshift.org
Apache License 2.0
8.54k stars 4.73k forks source link

auto-create OpenShift Routes when a Service is created (if there's metadata/annotations on the service)? #2026

Closed jstrachan closed 6 years ago

jstrachan commented 10 years ago

One of the awesome things about Kubernetes is that the Service, Pods, Replication Controller JSON/YAML can be run on any environment and namespace/project.

Right now Routes are completely environment and namespace specific since they refer to the globally unique host name to expose the service. However its kinda painful writing/generating lots of JSON for each service; if you've lots of services, thats lots of JSON of the Routes.

It would be nice if either by default, or if some OpenShift metadata/annotation were present on the Service, when a Service gets created OpenShift it would automatically also create a Route for the service on host ${serviceId}.${namespace}.${OPENSHIFT_DOMAIN} where OPENSHIFT_DOMAIN is either a global configuration; or we specify the ${namespace}.${OPENSHIFT_DOMAIN} as an annotation on the Project.

i.e. we could make Services which can be deployed anywhere and if they are deployed on OpenShift then a Route is automatically created.

Folks could add extra annotations to help the generation of the Route; such as session affinity or TLS termination etc. i.e. we can put all the relevant metadata into the Service (as, say, annotations) and then it'll just work in any Kubernetes environment - and then in any OpenShift namespace/project it'd get a Route (if annotated correctly)

0xmichalis commented 10 years ago

@jstrachan shortly you will be able to generate routes from services with oc expose. https://github.com/openshift/origin/pull/2045

smarterclayton commented 10 years ago

We've talked about auto creating routes based on metadata on the service. It should be easy.

jstrachan commented 10 years ago

agreed - I think it would really help app developers too; they'd be able to generate standard kubernetes json that works on any kubernetes environment; and then have routes created automatically if on OpenShift (or any other kubernetes environment that wishes the respect the OpenShift route metadata)

jstrachan commented 10 years ago

as an aside a workaround for this issue; we've a simple command for java folks to lazily create any missing routes: mvn fabric8:create-routes.

It'd be much nicer for this to happen on the fly by OpenShift though

jstrachan commented 9 years ago

how about reusing the loadBalancer flag from kubernetes to indicate whether a Route should be created?

smarterclayton commented 9 years ago

I'd be ok with that. However, loadBalancer should be using the router anyway for a lot of customer deployments. @eparis related to what we discussed yesterday in regards to ingress/egress - if loadBalancer is served by the routers (or by a router that exists to handle TCP routing) we'd still need IP allocation in a regular environment.

On Fri, Jul 17, 2015 at 4:20 AM, James Strachan notifications@github.com wrote:

how about reusing the loadBalancer flag from kubernetes to indicate whether a Route should be created?

— Reply to this email directly or view it on GitHub https://github.com/openshift/origin/issues/2026#issuecomment-122213291.

Clayton Coleman | Lead Engineer, OpenShift

rawlingsj commented 9 years ago

+1 - it would be great to see this happen.

jstrachan commented 9 years ago

I'm wondering if OpenShift should follow the GKE approach of respecting the type: 'LoadBalancer on the Service; if that type is set to LoadBalancer then auto-create a Route? (As opposed to requiring an OpenShift specific annotation)

Then as a developer making a service which needs an external load balancer (like a web app), you'd just set type: 'LoadBalancer' and know your service will work properly on at least GKE and OpenShift. Then any other kubernetes environment should try to respect the LoadBalancer type too

jstrachan commented 9 years ago

BTW for now I've patched our fork of helm to do this for us when creating a Service which is of type LoadBalancer as a workaround. We basically just run oc expose service cheese after creating the service if its type is LoadBalancer https://github.com/fabric8io/helm/blob/openshift-all/action/openshift.go#L56

dustymabe commented 8 years ago

+1 for this feature.

smarterclayton commented 8 years ago

I think there's a good precedent for this. The challenge is identifying which ports to expose. Will keep this on the list of things to look at.

openshift-bot commented 7 years ago

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot commented 6 years ago

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

openshift-bot commented 6 years ago

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close