Exposing TCP and UDP ports through ingress NGINX

· Mik's TIL

#kubernetes

It is possible to expose ports other than 80 and 443 through the NGINX ingress in Kubernetes.

An example where this is needed is a DNS server which uses port 53 on both TCP and UDP. Pi-hole is a widely self-hosted DNS server that also works as an ad-blocker.

The way to expose those ports is, in a couple of points:

  1. Define the app that implements the service and exposes the ports to the cluster via a Kubernetes service;
  2. Configure the NGINX ingress controller to accept incoming requests from the ports, and forward them to the service.

There are a couple of caveats:

Source: https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/