When deploying workloads in a Kubernetes cluster, assigning a hostPort to pods can impact node utilization, especially in environments managed through Ocean. This configuration affects how pods are scheduled across nodes and can contribute to underutilized resources if not configured carefully.
This situation can occur when multiple pods request the same hostPort. Each unique combination of hostIP, hostPort, and protocol must be unique on a node, so if multiple pods request the same port, they must be scheduled on different nodes. The following example demonstrates a pod definition requiring a hostPort:
apiVersion: v1
kind: Pod
metadata:
name: firstpod
spec:
containers:
- name: container
image: nginx
ports:
- containerPort: 80
hostIP: 10.0.0.1
hostPort: 8080
When such pods are deployed, Kubernetes must schedule them on separate nodes, since only one instance per node can claim the same hostPort. This behavior can lead to several nodes hosting very few pods, resulting in underutilization across the cluster.
Key details
-
A pod that binds a
hostPortlimits scheduling flexibility because each node can only host a single pod for each unique host port. -
If multiple pods define the same
hostPort, Kubernetes schedules each on a different node. -
Because of this restriction, resource utilization might decrease, and you may end up with several partially used nodes.
Best practices
-
Avoid using
hostPortwhenever possible. Use it only when absolutely necessary. -
Instead of binding to a host port:
-
Expose required ports using Kubernetes Services, such as
NodePortorLoadBalancer. -
Consider using headless Services (those with
clusterIP: None) for service discovery. -
For debugging purposes, access pods using the API server proxy (
kubectl proxy) or port-forwarding (kubectl port-forward) rather than assigninghostPort.
-
-
If
hostPortmust be used, use unique port numbers across pods, or distribute workloads strategically to ensure node capacity is efficiently utilized. -
Avoid specifying
hostNetworkfor the same reasons ashostPort, as it also binds pods to specific network namespaces on the node.
For additional reference, see the Kubernetes official documentation on Services and Networking.
Related Articles
Resolve underutilized ECS container instances caused by HostPort configuration 12Number of Views Pods with hostPort requests cause underutilized nodes 4Number of Views Can hostPort settings cause underutilized ECS nodes? 3Number of Views Pods fail after scheduling on B‑series burstable VM nodes 4Number of Views Will a cluster roll replace nodes that have pods with the spotinst.io/restrict-scale-down label? 16Number of Views
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add additional feedback (optional)
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
|
FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513
(toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367
(toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895
2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
Revenera Assistant
Case id: 00001065
Activity: Status change: 2 hours ago