How exactly kube-proxy works: Basics on Kubernetes.

In recent times Kubernetes is becoming a de facto tool to be used and it adds a lot of value to your profile if you have a good understanding of it. Unfortunately, the way clouds have abstracted everything from users, there are not many people aware of how this actually works behind the scene and is actually using a very basic concept of networking instead of doing anything fancy.

What is the job of kube-proxy?

The main task of Kube-proxy is making configurations so that packets can reach their destination when you call a service and not routing the packets. This must be clear to you, in the very basic configuration, when you talk about kube-proxy it doesn’t route the packets, it makes configuration so that packet can reach the destination.

What configuration does it make?

Kube-proxy creates iptables rules for the services that are created.

Kube proxy runs on each node and talks to api-server to get the details of the services and endpoints present. Based on this information, kube-proxy creates entries in iptables, which then routes the packets to the correct destination.

When you create any service in Kubernetes, the traffic can come on any of the nodes, and then its iptables will route the packet to the correct node and after that, it can reach the correct pod.

This post will not talk about a lot in depth how it is implemented. This was intended to give you a direction and to make you aware that kube-proxy uses iptables and ipvs behind the scenes to enable packets to reach their correct destination.

If you like the article please share and subscribe.


Gaurav Yadav

Gaurav is cloud infrastructure engineer and a full stack web developer and blogger. Sportsperson by heart and loves football. Scale is something he loves to work for and always keen to learn new tech. Experienced with CI/CD, distributed cloud infrastructure, build systems and lot of SRE Stuff.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.