-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d14d18
commit 6afb540
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# Set variables | ||
NAMESPACE=${1:-default} | ||
LOG_DIR="./k8s-logs" | ||
TIMESTAMP=$(date +"%Y%m%d_%H%M%S") | ||
|
||
# Ensure log directory exists | ||
mkdir -p "$LOG_DIR" | ||
|
||
# Collect logs using stern (includes logs from terminated pods) | ||
echo "Collecting stern logs..." | ||
stern "(tank|commander).*" --namespace="$NAMESPACE" --output default --since 1h --no-follow > "$LOG_DIR/${TIMESTAMP}_stern_logs" | ||
|
||
# Collect descriptions of all resources | ||
echo "Collecting resource descriptions..." | ||
kubectl describe all --namespace="$NAMESPACE" > "$LOG_DIR/${TIMESTAMP}_resource_descriptions.txt" | ||
|
||
# Collect events | ||
echo "Collecting events..." | ||
kubectl get events --namespace="$NAMESPACE" --sort-by='.metadata.creationTimestamp' > "$LOG_DIR/${TIMESTAMP}_events.txt" | ||
|
||
echo "Log collection complete. Logs saved in $LOG_DIR" |