Created
June 4, 2020 00:03
-
-
Save takakabe/04dee59a29efdce04547c3adbb144bd0 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
set -u | |
| |
while getopts n: opt; do | |
optarg="${OPTARG}" | |
if [[ "${opt}" = - ]]; then | |
opt="-${OPTARG%%=*}" | |
optarg="${OPTARG/${OPTARG%%=*}/}" | |
optarg="${optarg#=}" | |
set +u | |
if [[ -z "${optarg}" ]] && [[ ! "${!OPTIND}" = "-*" ]]; then | |
optarg="${!OPTIND}" | |
shift | |
fi | |
set -u | |
fi | |
case "-${opt}" in | |
-n|--namespace) | |
namespace="${optarg}" | |
;; | |
--*) | |
echo "${0}: illegal option -- ${opt##-}" >&2 | |
exit 1 | |
;; | |
esac | |
done | |
shift $((OPTIND - 1)) | |
| |
| |
pods=`kubectl get pods -n ${namespace:-default} | awk '{print $1}' | grep -v 'NAME'` | |
for pod in ${pods}; do | |
echo '---' | |
echo ${pod} | |
kubectl describe pods ${pod} -n ${namespace:-default} | sed -n '/^Containers:/,$p' | grep -B 1 'Container ID:' | grep -v 'Container ID:' | grep -v "\-\-" | sed -e 's/://' | |
done | |
| |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment