Skip to main content
mid
intermediate
Kubernetes

Kubernetes Services and Networking

Question

Explain the different types of Kubernetes Services (ClusterIP, NodePort, LoadBalancer) and when to use each.

Answer

ClusterIP (default) exposes the service on an internal IP, accessible only within the cluster - use for internal communication between pods. NodePort exposes the service on each node's IP at a static port (30000-32767) - use for development or when you manage your own load balancer. LoadBalancer provisions an external load balancer (in cloud environments) - use for production external traffic. Ingress is not a service type but a separate resource for HTTP/HTTPS routing with a single entry point.

Why This Matters

Kubernetes networking is essential for connecting microservices and exposing applications. Understanding service types helps architects design secure, scalable systems and troubleshoot connectivity issues efficiently.

Code Examples

Kubernetes Service types

yaml
Common Mistakes
  • Using LoadBalancer for every service (costly and unnecessary)
  • Confusing targetPort with port
  • Not understanding that NodePort opens ports on ALL nodes
Follow-up Questions
Interviewers often ask these as follow-up questions
  • What is the difference between port, targetPort, and nodePort?
  • How does kube-proxy handle service traffic?
  • When would you use an Ingress instead of a LoadBalancer service?
Tags
kubernetes
networking
services
ingress
load-balancing