File tree 2 files changed +44
-0
lines changed
2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 91
91
run : |
92
92
source .venv/bin/activate
93
93
./test/${{matrix.test}}
94
+ - name : Collect Kubernetes logs
95
+ if : always()
96
+ run : |
97
+ echo "Installing stern..."
98
+ STERN_VERSION="1.30.0"
99
+ curl -Lo stern.tar.gz https://github.com/stern/stern/releases/download/v${STERN_VERSION}/stern_${STERN_VERSION}_linux_amd64.tar.gz
100
+ tar zxvf stern.tar.gz
101
+ chmod +x stern
102
+ sudo mv stern /usr/local/bin/
103
+
104
+ # Run script
105
+ curl -O https://raw.githubusercontent.com/willcl-ark/warnet/main/resources/scripts/k8s-log-collector.sh
106
+ chmod +x k8s-log-collector.sh
107
+ ./k8s-log-collector.sh default
108
+ - name : Upload log artifacts
109
+ if : always()
110
+ uses : actions/upload-artifact@v4
111
+ with :
112
+ name : kubernetes-logs-${{ matrix.test }}
113
+ path : ./k8s-logs
114
+ retention-days : 5
94
115
test-without-mk :
95
116
runs-on : ubuntu-latest
96
117
strategy :
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Set variables
4
+ NAMESPACE=${1:- default}
5
+ LOG_DIR=" ./k8s-logs"
6
+ TIMESTAMP=$( date +" %Y%m%d_%H%M%S" )
7
+
8
+ # Ensure log directory exists
9
+ mkdir -p " $LOG_DIR "
10
+
11
+ # Collect logs using stern (includes logs from terminated pods)
12
+ echo " Collecting stern logs..."
13
+ stern " (tank|commander).*" --namespace=" $NAMESPACE " --output default --since 1h --no-follow > " $LOG_DIR /${TIMESTAMP} _stern_logs"
14
+
15
+ # Collect descriptions of all resources
16
+ echo " Collecting resource descriptions..."
17
+ kubectl describe all --namespace=" $NAMESPACE " > " $LOG_DIR /${TIMESTAMP} _resource_descriptions.txt"
18
+
19
+ # Collect events
20
+ echo " Collecting events..."
21
+ kubectl get events --namespace=" $NAMESPACE " --sort-by=' .metadata.creationTimestamp' > " $LOG_DIR /${TIMESTAMP} _events.txt"
22
+
23
+ echo " Log collection complete. Logs saved in $LOG_DIR "
You can’t perform that action at this time.
0 commit comments