Most asked Kubernetes interview question:
Explain services in Kubernetes and which you use ?
Read it for simple explanation: 👇
- Pods in Kubernetes are temporary.
- They get created, destroyed, and replaced anytime.
- So how do apps connect reliably?
👉 Services.
A Service provides a stable endpoint to access a group of Pods even when Pod IPs change.
⚙️ 4 Main Kubernetes Service Types:
1️⃣ ClusterIP (Default)
• Internal IP
• Accessible only inside the cluster
• Used for service-to-service communication
Example: Backend API → Database
2️⃣ NodePort
• Exposes the Service on each Node’s port
• Access via: NodeIP:NodePort
• Common for testing & demos
Example: Access app in browser using node IP
3️⃣ LoadBalancer (imp)
• Creates a cloud load balancer (AWS / Azure / GCP)
• Provides public IP
• Used for production workloads
Example: Public web application
4️⃣ ExternalName
• Maps Service to external DNS
• Connects Kubernetes apps to external services
Example: External database
Why Services Matter:
Without Services:
❌ Pod IPs keep changing
❌ Apps lose connectivity
With Services:
✅ Stable endpoint
✅ Built-in load balancing
✅ Service discovery
✅ Reliable communication
In real production environments, ClusterIP + LoadBalancer are the most commonly used combination.
Which service type you used ??
Comments
Post a Comment