How to attach VLAN to a kubernetes pod?

5/8/2020

I have an environment where we have a bare metal Server(Server 1) whose NIC is configured to pass VLAN 5 traffic.

CentOS is deployed on this server. Now I have a kubernetes pod on top of this, running DHCP service.

Now I have another server (Server 2) on the same VLAN 5 which has to get IP from the DHCP service I mentioned above.

When DHCP request comes from the Server 2, It will reach Server 1 since Server 1 is configured to pass VLAN 5.

But how do I make this request reach my DHCP service pod running on CentOS? How should I configure this pod's network?

-- Pavan Rajan
kubernetes
kubernetes-networking
kubernetes-networkpolicy
kubernetes-pod
vlan

1 Answer

5/12/2020

If I understood you right, you have deployed a DHCP-Server Pod.

It is needed to expose the DHCP service. Right now it looks like the Pod hasn't been exposed. There is a concept of Service in Kubernetes which is an abstract way to expose an application running on a set of Pods as a network service.

There are different types of services. One of them is a NodePort.

NodePort: Exposes the Service on each Node’s IP at a static port (the NodePort). A ClusterIP Service, to which the NodePort Service routes, is automatically created. You’ll be able to contact the NodePort Service, from outside the cluster, by requesting <NodeIP>:<NodePort>.

The caveat is that normally you can only use ports 30000–32767 (which aren't used by DHCP protocol).

That is why it is needed to re-route incoming DHCP-requests from port 67 to the port used by NodePort service ( iptables redirect for example).

Hope that helps.

-- Nick
Source: StackOverflow