-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathcreate-reports.sh
executable file
·37 lines (28 loc) · 1.33 KB
/
create-reports.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
ignore="--ignore-not-found"
logsDir="logs"
createResourceReport () {
path=$1
namespace=$2
resource=$3
withLogs=$4
mkdir -p "$path/$resource"
kubectl get "$resource" -n "$namespace" "$ignore" > "$path/$resource/list-$resource.txt"
for r in $(kubectl get "$resource" -n "$namespace" "$ignore" -o jsonpath='{.items[*].metadata.name}'); do
kubectl describe "$resource/$r" -n "$namespace" > "$path/$resource/$r-describe.txt"
if $withLogs ; then
kubectl logs "$resource/$r" --all-containers=true -n "$namespace" > "$path/$resource/$r-logs.txt"
fi
done
}
# Go through each namespace in the cluster
for namespace in $(kubectl get namespaces -o jsonpath='{.items[*].metadata.name}'); do
mkdir -p "$logsDir/$namespace"
createResourceReport "$logsDir/$namespace" "$namespace" "Pods" true
createResourceReport "$logsDir/$namespace" "$namespace" "Deployments" false
createResourceReport "$logsDir/$namespace" "$namespace" "Daemonsets" false
createResourceReport "$logsDir/$namespace" "$namespace" "Statefulsets" false
createResourceReport "$logsDir/$namespace" "$namespace" "Jobs" false
createResourceReport "$logsDir/$namespace" "$namespace" "FeatureFlag" false
createResourceReport "$logsDir/$namespace" "$namespace" "FeatureFlagSource" false
done