kubernetes-ingress-controller: Plugin annotations do not work with multiple hosts

Kong Ingress controller version: kong:0.13.1-centos

Kubernetes version (use kubectl version): v1.9.3

What happened: I have an ingress with multiple host matches on it (which turns into routes in Kong) and have now added a handful of plugin annotations to it. This resulted in one of the routes receiving all but one of the plugins and the other route receiving the other.

What you expected to happen: All host/routes would have the plugins applied.

How to reproduce it (as minimally and precisely as possible):

apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: add-request-id
config:
  header_name: Request-ID

---

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-test
  annotations:
    correlation-id.plugin.konghq.com: add-request-id
spec:
  rules:
  - host: test1.com
    http: &http_rules
      paths:
      - path: /mypath
        backend:
          serviceName: myservice
          servicePort: 80
  - host: test2.com
    http: *http_rules
  - host: test3.com
    http: *http_rules

Apply the above and see that /routes shows a unique id for each of the host above and that /plugins shows that each plugin appears only once and is bound to a single route_id.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (14 by maintainers)

Commits related to this issue

Most upvoted comments

Ah, that makes sense. I didn’t realize they’d actually be applied at the service level in kong. That might be more fitting for my use-case anyway from a logical perspective since each domain/entrypoint never uses different plugins.

So the re-use of plugins works with Service annotations, but not Ingress? That seems to be what @dag24 is saying but I would have expected similar behavior based on the problem’s description.

You can’t reuse plugin configurations in services either but you can apply the plugin at the service level instead of route level using an annotation in the k8s service.

Last question (because I’m derailing here): until labels are added, which resources are unsafe to manually add? I assume I can probably manually configure the global plugins at least and save 100s of resources here.

I’m sorry to say but you shouldn’t manage any resource manually in Kong when you’re using Kong as an Ingress controller. At this point, the only resort here is to temporarily create all KongPlugin resources. We will be trying to figure out an approach to make it possible to create global plugins via the ingress controller for the short term but in future, KongPlugin resources will be reusable.

@jaygorrell,

I can’t provide a timeline for this feature yet but this is something that would solve multiple problems.

Alternatively, is there a way to add a global plugin with Kubernetes Ingress? That would help a lot.

Unfortunately no. There is no mechanism to apply global plugins via the ingress controller yet. Stay tuned, this might be a smaller problem to solve.