Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routes with the same path but different methods are not being created #202

Closed
justinrcs opened this issue Nov 27, 2018 · 3 comments
Closed
Assignees
Labels
bug Something isn't working work in progress Work In Progress

Comments

@justinrcs
Copy link

Summary

Looking at moving from AWS API Gateway to Kong, we need to be able to reproduce our current setup. Given a simple CRUD API, where {id} is a path parameter variable:

POST
https://some-host/some-api-context/

GET
https://some-host/some-api-context/{id}

PUT/PATCH
https://some-host/some-api-context/{id}

DELETE
https://some-host/some-api-context/{id}

Each route points to a separate Lambda function responsible for a specific operation (create, update, etc)

Attempting to re-create this using the Ingress Controller (will just illustrate POST and GET for brevity)

POST (create):

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: api-post
  namespace:  kong
  annotations:
    kubernetes.io/ingress.class: "kong"
    configuration.konghq.com: api-post-config
    plugins.konghq.com: api-post-plugin
spec:
  rules:
    - host: some-host
      http:
        paths:
        - backend:
            serviceName: kong-proxy
            servicePort: 8000
          path: /some-api
apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
  name: api-post-config
  namespace: kong
route:
  methods:
  - POST
  regex_priority: 0
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: api-post-plugin
  namespace: kong
config:
    aws_key: [some-key]
    aws_secret: [some-secret]
    aws_region: [aws-region]
    function_name: [create-lambda-function-name]
    forward_request_body: true
    forward_request_headers: true
    forward_request_method: true
    invocation_type: RequestResponse
plugin: aws-lambda

GET (read):

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: api-get
  namespace:  kong
  annotations:
    kubernetes.io/ingress.class: "kong"
    configuration.konghq.com: api-get-config
    plugins.konghq.com: api-get-plugin
spec:
  rules:
    - host: some-host
      http:
        paths:
        - backend:
            serviceName: kong-proxy
            servicePort: 8000
          path: /some-api
apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
  name: api-get-config
  namespace: kong
route:
  methods:
  - GET
  regex_priority: 0
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: api-get-plugin
  namespace: kong
config:
    aws_key: [some-key]
    aws_secret: [some-secret]
    aws_region: [aws-region]
    function_name: [read-lambda-function-name]
    forward_request_body: true
    forward_request_headers: true
    forward_request_method: true
    invocation_type: RequestResponse
plugin: aws-lambda

This results in only the POST route being created.

The Ingress Controller does create the resources - acknowledged by the logs and by querying kubectl get ing -n kong or kubectl get kongingress -n kong, however, they are not created in the database.

Kong Ingress controller version
0.2.2

Kong or Kong Enterprise version
0.14

Kubernetes version

Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.0", GitCommit:"925c127ec6b946659ad0fd596fa959be43f0cc05", GitTreeState:"clean", BuildDate:"2017-12-16T03:15:38Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.8", GitCommit:"7eab6a49736cc7b01869a15f9f05dc5b49efb9fc", GitTreeState:"clean", BuildDate:"2018-09-14T15:54:20Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

Environment

  • Cloud provider or hardware configuration: AWS
  • OS (e.g. from /etc/os-release): Debian GNU/Linux 8 (jessie)
  • Kernel (e.g. uname -a): 4.4.121-k8s Status of controller? #1 SMP Sun Mar 11 19:39:47 UTC 2018 x86_64 GNU/Linux
  • Install tools: Kops Version 1.10.0

What happened

Only a single route is created, additional routes are ignored.

Expected behvaior

Multiple routes should be created. We are able to successfully configure this setup using vanilla kong (non-ingress) and the Admin REST API

Steps To Reproduce

  1. Create 2 lambda functions
  2. Create 2 ingress routes
  3. Configure ingress routes to use AWS-Lambda plugin pointing to separate functions in (1)
  4. Configure ingress routes to use different methods using KongIngress resource

Look at the underlying database or curl the kong admin api to list routes - only one is created

@hbagdi
Copy link
Member

hbagdi commented Dec 6, 2018

Thanks for the report @justinrcs!

Currently, the sync logic for Routes doesn't take into account methods and hence you're running into this problem.
We will be fixing this in the next release.

@hbagdi hbagdi self-assigned this Dec 19, 2018
@hbagdi hbagdi added the bug Something isn't working label Dec 19, 2018
@hbagdi
Copy link
Member

hbagdi commented Mar 8, 2019

This will be fixed as part of #241.
It is currently not possible to fix this problem without a refactor since we squash all the Ingress rules with the same path.

hbagdi added a commit that referenced this issue Apr 1, 2019
Breaking changes
-  KongIngress overrides for Service and Upstream will now be picked up
  from annotation on the service and not the route.

Changelog:
- Directly translate to Kong configuration objects
  Previously, the Ingress rules were parsed into Nginx Server and
  Location blocks, and then translated to Kong configuration. This was
  more complicated and information was lost during translation.
- Translation is now done to an intermediate Kong state and then further
  translated to the final format. The final format will differ, based on
  if Kong is running in a db or a db-less mode.
- Method based routes are now supported (#202)
- Default backend in Ingress rules is now respected and a default
  fallback route in Kong will be created if a default backend exists in
  one of the Ingress objects. If multiple Ingress objects have a default
  backed, the Ingress created first will be respected.

Fix #202
Fix #241
@hbagdi
Copy link
Member

hbagdi commented Apr 5, 2019

This is fixed with #241 and support will be available in the next release.

@hbagdi hbagdi added the work in progress Work In Progress label Apr 6, 2019
@hbagdi hbagdi closed this as completed in 09fb67c Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working work in progress Work In Progress
Projects
None yet
Development

No branches or pull requests

2 participants