Forward IP range to Kubernetes node running in Vagrant/VirtualBox

11/12/2018

I have a 3-node Kubernetes cluster setup with Vagrant/Virtualbox. I am setting up a 4th VM that is not attached to the cluster.

I want to configure my 4th node so that it routes all traffic in the Service IP CIDR to a node on the Kubernetes cluster. The specific node doesn't matter since once traffic hits a node it will route to the correct pod as I expect.

For example, let's say I deploy a Rabbit broker on my k8s cluster behind a Service with IP 10.0.0.5 and my cluster service CIDR is 10.0.0.0/24. On my 4th VM, I set up a python script to publish messages to 10.0.0.5. However, 10.0.0.5 is virtual since it is a Service ClusterIP and therefore doesn't know how to route. I want to add a routing rule to automatically send 10.0.0.0/24 traffic to any of the 3 nodes in my cluster.

Can anyone help me out?

-- bfink
kubernetes
routing
vagrant
virtualbox

1 Answer

11/12/2018

Although you might be able to make routing working with route tables and iptables, I would recommend using a NodePort type of service so that you talk to the IP address of your nodes and not a Virtual IP that is only available within the cluster.

-- Rico
Source: StackOverflow