Skip to content

Instantly share code, notes, and snippets.

@infinitewarp
Last active August 18, 2021 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infinitewarp/04aeb7c0bbf3d5f24c87f0368ee9e89b to your computer and use it in GitHub Desktop.
Save infinitewarp/04aeb7c0bbf3d5f24c87f0368ee9e89b to your computer and use it in GitHub Desktop.
crude openshift pod log scraper
#!zsh
# get all current cloudigrade pods logs
PROJECT="cloudigrade-stage"
#PROJECT="cloudigrade-prod"
#PROJECT="cloudigrade-ci"
oc project "${PROJECT}" || exit $?
DATEDIR=$(gdate -u "+%Y-%m-%dT%H.%M.%S")
DIRNAME="logs-$PROJECT-$DATEDIR"
mkdir -p "${DIRNAME}"
pushd "${DIRNAME}"
for POD in $(oc get pods -o jsonpath='{.items[?(.status.phase=="Running")].metadata.name}'); do
oc logs "${POD}" > "${POD}.txt"
done
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment