Service / Endpoint
a) Why is the service DNS not reachable after creating service?? curl nginx.default.svc.cluster.local
Useful Links
Architecture
Detailed Description
In Kubernetes, a Service is a way to expose an application running inside a set of Pods as a network service. It provides a stable IP address and DNS name, allowing access either from outside the cluster or from other Pods within the cluster. A Service serves as an abstraction layer, connecting clients to the appropriate Pods, ensuring that the actual Pods behind the Service can change without disrupting access.
There are different types of Services in Kubernetes, including:
- ClusterIP: The default service type that assigns an internal IP, reachable only within the cluster. It allows communication between Pods inside the cluster. Kube-Proxy load balances traffic across pods behind a ClusterIP Service.
- NodePort: Exposes the service on a static port across all nodes in the cluster, allowing external traffic to access the service.
- LoadBalancer: In cloud environments, this service type provisions an external load balancer to distribute traffic to multiple Pods.
- ExternalName: Maps a service to an external DNS name, allowing Kubernetes services to refer to external resources.
- Headless Service: A type of ClusterIP service with no assigned IP. It allows direct access to Pods without a proxy.
Endpoints are associated with a Service and represent the IP addresses of the Pods that match the Service's selector. When a Service is created, Kubernetes automatically creates Endpoints for it, enabling traffic forwarding to the correct Pods.
Command Reference Guide
Cluster IP
NodePort:
LoadBalancer
ExternalName
Headless Service
Hints
When accessing an external IP (e.g., Node1's external IP), the hostname and IP displayed on the website may not change. To test Kubernetes' load-balancing behavior, cordon Node1 and delete the pod running on it. When you call Node1's IP again, kube-proxy will reroute the traffic to a healthy pod on another node.
No Comments