☸️Kubernetes Service
Also known as K8s Service, Service (Kubernetes), ClusterIP
A steady name and address for a changing group of pods. It shares traffic among them.
Think of it like
It is like a shop's phone number. The staff change shifts, but you always call the same number.
Example
Jack's web pods call the database through a service named db. The database pod is replaced twice in a week, and the web pods never notice.
Why it matters
With no service, each app would have to chase the new address of each pod it calls.
Definition
Example code
yaml
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app.kubernetes.io/name: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 9376Common mistake
Key takeaways
- 1Steady address. The name stays while pods change.
- 2Picks by label. It finds pods that carry its label.
- 3Shares the load. Requests are spread across the pods.