Kubernetes Services Explained
A Kubernetes Service gives stable networking to a group of pods. It solves the problem of changing pod IPs and provides service discovery inside the cluster.
Quick answer
ClusterIP
Internal service inside the cluster.
NodePort
Exposes service on a port on each node.
LoadBalancer
Creates an external load balancer in supported cloud environments.
ClusterIP service example
apiVersion: v1 kind: Service metadata: name: nginx-service spec: type: ClusterIP selector: app: nginx ports: - port: 80 targetPort: 80
NodePort service example
apiVersion: v1 kind: Service metadata: name: nginx-nodeport spec: type: NodePort selector: app: nginx ports: - port: 80 targetPort: 80 nodePort: 30080
Commands
kubectl get svc kubectl describe svc nginx-service kubectl get endpoints nginx-service kubectl port-forward svc/nginx-service 8080:80
Service DNS
Pods can usually access a service by service name inside the same namespace.
curl
Common mistakes
- Selector labels do not match pod labels.
- Confusing service port and targetPort.
- Using NodePort for production without understanding network exposure.
- Expecting LoadBalancer to work in local clusters without a load balancer implementation.
Best practices
- Use ClusterIP for internal communication.
- Use Ingress for HTTP/HTTPS routing when suitable.
- Use clear labels and selectors.
- Check endpoints when traffic is not reaching pods.
Related Melochip guides
- Kubernetes Learning Path
- Docker Networks Explained
Official references
- Kubernetes Services documentation
Join the discussion
0 CommentsAsk questions, add context, or share what worked.
More from Melochip Editorial
Learn what Playwright testing is, why modern QA teams use it, how testers can get started, and the major types...
7 min read · Sep 19, 2026
Learn how Kubernetes Deployments and ReplicaSets work with practical YAML, scaling, self-healing, rolling upda...
7 min read · Sep 17, 2026
Learn Kubernetes security best practices with RBAC, Secrets, ServiceAccounts, Pod securityContext, NetworkPoli...
6 min read · Sep 17, 2026Related articles
Learn how Kubernetes Deployments and ReplicaSets work with practical YAML, scaling, self-healing, rolling upda...
7 min read · Sep 17, 2026
Learn Kubernetes Ingress with controllers, IngressClass, host and path routing, TLS, DNS, annotations, redirec...
8 min read · Sep 17, 2026
Learn Kubernetes monitoring and logs with kubectl logs, events, metrics-server, top commands, Prometheus, Graf...
5 min read · Sep 17, 2026
Learn Kubernetes ConfigMaps and Secrets with YAML, environment variables, file mounts, update behavior, immuta...
8 min read · Sep 17, 2026Stay in the loop. Get new Melochip articles
Receive Melochip article updates when new articles are available. Explicit opt-in only.
No comments yet. Start the discussion.