Report pod logs.

This commit is contained in:
Corneil du Plessis
2023-01-16 16:32:08 +02:00
parent b3608569bf
commit b2884f44d7
2 changed files with 28 additions and 0 deletions

View File

@@ -127,6 +127,7 @@ jobs:
echo "KUBECONFIG=$KUBECONFIG" >> $GITHUB_ENV
- name: 'Configure: deploy actions-runner-controller into stream-apps-gh-runners'
shell: bash
timeout-minutes: 30
env:
VERBOSE: ${{ inputs.verbose == 'true' && '--verbose' || '' }}
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
@@ -136,3 +137,8 @@ jobs:
GH_ARC_PRIVATE_KEY: ${{ secrets.GH_ARC_PRIVATE_KEY }}
GH_ARC_PAT: ${{ inputs.github_personal_access_token }}
run: ./scripts/deploy-gh-runners-${RUNNER_TYPE}.sh
- name: 'Retrieve: Pod Logs'
if: ${{ failure() }}
shell: bash
run: |
./scripts/get-logs-pods.sh actions-runner-system | tee ./pods.log

22
scripts/get-logs-pods.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
USE_NS=$1
if [ "$USE_NS" == "" ]; then
if [ "$NS" == "" ]; then
echo "NS not defined"
exit 1
else
USE_NS=$NS
fi
fi
set +e
PODS=$(kubectl get pods --namespace "$USE_NS" -o=jsonpath='{.items[*].metadata.name}' 2>/dev/null)
for pod in $PODS; do
echo "=================================="
echo "Config for $pod"
POD_JSON=$(kubectl get pod $pod --namespace "$USE_NS" --output=json)
echo "$POD_JSON"
echo "----------------------------------"
CN=$(echo "$POD_JSON" | jq '.spec.containers[0].name' | sed 's/\"//g')
echo "Logs for $pod/$CN"
kubectl logs $pod --container="$CN" --namespace "$USE_NS" --since=30m --timestamps=true
done