Kong Ingress Set Service Port to something other than 80

I’m trying to use Kong custom resources, like the KongIngress resource, to send information on a post to a webhook directly onto a RabbitMQ exchange. I’m using a custom kong plugin to accomplish this, and everything works fine in a local docker-compose environment, but when I deploy to kubernetes, the plugin registers that it’s sending an amqp request to rabbitmq.default.5672.svc:80. My rabbit service uses port 5672 and the kube service name on the Ingress is rabbitmq, but I want the port to be 5672, not 80. Is there a way to do this? In my local environment I was able to use dbless declarative config in kong to create a kong service with a url of localhost:5672 and it was able to connect to Rabbit, but I suspect the port 80 thing in kubernetes is messing with the ability to connect to Rabbit.

EDIT: If it helps, the custom plugin is showing that kong.router.get_service().host is rabbitmq.default.5672.svc, and kong.router.get_service().port is 80, which I don’t understand.

You can safely that. We have been meaning to fix it but it is a low priority issue. It throws a lot of users off.

The port to be used is present in the targets because Kong is also doing loadbalancing in case of being an Ingress Controller.

The targets, is this something I can set in a kong configuration or a kubernetes ingress resource? Or will I just have to find another way around the plugin?

The targets , is this something I can set in a kong configuration or a kubernetes ingress resource?

No.

What is it you are trying to do?

I am trying to get json data hitting an endpoint, say on example.com/api/v1, and route that data via a custom plugin to communicate that json POSTed data via AMQP to a rabbitmq service on port 5672, in kubernetes. I have kong configured with the custom plugin and working locally using kong’s declarative config to make the Kong service url be localhost:5672. I have the KongIngress resource with the Ingress resource pointing to a backend rabbitmq service with a service port of 5672, which ends up through kube getting a host name of rabbitmq.default.5672.svc, and a port number of 80. I need a way to send the data to 5672, not 80, because the plugin is failing to connect to the backend service with that hostname and port combo.

Can you supply the port and host information as part of the plugin configuration?


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ