[Kubernetes] Service & Service Types

1 minute read


Service & Service Types

  • Service: a stable address for pods(i.e an endpoint that is consistent so that other things(in and outside the cluster) can access it)
    • pods don’t have a DNS name automatically when created, needs to create a service on top of them
    • CoreDNS resolve services by name
  • There are different types of services
    • ClusterIP
    • NodePort
    • LoadBalancer
    • ExternalName
  • Kubernetes Ingress: Specifically designed for HTTP traffic (inbound to the cluster)

Service Types

ClusterIP

  • default
  • Single, internal virtual IP allocated
  • only reachable from within cluster(nodes & pods, i.e. one set of pods connecting to other set of pods)
  • pods can reach service via apps port number
  • always avaiable in k8s

NodePort

  • allows connection outside the cluster through the IP address of the nodes
  • high port allocated on each node
  • port is open on every node’s IP
  • Anyone can connect (if they can reach the node)
  • Other pods need to be updated to this port
  • always avaiable in k8s

LoadBalancer

  • controls a LB endpoint external to the cluster
  • only available when infra porvider give a LB(e.g. AWS ELB, etc)
    • mostly used in the cloud
  • created NodePort + ClusterIP services, tells LB to send to NodePort

ExternalName

  • used less often
  • not about inbound, rather for outbound
  • adds CNAME DNS record to CoreDNS only
  • Not used for Pods, but for giving pods as DNS name to use for something outside k8s

ref