Skip to content

Plugin precedence of route + service over consumer not working #14726

@CharlieC3

Description

@CharlieC3

Is there an existing issue for this?

  • I have searched the existing issues

Kong version ($ kong version)

3.9.1

Current Behavior

In Kubernetes 1.32, when I configure the ratelimit plugin (A) on a KongConsumer, and then configure a different ratelimit plugin (B) on an Ingress and Service, hitting a backend pod which uses this Ingress and Service while authenticated as the KongConsumer shows ratelimit plugin A was used instead of ratelimit plugin B.

Expected Behavior

According to the plugin precedence order, plugins configured on a Route (Ingress) + Service should take precedence over plugins only configured on a Consumer. As such, ratelimit plugin B should have been selected for these requests.

Steps To Reproduce

  1. Create two ratelimit KongClusterPlugins, A and B, which have different ratelimit settings (second,minute, month). Also create an auth KongClusterPlugin for identity, like key-auth.
  2. Create a KongConsumer, Ingress, and Service. The KongConsumer should use plugin A and a configured key-auth plugin for identification, while the Ingress and Service should use plugin B.
  3. Send a request which hits the configured Ingress and Service, using a credential configured in the KongConsumer.

Anything else?

I also posted this in the KIC repo, but am cross-posting it here because this may be more of a gateway issue (I'm not sure).

There are no errors in the KIC with this setup, and the Kong Admin shows the Service, Route, and Consumer are configured as expected.

Here are some example configs that can be used or referenced to reproduce the bug:

apiVersion: configuration.konghq.com/v1
config:
  minute: 900
  month: 15000
  policy: redis
  redis:
    host: my-redis-server
  second: 40
disabled: false
kind: KongClusterPlugin
metadata:
  annotations:
    kubernetes.io/ingress.class: kong
  name: rate-limiting-free
plugin: rate-limiting
---
apiVersion: configuration.konghq.com/v1
config:
  minute: 500
  policy: redis
  redis:
    host: my-redis-server
  second: 40
disabled: false
kind: KongClusterPlugin
metadata:
  annotations:
    kubernetes.io/ingress.class: kong
  name: rate-limiting-bronze
plugin: rate-limiting
---
apiVersion: configuration.konghq.com/v1
config:
  anonymous: anonymous
  hide_credentials: true
  key_names:
  - x-api-key
disabled: false
kind: KongClusterPlugin
metadata:
  annotations:
    kubernetes.io/ingress.class: kong
  labels:
    global: "true"
  name: key-auth-global
plugin: key-auth
---
apiVersion: configuration.konghq.com/v1
credentials:
- key-example-consumer
kind: KongConsumer
metadata:
  annotations:
    konghq.com/plugins: rate-limiting-free
    kubernetes.io/ingress.class: kong
  name: example-consumer
  namespace: my-consumer-namespace
---
apiVersion: v1
data:
  # Randomly generated for this example
  key: ODA3ZmJkNWNjZDA3YmRkYjFmODc1OTE2MDg4NWM5ZGI=
kind: Secret
metadata:
  labels:
    konghq.com/credential: key-auth
  name: key-example-consumer
  namespace: my-consumer-namespace
type: Opaque
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    konghq.com/plugins: rate-limiting-bronze
  name: app
  namespace: my-app-namespace
spec:
  ingressClassName: kong
  rules:
  - host: test.example.com
    http:
      paths:
      - backend:
          service:
            name: app
            port:
              number: 3000
        path: /
        pathType: Prefix
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    konghq.com/plugins: rate-limiting-bronze
  name: app
  namespace: my-app-namespace
spec:
  internalTrafficPolicy: Cluster
  ipFamilies:
  - IPv4
  ipFamilyPolicy: SingleStack
  ports:
  - name: http
    port: 3000
    protocol: TCP
    targetPort: http
  selector:
    app.kubernetes.io/name: app
  sessionAffinity: None
  type: ClusterIP

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending author feedbackWaiting for the issue author to get back to a maintainer with findings, more details, etc...plugins/rate-limiting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions