List pods running on a kubernetes node

Published: 2024-06-05 20:19:52 +0000
Categories: Misc,




Running kubectl get pods is pretty straightfoward, but it can do also do a lot of filtering

If contention is suspected, it's often useful to be able to see what other workloads the underlying node is carrying

This snippet details getting node information from kubectl, with an example showing out how to list all pods that are running on the same node as a pod with a specific label.


# List all pods with their nodes
kubectl get pods -o wide

# Filter by node id
kubectl get pods --field-selector spec.nodeName=MyNode

# Identify nodes and pods for specific app
kubectl get pods -l app=MyApp -o wide

Usage Example

# List all pods on all nodes running a pod for app MyApp
for node in `kubectl get pods -l app=MyApp -o wide --no-headers | awk '{print $7}'` do
    echo "$node"
    kubectl get pods --field-selector spec.nodeName="$node"
    echo ""


k8s, pods, nodes,

Latest Posts

Copyright © 2024 Ben Tasker | Sitemap | Privacy Policy
Available at, http://phecoopwm6x7azx26ctuqcp6673bbqkrqfeoiz2wwk36sady5tqbdpqd.onion and http://snippets.bentasker.i2p
hit counter