Search code examples
kong

Kong 3.0 {"message":"no Route matched with those values"}


I'm trying to setup Kong proxy in Docker-Compose and something is not working. My Docker-compose file looks like that:

version: '3.8'

name: 'App'

networks:
  api-network:
    name: api-network
    driver: bridge

services:
  kong:
    image: kong:3.0
    volumes:
      - ./App/kong/kong.yml:/usr/local/kong/declarative/kong.yml
    container_name: kong
    environment:
      KONG_DATABASE: 'off'
      KONG_PROXY_ACCESS_LOG: '/dev/stdout'
      KONG_ADMIN_ACCESS_LOG: '/dev/stdout'
      KONG_PROXY_ERROR_LOG: '/dev/stderr'
      KONG_ADMIN_ERROR_LOG: '/dev/stderr'
      KONG_ADMIN_LISTEN: "0.0.0.0:8001, 0.0.0.0:8444 ssl"
      KONG_DECALATIVE_CONFIG: "/usr/local/kong/declarative/kong.yml"
    command: "kong start"
    networks:
      - api-network
    ports:
      - "8000:8000"
      - "8443:8443"
      - "127.0.0.1:8001:8001"
      - "127.0.0.1:8444:8444"
  
  building_service:
    container_name: building_service
    build: ./App/building_service
    restart: always
    command: uvicorn app.main:app --reload --host 0.0.0.0 --port 80
    ports:
      - 8004:80
    expose:
      - 80
    networks:
      - api-network
    volumes:
      - ./App/building_service:/usr/src/building_service/

My kong.yml file:

_format_version: "3.0"
_transform: true

services:
  - name: building_service
    url: http://building_service/building
  routes:
  - name: building_service_route
    paths:
    - /building

When I check services http://localhost:8001/services I get message:

{"next":null,"data":[]}

When I check config http://localhost:8001/config I get message:

{"config":"_format_version: '3.0'\n_transform: false\n"}

And finally when I try to open docs (fastAPI) for my building_service http://localhost:8000/building/docs or just building http://localhost:8000/building I get:

{"message":"no Route matched with those values"}

Solution

  • Are you sure that your declarative config file is loaded? If the file is loaded into kong, calling:8001/services would return building_service service

    Judging from your docker-compose file
    KONG_DECALATIVE_CONFIG: "/usr/local/kong/declarative/kong.yml"
    Shouldn't it be KONG_DECLARATIVE_CONFIG ??