What does a Kubernetes Service provide?
Options
- Persistent storage that keeps its data when a pod restarts
- A stable IP or DNS name that load-balances across the matching pods (Correct option)
- Container image builds triggered from a Git repository
- Encryption of the secrets stored in the cluster
Answer
A stable virtual IP/DNS name that load-balances to a changing set of pods selected by labels
Why
Pods come and go with changing IPs, so other apps cannot rely on them directly.
A Service gives a stable name (e.g. http://orders) and spreads traffic across all healthy Pods that have the matching labels.
Types: ClusterIP (internal only), NodePort, LoadBalancer (external). An Ingress routes outside HTTP traffic to Services.
Remember
Service = stable address in front of changing Pods.