Route name across api end points

2019-08-29 17:43发布

问题:

We have below two end points, having their respective Organization and Space

1) Dev environment: a.b.c.org.cloud

2) Proof of Concept environment(POC): a.b.c.poc.io


There is an app(my-cool-app) with route name my-cool-app.a.b.c.poc.io running in POC environment.

Due to code smell issue in this app, route name is decided by app source code(hard coded) but not through manifest.yml of cf push. This lead to same route name my-cool-app.a.b.c.poc.io for my-cool-app in Dev environment.


1) Can app have same route name my-cool-app.a.b.c.poc.io in dev environment(a.b.c.org.cloud)? Because we see this error org.cloudfoundry.client.v2.ClientV2Exception: CF-InvalidRelation(1002): The app cannot be mapped to this route because the route is not in this space. Apps must be mapped to routes in the same space. after cf push

2) Does Dev and POC environment have same cloud controller database(CCDB)? Because CCDB maintains binding of app name with routename

回答1:

1) Can app have same route name my-cool-app.a.b.c.poc.io in dev environment(a.b.c.org.cloud)?

It depends on what you mean by "dev" and "poc" environments. If they are totally separate foundations, then yes. It should work. You just use DNS to control where actual traffic is routed.

If they are sharing the same cloud controller, like you have a "dev" and "poc" org, then it works but with restrictions. You can map the same route to two different apps, but they have to be in the same space. That's what this error is saying.

The app cannot be mapped to this route because the route is not in this space. Apps must be mapped to routes in the same space.

If you map the same route to two different apps, what you're effectively doing is splitting traffic across the two apps 50/50. If Cloud Controller were to allow this across orgs & spaces then you could have someone in a different org & space that is able to divert traffic from your app to another app, potentially malicious app, which would be a big security problem. Given this, Cloud Controller prevents that from being allowed.

2) Does Dev and POC environment have same cloud controller database(CCDB)? Because CCDB maintains binding of app name with routename

It sounds like your environments do, but that's not a strict requirement. You could have two totally separate foundations, one for Dev and one for POC, which do not share anything.