GetEc2InstanceTypesForK8sPods

nicolaw 13th March 2024 at 2:13pm
AWS awscli jq kubectl Kubernetes
while read -r pod node
do
    echo -n "$pod " \
        && aws ec2 describe-instances --output json \
         | jq -re --arg node $node \
         '.Reservations[].Instances[]|select(.PrivateDnsName == $node).InstanceType'
done < <(kubectl get pods --no-headers \
    -o custom-columns=NAME:metadata.name,NODE:spec.nodeName)