Kong: Global fallback route does not work

Created on 17 Feb 2020  路  4Comments  路  Source: Kong/kong

Summary

I run Kong in DB-less mode with the following config:

services:
  - name: s-service
    url: http://s-service

upstreams:
  - name: s-service
    heathchecks:
        <skipped since not relevant> 
    targets:
       - target: s-service:8090
         weight: 100

routes:
  - name: root
    paths:
       - /

The idea is to catch every request and proxy it by the Host header. In the example above only one service is provided for brevity.

This config works fine for Kong v1.4.2, and doesn't work for Kong 2.0.1, which returns no Service found with those values for each requests.
The upsteam is healthy and proper configs are returned by Admin API of Kong.

I see the fallback route guide in the documentation, but it includes service route, not the global one. Is there such thing as global route in Kong v2?

Steps To Reproduce

  1. Use the config above to Start Kong in DB-less mode;
  2. Send request with header host: s-service to any path;
  3. Observe the response is no Service found with those values.

Additional Details & Logs

  • Kong version (2.0.1)
  • Kong logs - no relevant logs found.
  • Operating system: local -- macOS v10.14.6; Kong is running in Docker v2.1.0.5, engine v19.03.5.
tasfeature

Most helpful comment

I marked this as task/feature just in case if we want to reconsider the removal or get this feature back in some form (perhaps not in original). If there are others in community that would like to see this feature returned, please let us know here, thank you!

All 4 comments

Please instead do:

services:
  - name: s-service
    url: http://s-service
    routes:
    - name: root
      paths:
      - /
upstreams:
  - name: s-service
    heathchecks:
        <skipped since not relevant> 
    targets:
       - target: s-service:8090
         weight: 100

You are creating a service and a route but not associating them together and Kong can't figure out what to do one a route is matched.

@hbagdi that's the idea -- to create a single route which is not associated to any particular service, but instead does routing to any service based on Host header.
Such setup works fine in Kong v1.4.

btw, in Kong 2.0 such config seems not working as well:

services:
  - name: s-service
    url: http://s-service
    routes:
    - name: root
      paths:
      - /

unless you add Hosts config to the route:

services:
  - name: s-service
    url: http://s-service
    routes:
    - name: root
      paths:
      - /
      hosts:
      - s-service

Service mesh was removed with 2.0 and also all the transparent patches were removed, and along we removed serviceless proxying:
https://github.com/Kong/kong/pull/5350
https://github.com/Kong/kong/pull/5353

The removal of transparent made the feature less useful and limited, and in many cases confusing. I think we can still make a plugin to enable it.

I marked this as task/feature just in case if we want to reconsider the removal or get this feature back in some form (perhaps not in original). If there are others in community that would like to see this feature returned, please let us know here, thank you!

Was this page helpful?
0 / 5 - 0 ratings