Last active
September 24, 2024 14:01
-
-
Save diafour/ede2238e6d7fbec9e5dff527f1b71788 to your computer and use it in GitHub Desktop.
d8-virtualization debug report for module
This file contains hidden or 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
curl -sLo - https://gist.github.com/diafour/ede2238e6d7fbec9e5dff527f1b71788/raw/75e1aa6ef98f9ab8e83b866a6837047ff8293dfe/debug-report-module.sh | bash -s |
This file contains hidden or 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
#!/usr/bin/env bash | |
TS=$(date +"%Y-%m-%d-%H-%M") | |
REPORT_NAME=debug-report-virtualization-module-${TS} | |
say_green(){ echo -e "\033[1;32m${@}\033[0m" ; } | |
say_red(){ echo -e "\033[1;31m${@}\033[0m" ; } | |
say_yellow(){ echo -e "\033[1;33m${@}\033[0m" ; } | |
create_report(){ | |
NS=d8-virtualization | |
OUTDIR=$1 | |
cd $OUTDIR | |
say_yellow "Get module config ..." | |
kubectl get mc virtualization -oyaml > module-config-virtualization.yaml | |
kubectl get module virtualization -oyaml > module-virtualization.yaml | |
say_yellow "Get Deckhouse queue ..." | |
kubectl -n d8-system exec svc/deckhouse-leader -- deckhouse-controller queue list > d8-queue.txt | |
# Overall status of virtualization | |
kubectl get ns $NS -o wide > ns-$NS.yaml | |
kubectl describe ns $NS > ns-$NS.describe | |
kubectl -n $NS get all -o wide > get-all.txt | |
# Describe all Pods | |
for name in $(kubectl -n $NS get po -oname) ; do | |
say_yellow Dump $name ... | |
file=pod-${name#pod/} | |
kubectl -n $NS get $name -oyaml > ${file}.yaml || rm ${file}.yaml | |
kubectl -n $NS describe $name > ${file}.describe || rm ${file}.describe | |
kubectl -n $NS logs $name > ${file}.log || rm ${file}.log | |
kubectl -n $NS logs -c proxy $name > ${file}-proxy.log || rm ${file}-proxy.log | |
done | |
# Describe all Deployments. | |
for name in $(kubectl -n $NS get deploy -oname) ; do | |
say_yellow Dump $name ... | |
file=deploy-${name#deployment.apps/} | |
kubectl -n $NS get $name -oyaml > ${file}.yaml || rm ${file}.yaml | |
kubectl -n $NS describe $name > ${file}.describe || rm ${file}.describe | |
done | |
# Describe all Daemonsets. | |
for name in $(kubectl -n $NS get daemonsets -oname) ; do | |
say_yellow Dump $name ... | |
file=ds-${name#daemonset.apps/} | |
kubectl -n $NS get $name -oyaml > ${file}.yaml || rm ${file}.yaml | |
kubectl -n $NS describe $name > ${file}.describe || rm ${file}.describe | |
done | |
# Get CDI and Kubevirt configs | |
say_yellow "Get CDI and Kubevirt configs states ..." | |
objName="internalvirtualizationkubevirts.internal.virtualization.deckhouse.io/config" | |
kubectl -n $NS get $objName -oyaml > kubevirt-config.yaml | |
kubectl -n $NS describe $objName > kubevirt-config.describe | |
objName="internalvirtualizationcdis.cdi.internal.virtualization.deckhouse.io/config" | |
kubectl -n $NS get $objName -oyaml > cdi-config.yaml | |
kubectl -n $NS describe $objName > cdi-config.describe | |
say_yellow "Get state from original Kubevirt/CDI ..." | |
kubectl -n kubevirt get all > original-kubevirt-all.txt || rm original-kubevirt-all.txt | |
kubectl -n cdi get all > original-kubevirt-all.txt || rm original-kubevirt-all.txt | |
cd - | |
} | |
main(){ | |
tmpDir=$(mktemp -d) | |
trap 'rm -rf $tmpDir' ERR EXIT | |
REPORT_DIR_PATH="${tmpDir}/${REPORT_NAME}" | |
REPORT_ARCHIVE="${REPORT_NAME}.tar.gz" | |
mkdir "${REPORT_DIR_PATH}" | |
create_report "${REPORT_DIR_PATH}" | |
say_green "Archiving report ..." | |
tar -czvf "${REPORT_ARCHIVE}" -C "${tmpDir}" "${REPORT_NAME}" | |
say_green "Done: ${REPORT_ARCHIVE}" | |
} | |
main $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment