this can be done in a one liner:
printf "%-30s %s\n" "NODE_NAME" "POD_ALLOCATION" && kubectl get nodes -o name | xargs -I {} bash -c 'count=$(kubectl get pods --all-namespaces --field-selector spec.nodeName=$(echo {} | cut -d/ -f2) -o json | jq ".items | length"); capacity=$(kubectl get {} -o jsonpath="{.status.capacity.pods}"); printf "%-30s %s/%s\n" "$(echo {} | cut -d/ -f2)" "$count" "$capacity"'