Services and Networking
A Service in Kubernetes is an abstraction that defines a logical set of pods and a policy to access them — typically via a DNS name and stable IP address.
Types of Services:
- ClusterIP: Default; accessible within the cluster
- NodePort: Exposes service on static port on each node
- LoadBalancer: Integrates with cloud provider’s load balancer
Example Service YAML:
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: NodePort
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80