Rancher 2 provides 4 options in the "Ports" section when deploying a new workload:
What are the differences? Especially between NodePort, HostPort and Cluster IP?
The NodePort type is an extension of the ClusterIP type. So a Service of type NodePort has a cluster IP address. The LoadBalancer type is an extension of the NodePort type. So a Service of type LoadBalancer has a cluster IP address and one or more nodePort values.
ClusterIP (default): Internal clients send requests to a stable internal IP address. NodePort: Clients send requests to the IP address of a node on one or more nodePort values that are specified by the Service. LoadBalancer: Clients send requests to the IP address of a network load balancer.
The ClusterIP provides a load-balanced IP address. One or more pods that match a label selector can forward traffic to the IP address. The ClusterIP service must define one or more ports to listen on with target ports to forward TCP/UDP traffic to containers.
A host port is a port on a host that connect it to the storage system, either directly or through a switch. Note: Host ports that were created outside of the DS8000® Storage Management GUI are displayed in the Unassigned Host Ports list and must be assigned to hosts.
HostPort (nodes running a pod): Similiar to docker, this will open a port on the node on which the pod is running (this allows you to open port 80 on the host). This is pretty easy to setup an run, however:
Don’t specify a hostPort for a Pod unless it is absolutely necessary. When you bind a Pod to a hostPort, it limits the number of places the Pod can be scheduled, because each combination must be unique. If you don’t specify the hostIP and protocol explicitly, Kubernetes will use 0.0.0.0 as the default hostIP and TCP as the default protocol. kubernetes.io
NodePort (On every node): Is restricted to ports between port 30,000 to ~33,000. This usually only makes sense in combination with an external loadbalancer (in case you want to publish a web-application on port 80)
If you explicitly need to expose a Pod’s port on the node, consider using a NodePort Service before resorting to hostPort. kubernetes.io
Cluster IP (Internal only): As the description says, this will open a port only available for internal applications running in the same cluster. A service using this option is accessbile via the internal cluster-ip.
Host Port |
Node Port |
Cluster IP |
---|---|---|
When a pod is using a hostPort , a connection to the node’s port is forwarded directly to the pod running on that node
|
With a NodePort service, a connection to the node’s port is forwarded to a randomly selected pod (possibly on another node ) |
Exposes the Service on an internal IP in the cluster. This type makes the Service only reachable from within the cluster. |
pods using a hostPort , the node’s port is only bound on nodes that run such pods |
NodePort services bind the port on all nodes, even on those that don’t run such a pod |
NA |
The hostPort feature is primarily used for exposing system services, which are deployed to every node using DaemonSets
|
NA | NA |
General Ask Question
Q: What happens when many pods running on the same node whit NodePort?
A: With NodePort
it doesn't matter if you have one or multiple nodes, the port is available on every node.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With