Roadmap › Kubernetes (K8s) & AKS › Module: Architecture and Core Objects
Lessons in this course (15)

3. Services and service types

Basic★ Must knowLesson 3 of 15

Pods come and go with changing IPs; a Service gives a stable virtual IP and DNS name (shop-api.default.svc.cluster.local, or just shop-api in the same namespace) and load-balances to ready pods matching its selector.

TypeExposesUse
ClusterIP (default)Internal virtual IP onlyService-to-service
NodePortA port (30000–32767) on every nodeTesting, legacy
LoadBalancerCloud load balancer with external IPExpose a service directly (one LB per service)
ExternalNameDNS CNAME to an external hostAlias external services
Headless (clusterIP: None)DNS returns pod IPsStatefulSets, client-side discovery
yaml
apiVersion: v1
kind: Service
metadata: { name: shop-api }
spec:
  type: ClusterIP
  selector: { app: shop-api }
  ports:
    - port: 80          # service port
      targetPort: 8080  # container port