Created
May 7, 2019 20:28
-
-
Save mjhuber/beebbb42194f316d4a2a038e275aeefd to your computer and use it in GitHub Desktop.
Get k8s resources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
NAMESPACE="default" | |
DEPLOYMENTS=$(kubectl get deploy -n $NAMESPACE --no-headers | awk '{print $1}') | |
for deploy in $DEPLOYMENTS; do | |
echo "$deploy" | |
resources=$(kubectl get deploy/$deploy -n $NAMESPACE -o json | jq '.spec.template.spec.containers[0].resources') | |
mem_limit=$(echo $resources | jq '.limits.memory') | |
mem_req=$(echo $resources | jq '.requests.memory') | |
cpu_limit=$(echo $resources | jq '.limits.cpu') | |
cpu_req=$(echo $resources | jq '.requests.cpu') | |
printf "\tMemory:\n\t Requests: %s\n\t Limits: %s\n\n" $mem_req $mem_limit | |
printf "\tCPU:\n\t Requests: %s\n\t Limits: %s\n\n\n" $cpu_req $cpu_limit | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment