Skip to main content

Services Introduction

A Service is used to connect applications together by exposing a network application (Pod) in the cluster. The internal Pod network is in the range of 10.244.0.0.
Use kubectl describe pods/<pod-name> to get the pod IP address.
Kubernetes has three default service types:
TypeDescription
ClusterIPCreates a virtual IP for enabling communication between different services within the cluster.
NodePortExposes an application to external clients by opening a port on worker nodes.
LoadBalancerSupports external load balancers and distributes network traffic across multiple instances.

Service Types

Each pod has its own IP address, but these IPs are not static — pods can restart at any time and get new IPs. With ClusterIP, each service is assigned a stable name and IP address inside the cluster. Other pods can use either the service name or cluster IP to access the service.This is the default service type.
service.yaml
apiVersion: v1
kind: Service
metadata:
  name: backend-service
spec:
  selector:
    app: backend
  type: ClusterIP
  ports:
    - targetPort: 8080  # Port that the Pod exposes
      port: 8000        # Service port

Build docs developers (and LLMs) love