Skip to content

Instantly share code, notes, and snippets.

@steve-fraser
Created March 19, 2026 20:10
Show Gist options
  • Select an option

  • Save steve-fraser/d651e6fc06509c1047bce20034ed6e68 to your computer and use it in GitHub Desktop.

Select an option

Save steve-fraser/d651e6fc06509c1047bce20034ed6e68 to your computer and use it in GitHub Desktop.
kubectl get volumeattachments -o json | \
jq -r '
[.items[] | select(.status.attached==true) | .spec.nodeName] |
group_by(.) |
map({node: .[0], attached: length}) |
.[]
' | \
while read -r line; do
node=$(echo "$line" | jq -r '.node')
attached=$(echo "$line" | jq -r '.attached')
limit=$(kubectl get csinode "$node" -o jsonpath='{.spec.drivers[?(@.name=="ebs.csi.aws.com")].allocatable.count}' 2>/dev/null)
echo "$node | attached=$attached | limit=${limit:-unknown} | remaining=$(( ${limit:-0} - attached ))"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment