Kubernetes service endpoints IP with hostnetwork and two networks on host

9/23/2018

I have some hosts with 2 interfaces. Also, I have deamonset with hostnetwork and service for it. Kubernetes uses one interface for work, but my app uses other.

In the service endpoints I see the IP of the first interface, how can I change it to the second IP without changing the endpoint manifest by hand?

-- Андрей Федюнин
kubernetes
networking

1 Answer

9/24/2018

The brief explanation of ways to access Kubernetes Pods from outside of the cluster can be found here.

Only the Nodeport option allows you to select the desired interface.

There is a kube-proxy flag for selecting NodePort IP range introduced by PR #58052.

You can find more information in the design-proposals and the official documentation:

If you want to specify particular IP(s) to proxy the port, you can set the --nodeport-addresses flag in kube-proxy to particular IP block(s) (which is supported since Kubernetes v1.10). A comma-delimited list of IP blocks (e.g. 10.0.0.0/8, 1.2.3.4/32) is used to filter addresses local to this node. For example, if you start kube-proxy with flag --nodeport-addresses=127.0.0.0/8, kube-proxy will select only the loopback interface for NodePort Services. The --nodeport-addresses is defaulted to empty ([]), which means select all available interfaces and is in compliance with current NodePort behaviors.

-- VAS
Source: StackOverflow