What happens when a visitor opens your app on Kubernetes
Kubernetes Service: one address that stays while pods come and go
In Kubernetes, pods are replaced all the time. Other apps still have to find them. They need one name and one address that never change, even when the pods behind them do.
-
1
Pods come and go, and their addresses go with them. Yet one thing on all your pods never changes.
-
2
Each one carries the sticker "app: cafe-menu". You wrote it in your app's file, and Kubernetes puts it on every pod it starts from that file. This sticker is called a label.
-
3
So you ask Kubernetes for a Service: one name and one address that stand for every pod with that label. Both stay as long as the Service exists.
-
4
The order app writes the Service's address on its note. Its requests go there, and the menu comes back from one of your pods.
-
5
When a pod is replaced, the new one carries the label too, and the Service stands for it. The note stays right.
-
6
Now look for the Service's address. No pod has it, and no single computer answers to it. Yet requests sent there get the menu. Where do they go?
-
Quick check
Rono's café gets busy.
Show the answer
No. The 2 new pods carry the label, so the Service stands for them too, and its address stays the same.
-
Go further
The real names of the Service.