The author of this article outlines their journey of creating their own Kubernetes and shares some key points and flow they met during development.
They explain that to truly understand how a program works, you need to learn how it is built and try to write it yourself.
They share some prerequisites and a disclaimer before sharing code and demonstrating a running node with kubelet and three pods with a node port service on it.
They explain how a watcher-listener action is implemented in Kubernetes and point to the source code for more details on the pods and watcher-listener creations.
The author then spends more time detailing the creation of the iptables chain of services, with the creation of a ClusterIP service and then a NodePort service.
They explain the creation of endpoints that “point” to a pod and how the kube-proxy listens to new services and endpoint creations, creating a new IPTables chain that masquerades and loads the requests to the pods based on a service selector for load balancing.
They also mention that the kube-proxy has another listener that matches existing endpoints to actions like when an existing pod fails or is deleted and deletes the address in the endpoint.
The author advises readers to go into more detail by exploring the source code under pkg/kube-proxy section.