Routing - acmeair-svt/acmeair-mainservice-java GitHub Wiki

Challenges

  • The default routes for each microservice creates different hostnames for each service, causing CORS issues. (See below)
  • The Mainservice submits requests using window.location, so the hostnames for each service must be the same as the Mainservice
    • ex. url: window.location.protocol+ '//' + window.location.host + '/customer/config/countCustomers'
  • The host is hard coded into the app-deploy.yaml file and must be updated when deploying to new cluster. (See below)
  • Having the same host for all services will result in certificate sharing issues when using HTTPS

Enable CORS

  • Add CORS config to server.xml for each service
 <cors domain="/acmeair"
      allowedOrigins="*"
      allowedMethods="OPTIONS, GET, DELETE, POST"
      allowedHeaders="*"
      allowCredentials="true"
      maxAge="3600" />
<cors domain="/<service>"
      allowedOrigins="*"
      allowedMethods="GET, DELETE, POST, OPTIONS"
      allowedHeaders="*"
      allowCredentials="true"
      maxAge="3600" />

Routing with spec.route

  • We decided to specify the name of the routes by adding the following to app-deploy.yaml file for each service (replace service with acmeair for main and name of service for flight, booking, auth and customer)
  spec.route:
      host: aa-acmeair.apps.acme42.cp.fyre.ibm.com
      path: "/service"
  • Challenge: the host still needs to be updated each time the application is deployed to a new cluster

Avoiding hardcoded route

  • Tested changing spec.route to

    route:
        host: 
        path: "/acmeair"
    
    • Result: route uses service name in host image
    • Attempt to login image
  • Attempted to use a configmap for generating default hostname (This is not currently used because the defaultHostName variable requires Open Liberty Operator version 0.7.0)

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: open-liberty-operator
      namespace: acmeair
    data:
      defaultHostName: 'host-acmeair.apps.acmeair45.cp.fyre.ibm.com'
    
    • Removed host from route
      route:
          host: 
          path: "/acmeair"
    
    • Result: image

    • Added "main" as route.host

      • Result: Route for main service became http://main/acmeair
  • NOTES:

    • Open Liberty Operator version is currently 0.5.1 and defaultHostName variable requires version 0.7.0
    • Having the same host for all services will result in certificate sharing issues when using HTTPS
    • Use proxy with a single externally exposed route and connect internally with application binding
    • When using HTTPS with only one externally exposed route it may not be possible to reload AcmeAir database with curl method anymore for jMeter. Use website to reload database in this case instead
⚠️ **GitHub.com Fallback** ⚠️