Is it possible to join a hardware in the same subnet with Kubernetes pods?

8/15/2017

I have setup a Kubernetes cluster with flannel network on bare metal. I have a service deployed and running in the cluster. The service would broadcast to discover the other end devices in the same subnet.

The problem is that the client agents which receives the broadcasts are running on resource-constrained hardware. These devices are running in the same subnet with the Master and Worker Nodes. The deployed service in pods (netmask: 10.244.0.0/16) are unable to discover the clients running in the Host OS subnet (netmask: 192.168.0.0/24). How to join the clients in the pods' subnet?

Any help is appreciate.

-- ichbinblau
kubernetes
networking

2 Answers

8/15/2017

The issue is that they are actually in different subnets: the pod network and the bare-metal network. Therefore you would have to check what options are available for service discovery between different subnets. Some propose the use of a tracker (just like P2P networks work) https://serverfault.com/a/304344/380575.

You could also try adding external services/endpoints to the services running outside the cluster, but I am quite uncertain that this could work.

Bottom line: If you need services in other subnets, you can either use a tracker or create static endpoints to them.

-- Javier Salmeron
Source: StackOverflow

9/27/2017

I ended up making the host and pods running in the same subnet by adding hostNetwork: true in pod configuration. In that case, containers are using host network. Inspired from here

The configuration looks like:

apiVersion: v1
kind: ReplicationController
metadata:
 name: worker
 namespace: default
spec:
 replicas: 4
 selector:
   name: worker
 template:
   metadata:
     labels:
       name: worker
 spec:
    hostNetwork: true
    containers:
       - image: 10.0.0.1:5000/worker
         name: worker
         imagePullPolicy: IfNotPresent
-- ichbinblau
Source: StackOverflow