Bitzu

KCNA ยท Kubernetes networking

Kubernetes Services and their types

ClusterIP, NodePort, LoadBalancer, ExternalName, headless Services, endpoints and kube-proxy role.

Key points

  • A Service gives a stable virtual IP and DNS name to changing Pods chosen by a label selector.
  • ClusterIP (default): internal only
  • NodePort: opens a port on every node
  • LoadBalancer: asks a cloud provider for an external load balancer
  • ExternalName: returns a CNAME to an outside name
  • Headless (clusterIP: None): no virtual IP, DNS returns Pod IPs
  • kube-proxy on each node programs the rules sending Service traffic to backends

Source: https://kubernetes.io/docs/concepts/services-networking/service/

Practice questions

Single choice

Which Service type is used when you do not set type explicitly?

  1. NodePort
  2. LoadBalancer
  3. ClusterIP
  4. ExternalName
Show answer

Answer: C. ClusterIP

ClusterIP is the default and is reachable only from inside the cluster. NodePort and LoadBalancer must be requested explicitly.

Select all that apply

Which statements about Service types are correct?

  1. NodePort opens the same port number on every node
  2. ExternalName works by returning a CNAME record
  3. ClusterIP is reachable from outside the cluster by default
  4. LoadBalancer always works on any bare-metal cluster with no add-ons
  5. ExternalName selects Pods by label and proxies traffic to them
Show answer

Answer: A. NodePort opens the same port number on every node, B. ExternalName works by returning a CNAME record

NodePort exposes the same port on every node. ExternalName only answers with a CNAME at the DNS level. ClusterIP is internal and LoadBalancer depends on a cloud provider or add-on, so neither statement about them holds.

True or false

True or false: kube-proxy receives each packet sent to a Service IP and forwards it itself, so it sits in the data path.

Show answer

Answer: False

False in the usual modes. kube-proxy watches Services and programs kernel rules (iptables, IPVS or nftables); the kernel does the forwarding.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More KCNA topics in this module