back-end), and Kubernetes will distribute traffic across the matching Pods.

Why Use a ClusterIP Service?
| Benefit | Description |
|---|---|
| Stable in-cluster address | Pods reference a single virtual IP and DNS name instead of changing Pod IPs |
| Built-in load balancing | Distributes traffic evenly across all healthy Pods |
| Decoupling components | Front-end, back-end, cache, and DB tiers communicate via service names |
Defining a ClusterIP Service
Createservice-definition.yml to expose your back-end Pods:
By default,
spec.type is ClusterIP. If you omit it, Kubernetes will still create a ClusterIP Service unless you specify another type.Key Fields
| Field | Description |
|---|---|
metadata.name | Name of the Service (DNS name within cluster) |
spec.selector | Labels used to identify the target Pods |
spec.ports | List of ports the Service exposes and routes to |
Pod Definition with Matching Labels
Ensure your Pods carry labels that match the Service’s selector:Deploying and Verifying
Apply the Service and check its status:Links and References
- Kubernetes Services Overview
- Redis Official Site
- MySQL Official Site
- Kubernetes Documentation
- Docker Hub
Avoid mapping Service ports directly to host ports in production; use
ClusterIP for secure, in-cluster traffic and consider Ingress or LoadBalancer types for external access.