⚡ ~/naveed Interview Prep
⚡ Portfolio Home 👤 About Naveed Bio & Credentials 📫 Contact Naveed Get In Touch ✍️ Engineering Blog Deep Dives 🎯 Interview Hub 1,000+ Scenarios ☸️ Kubernetes Mastery Hub 24 Modules 🎮 DevOps Arcade & Quizzes Subnet Blitz ⚡ 🗺️ DevOps Roadmaps PDFs & Guides 🤖 Morpheus Analysis AI Quant ↗ 🛠️ Developer Tools Utilities 🧪 Labs & Experiments 📄 Interactive CV & Certs 🔗 All Links & Socials ⚡ Join The Dispatch (Weekly SRE Newsletter) →
← Back to All Kubernetes Interview Questions Scenario 187 of 207 in Kubernetes
Senior Cloud Engineer (L2) Kubernetes Networking & Ingress Controllers L2 Cloud Screen

Q: What is the difference between a Kubernetes Service and an Ingress? When would you use each one?

Clear, senior-level distinction between Kubernetes Services (ClusterIP, NodePort, LoadBalancer) and Ingress controllers with real-world architecture examples.

#Kubernetes #Service #Ingress #Layer 4 #Layer 7 #Networking #Architecture
🎙️ Candidate Opening & Architectural Context
"In Kubernetes, a Service operates at Layer 4 (Transport layer - TCP/UDP), providing stable internal networking and load balancing across dynamic pod IP addresses. An Ingress operates at Layer 7 (Application layer - HTTP/HTTPS), acting as an intelligent reverse proxy that routes external internet traffic to internal Services based on hostnames and URL paths."
Advertisement
⚡ Recommended Practice Lab

Want to master this scenario in a live sandbox? KodeKloud's CKA & CKAD Hands-On Certification Track covers this exact problem with hands-on terminal drills.

🛠️ Production Runbook & Step-by-Step Resolution

Direct Answer: In Kubernetes, a Service operates at Layer 4 (Transport layer - TCP/UDP), providing stable internal networking and load balancing across dynamic pod IP addresses. An Ingress operates at Layer 7 (Application layer - HTTP/HTTPS), acting as an intelligent reverse proxy that routes external internet traffic to internal Services based on hostnames and URL paths.

1

Kubernetes Service Types & Layer 4 Mechanics

A Service creates a static virtual IP (ClusterIP) managed by kube-proxy iptables or IPVS rules: - ClusterIP: Exposes the service internally inside the cluster (default). - NodePort: Opens a dedicated static port (30000-32767) on all node IP addresses. - LoadBalancer: Provisions a cloud provider Layer 4 load balancer (AWS NLB / Azure Basic LB). Creating 50 LoadBalancer Services provisions 50 expensive cloud load balancers.

apiVersion: v1
kind: Service
metadata:
  name: payment-service
spec:
  type: ClusterIP
  selector:
    app: payment
  ports:
  - port: 80
    targetPort: 8080
2

Kubernetes Ingress & Layer 7 Routing Mechanics

Ingress is a set of routing rules evaluated by an Ingress Controller (NGINX, Traefik, AWS ALB Controller). It consolidates routing for multiple microservices behind a single public cloud Load Balancer and single public IP address.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: main-ingress
spec:
  rules:
  - host: api.example.com
    http:
      paths:
      - path: /payments
        pathType: Prefix
        backend:
          service:
            name: payment-service
            port:
              number: 80
      - path: /users
        pathType: Prefix
        backend:
          service:
            name: user-service
            port:
              number: 80
Advertisement
3

Key Capabilities Comparison Table

Feature trade-offs: - Protocols: Service handles TCP, UDP, SCTP. Ingress handles HTTP, HTTPS, WebSockets, gRPC. - SSL Termination: Ingress terminates SSL/TLS and manages certs (cert-manager). Services do not terminate SSL. - Path Routing: Ingress routes by domain and URI path (/payments vs /users). Service knows nothing about HTTP paths.

Pro Tip: Cost & Architecture Rule: Never expose multiple web microservices using Service Type LoadBalancer. Expose them internally as ClusterIP Services and unify them under a single Ingress Controller.
4

When to Use Each

- Use ClusterIP Service for internal pod-to-pod communication. - Use Ingress for external web/API traffic needing domain routing, SSL termination, and rate limiting. - Use LoadBalancer Service when exposing non-HTTP Layer 4 traffic (database proxies, gaming UDP servers, MQTT brokers).

💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Service is Layer 4 (TCP/UDP stable IP for pods). Ingress is Layer 7 (HTTP reverse proxy providing SSL termination, host/path routing, and consolidating public entry points behind a single load balancer)."
⚡ 60-Second Elevator Pitch Talking Points
  • A Service operates at Layer 4, providing stable cluster-internal virtual IPs for dynamic pods.
  • An Ingress operates at Layer 7, providing HTTP/HTTPS routing, SSL termination, and path-based routing.
  • Use Ingress to route traffic to multiple internal ClusterIP services behind a single cloud load balancer.
  • Use Type LoadBalancer directly only for non-HTTP Layer 4 workloads like TCP gaming or MQTT.
⛔ Critical Candidate Mistakes to Avoid in This Scenario

Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:

  1. Configuring Service selector labels that mismatch underlying Pod manifest metadata A typo in spec.selector causes the Service endpoints list (kubectl get endpoints) to remain empty, resulting in 503 Service Unavailable or timeouts.
  2. Omitting explicit ingressClassName specifications when running multiple ingress controllers Without an explicit ingressClassName, ingress resources are either ignored or picked up unpredictably by competing controllers.
  3. Depleting worker node subnet IP address allocations under VPC CNI or Azure CNI Direct VPC pod networking allocates real subnet IPs; failing to monitor IP pools causes new pods to stay stuck indefinitely in ContainerCreating.
  4. Attempting network triage without inspecting kubectl describe service and EndpointSlice resources Verifying EndpointSlice population immediately determines whether a connectivity failure is caused by pod labeling, readiness probes, or routing.
Advertisement
📥 FREE DOWNLOAD · 101-PAGE COMPANION HANDBOOK
Studying for Kubernetes & SRE Technical Rounds?
Download the complete 100-question PDF field guide covering all 11 core modules with offline diagnostic runbooks.
📥 Download PDF (Free) Read Online Guide →
Want more Kubernetes scenarios?
Explore our complete collection of scenario-based Kubernetes interview runbooks.
Browse All Kubernetes Questions →