问题
Below is the error on cf push
:
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.
Below is the manifest file:
applications:
- name: xyz-api
instances: 1
memory: 1G
buildpack: java_buildpack_offline
path: target/xyz-api-0.1-SNAPSHOT.jar
cf login x.y.z.w.org.cloud ....
cf push xyz-api -p target/xyz-api-0.1-SNAPSHOT.jar
We have two API end points:
a.b.c.d.org.cloud
x.y.z.w.org.cloud
As per investigation, we realised that the route name already exist on a.b.c.d.org.cloud
because our source code is hardcoding the same route name for on any API end point.
Can't same route name be used for multiple API end points? why?
回答1:
By default, cf push assigns a route to every app
I have no idea what the functionality is omitting a route
, maybe a default /
is assigned to the application in the space which might already be taken by another application in the space.
The Cloud Foundry Gorouter routes requests to apps by associating an app with an address, known as a route. We call this association a mapping. Use the cf CLI cf map-route command to associate an app and route.
You can run the cf routes
command to see what routes are in use,
https://cli.cloudfoundry.org/en-US/cf/routes.html
You can run an application without a route, a random route, or provide a route
https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html#no-route
---
...
no-route: true
random route,
---
...
random-route: true
defined route,
---
...
routes:
- route: example.com
- route: www.example.com/foo
- route: tcp-example.com:1234
https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html#routes
You may want to check the routes documentation for a more detailed explanation of what a route is.
https://docs.cloudfoundry.org/devguide/deploy-apps/routes-domains.html
来源:https://stackoverflow.com/questions/54580831/apps-must-be-mapped-to-routes-in-the-same-space