Kubernetes Service
The Service API, part of Kubernetes, is an abstraction to help you expose groups of Pods over a network. Each Service object defines a logical set of endpoints (usually these endpoints are Pods) along with a policy about how to make those pods accessible.
A Kubernetes Service enables reliable communication between Pods or external clients and workloads. Its key components include:
1. ????????????????: Identifies target Pods using labels, such as ??????: ????????-??????.
?
2. ??????????????????: Tracks the IP addresses and ports of Pods selected by the Service, ensuring updated routing as Pods change.
?
3. ?????????????? ????: A virtual, stable IP address assigned to the Service, used for communication within the cluster.
?
4. ???????? ??????????????????????????: Maps the Service's external port (????????) to the container's internal port (????????????????????), and optionally to a Node's port (????????????????).
?
5. ????????: Determines how the Service is exposed.
?
Options include:
- ?????????????????? (default) for internal communication.
- ???????????????? for access via a Node's IP.
- ???????????????????????? for external access via a cloud provider.
- ???????????????????????? to map to an external DNS name.
?
6. ?????????????? ??????????: Managed by kube-proxy, it routes traffic to Pods, ensuring load balancing and fault tolerance.
?
Example to Create Service and Deploy Pods on Kubernetes:
?
Step 1) Creation of Replica set yaml file and pod creation:
?
?
Step2) Create Service with name – mysvc.yaml
?
Step3) Change Service type to NodePort to access Application outside Cluster:
?
?
Step4) ?Access Application Outside Cluster using NodePort Port Number :
?
?