Feature request: ingress controller to support kong which lives outside the kubernetes cluster

I’m considering a use case where kong is deployed outside the kubernetes cluster. Now the ingress controller can add routes and services in Kong. However, it cannot find the correct upstream endpoints. In https://github.com/Kong/kubernetes-ingress-controller/blob/master/internal/ingress/controller/endpoints.go#L31 the endpoints are just IP addresses of the pods.

When the Kong service is outside the kubernetes cluster, it cannot reach the endpoints using pod IPs. I have an idea for this case:

  1. The service can have type NodePort. This opens a port 3xxxx on each node of the kubernetes cluster.
  2. For the endpoint list, we use : where IP is the node IP, and port is the 3xxxx port.

This deployment may sound weird. It’s useful in a few cases. I have a few examples:

  1. While the kubernetes cluster is using IPv4, and the services should be reached by IPv6 clients. In this case, we can run Kong in an IPv4/IPv6 dual stack server outside the kubernetes cluster, and ask the ingress controller to set up the routes.
  2. While the kubernetes cluster does not have LoadBalancer available, and the service is required to work on a fixed port. We may consider deploying an external API gateway.

Hello @trentzhou,

Welcome to Kong Nation!

The use cases are indeed valid.
While it would be possible to change Ingress Controller to only populate routes and services and skip configuring upstreams and targets, how would you a user go about configuring upstreams and targets?

Have you considered using Kong’s native declarative configuration or other configuration tool to configure Kong, since it’s running outside your k8s cluster?

Thanks @hbagdi for the tips. I’m going to try your solutions.
Anyway, if the upstreams can be set up automatically, that would be nice.

I just tried to build kong ingress controller, but I failed to compile.
I used command “go get github.com/kong/kubernetes-ingress-controller/cli/ingress-controller”, and the error was:

github.com/kong/kubernetes-ingress-controller/internal/ingress/status

src/github.com/kong/kubernetes-ingress-controller/internal/ingress/status/status.go:105:15: not enough arguments in call to s.elector.Run
have ()
want (context.Context)
src/github.com/kong/kubernetes-ingress-controller/internal/ingress/status/status.go:201:3: cannot use func literal (type func(<-chan struct {})) as type func(context.Context) in field value

The file status.go has not been updated for about a year. Now https://github.com/kubernetes/client-go/blob/master/tools/leaderelection/leaderelection.go#L172 has changed the function signature.

Please use dep to use manage the dependency. make deps will vendor the dependency for you and you should be able to build the Ingress Controller.