Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes kube-proxy mechanism

In Kubernetes, let’s say we have three pods, which are physically hosted on Node X, Y and Z. When I expose them as a service using ‘kubectl expose’, are all nodes in the cluster (in addition to X, Y and Z) configured the same way? Specifically, kube-proxy in each node within the cluster watches the apiserver, builds a bunch of iptables rules and references the portal IP (chosen by apiserver), and inserts those rules to the node which it lives on?

I assume the reason it has to be done on all nodes is that the cluster has no idea from which node the client would come from to hit the portal IP?

like image 258
user3290431 Avatar asked Jun 01 '17 15:06

user3290431


1 Answers

You are correct. The portal network (aka service network, cluster network) has no network interface but is a collection of iptables rules managed by kube-proxy. Each node needs to have these rules as a pod on any of them could connect any portal IP (aka service IP, cluster IP).

Read more here: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies

like image 50
Janos Lenart Avatar answered Nov 15 '22 11:11

Janos Lenart