Tuesday, September 3, 2019

Minikube TCP ingress

I've been playing around with Minikube to setup a local, single-node kubernetes cluster. But it wasn't obvious how to open a tcp to connect to a service running in the cluster.

1. Enable the minikube ingress addon. This installs a ingress-nginx controller for you in the kube-system namespace

minikube addons enable ingress

2. The ingress-nginx supports proxying tcp ports (see the docs for details), we jsut need to edit the configmap created by the minikube to forward the correct ports.

Here is an example adding tcp ingress from port 5432, to a default/postgres service on port 5432:


3. By default, the minikube ingress addon sets up ingres-nginx to use the internal network, so the ports are still not exposed to clients outside the cluster. One way around this is the change the ingress pod to use the host neowork, so the nginx listens of the host's network interface. The docs go over the pros and cons of using host ports, but it worked for my use case.

Enable host network for ingress controller: