Add a script to collect logs

This commit is contained in:
Gaël Goinvic committed 2026-03-26 17:45:04 +01:00
1 parent db7f7ef6e8
commit b73a29d40e
4 files changed
+113 -24

No files matched your search

+1 -24
View File
@@ -160,30 +160,7 @@ jobs:
if: ${{ failure() }}
shell: bash
run: |
mkdir ess-helm-logs
k3d kubeconfig merge ess-helm -ds
for ns in $(kubectl --context k3d-ess-helm get ns -o custom-columns=NS:.metadata.name --no-headers); do
mkdir -p "./ess-helm-logs/$ns"
for pod in $(kubectl --context k3d-ess-helm -n "$ns" get pod -o custom-columns=NS:.metadata.name --no-headers); do
kubectl --context k3d-ess-helm -n "$ns" logs --all-containers --prefix --timestamps --ignore-errors --previous "$pod" > "./ess-helm-logs/$ns/$pod.previous"
kubectl --context k3d-ess-helm -n "$ns" logs --all-containers --prefix --timestamps --ignore-errors "$pod" > "./ess-helm-logs/$ns/$pod.logs"
done
resources=("pods" "deployments" "statefulsets" "services" "configmaps" "ingresses" "persistentvolumes" "persistentvolumeclaims" "endpoints")
for i in "${resources[@]}"; do
kubectl --context k3d-ess-helm get "$i" -n "$ns" > "./ess-helm-logs/$ns/$i.txt"
echo "----" >> "./ess-helm-logs/$ns/$i.txt"
kubectl --context k3d-ess-helm get "$i" -o yaml -n "$ns" >> "./ess-helm-logs/$ns/$i.txt"
done
kubectl --context k3d-ess-helm get events --sort-by=.metadata.creationTimestamp -n "$ns" > "./ess-helm-logs/$ns/events.txt"
kubectl --context k3d-ess-helm get secrets -n "$ns" > "./ess-helm-logs/$ns/secrets.txt"
echo "----" >> "./ess-helm-logs/$ns/secrets.txt"
kubectl --context k3d-ess-helm get secrets -o yaml -n "$ns" | yq eval '.items[].data |= with_entries(.value = "censored") | .items[].stringData |= with_entries(.value = "censored")' > "./ess-helm-logs/$ns/secrets.txt"
done
kubectl --context k3d-ess-helm get crds > "./ess-helm-logs/crds.txt"
echo "----" >> "./ess-helm-logs/$ns/crds.txt"
kubectl --context k3d-ess-helm get crds -o yaml | yq 'del .items[].spec' > "./ess-helm-logs/crds.txt"
docker logs k3d-ess-helm-server-0 > "./ess-helm-logs/k3d-ess-helm-server-0.logs" 2>&1
k3d cluster delete ess-helm
collect-ess-logs --system-logs
- name: Upload logs
if: ${{ failure() }}