Junior — Middle
Can you explain the differences between NodePort and ClusterIP service types in Kubernetes?
sobes.tech AI
Answer from AI
In Kubernetes, services of type ClusterIP and NodePort differ in the way they provide access to pods:
-
ClusterIP is a service accessible only within the cluster. It creates a virtual IP address that pods inside the cluster can communicate with. External access is not possible directly through this IP.
-
NodePort is an extension of ClusterIP that opens a fixed port on each node of the cluster. This port can be used to access the service from outside the cluster, using the IP of any node and this port.
Example:
- ClusterIP: the service is only accessible inside the cluster via IP 10.0.0.1
- NodePort: the service is accessible from outside via the node's IP (e.g., 192.168.1.10) and port 30080
Thus, NodePort allows external clients to access the service, while ClusterIP is only for internal cluster components.