Mastodon

Services in Kubernetes

Services provide an abstraction defining a logical set of pods and a policy by which they may be accessed. Pods are targeted by a Service as defined by a selector. For example, suppose you have a set of Pods that each listen on TCP port 9376 and carry a label app=MyApp:

apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 9376

This specification creates a new Service object named “my-service”, which targets TCP port 9376 on any Pod with the app=MyApp label.

References

Service - Kubernetes #kubernetes

Tags: kubernetes