Interview Prep/Kubernetes/Scheduling and Pending Pods

A Pod using `hostPort: 8080` is Pending with `node(s) didn't have free ports for the requested pod ports`.

IntermediateTroubleshootingScheduling and Pending Pods
Answer

Likely causes → hostPort makes a port exclusive per node. During a rolling update the new Pod needs the same host port on a node where the old one still runs, or another DaemonSet already uses it.

Diagnose →

kubectl get pods -A -o json | jq -r '.items[] | select(.spec.containers[].ports[]?.hostPort==8080) | "\(.metadata.namespace)/\(.metadata.name) \(.spec.nodeName)"'

Fix → Drop hostPort and use a Service. If it is genuinely required (node-local agents), set the rollout to maxSurge: 0, maxUnavailable: 1 so the old Pod frees the port first.

Prevent → Treat hostPort/hostNetwork as exceptions approved by the platform team; block them by policy elsewhere.

All Kubernetes questions Roadmap: Kubernetes core

More on Scheduling and Pending Pods