Kubernetes: Routing non HTTP Request via Ingress to Container

Matthias M picture Matthias M · Mar 23, 2018 · Viewed 17.7k times · Source
  1. I use a local kubernetes bundled with docker on Mac OS.
  2. I've installed the nginx-ingress-controller.
  3. I manged to send external http request via ingress to my kubernetes managed containers (e.g. from my local browser). All request are sent via the nginx ports 80 or 443.

The problem is, that I can only route http or https requests via my ngnix controller. How can I send non HTTP Requests (e.g. database or corba) via ingress to my containers?

Answer

stacksonstacks picture stacksonstacks · Mar 23, 2018

This is not well supported via the ingress mechanism and is an open issue.
There is a work around for tcp or udp traffic using nginx-ingress which will map an exposed port to a kubernetes service using a configmap.
See this doc.

Start the ingress controller with the tcp-services-configmap (and/or udp-services-configmap) argument.

args: 
- "/nginx-ingress-controller"
- "--tcp-services-configmap=default/nginx-tcp-configmap"
- "--v=2"

deploy configmap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-tcp-configmap
data:
  9000: "default/example-service:8080"

where 9000 is the exposed port and 8080 is the service port