A service router for a home scale Kubernetes cluster and alike
50K+
This project is in hot development. Everything might change, most of it is still difficult to use.
I use this service to run a "private virtual network" within my home network so I can expose services running on my Raspberry Pi Kubernetes cluster to my local network almost like with a real ingress controller like Traefik combined with a cloud DNS provider.
The Linux backend uses the ip command to add additional IP addresses to a network interface and the iptables
command to redirect traffic towards those IPs to the actual address and port. This allows the service to redirect any
port no matter if it is already bound to 0.0.0.0 on the host. As a side effect it might also be more efficient than
redirection through userspace, with fewer context switches ;-)
The built-in DNS server resolves hostnames from configured routes to the allocated virtual IP. I use dnsmasq on my home
network which made it easy to forward queries for *.cloud.home to this service running on the IP 192.168.0.11:
server=/cloud.home/192.168.0.11
There is no integration into Kubernetes yet but it's obviously the point of this thing.
All configuration parameters have to be supplied as environment variables:
STATE_FILENAME location of the file to store configured routes in - default: state.jsonPORT port for the API server to listen on - default: 8080NODES list of IPs of nodes to send traffic to - default: 169.254.123.125 169.254.123.126 169.254.123.127INTERFACE network interface to use for the virtual IPs - default: eth0IPPOOL_PREFIX static part of the IP pool to use for the virtual IPs, pattern has to match AAA.BBB.CCC. -
default: 169.254.123.IPPOOL_HOSTMIN lower boundary of the IP pool - default 100IPPOOL_HOSTMAX upper boundary of the IP pool - default 200DOMAIN DNS domain of the built-in DNS server - default cheap-ingress.localDNS_PORT port for the built-in DNS server to listen on - default 53DEBUG names of modules to show debug output from:
Given:
192.168.0.0/23192.168.0.0/24 block*.cloud.home to 192.168.0.11192.168.1.20 - 192.168.1.2532412--privileged --network=host on a host with the IP 192.168.0.11NODES="192.168.1.20 192.168.1.21 192.168.1.22"
INTERFACE=eth0
IPPOOL_PREFIX=192.168.1.
IPPOOL_HOSTMIN=100
IPPOOL_HOSTMAX=199
DOMAIN=cloud.home
PORT=80
DEBUG=cheap-ingress:*
When:
http POST 192.168.0.11/api/route hostname=futhek port=80 protocol=tcp nodePort=32412
Then:
http://futhek.cloud.home/docker pull timotto/cheap-ingress:latest