Created
September 30, 2021 11:05
-
-
Save martinkennelly/9f1a1752a02f23312733ca5e120d54ab to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
NAMESPACE="openshift-ovn-kubernetes" | |
KUBE_NODE_CONTAINERS=("ovn-acl-logging" "ovn-controller" "ovnkube-node") | |
KUBE_MASTER_CONTAINERS=("kube-rbac-proxy" "nbdb" "northd" "ovn-dbchecker" "ovnkube-master" "sbdb") | |
dir=$(mktemp -d) | |
sleep_duration=${SLEEP_DURATION:-20} | |
i=1 | |
echo "log base temp directory: '$dir'" | |
read -n 1 -p "hit enter when ready to record pods logs contineously until interupt every $sleep_duration seconds: " | |
while true; do | |
new_dir="$dir/$i" | |
mkdir -p "$new_dir" | |
echo "very very rought time into test '$i' - '$(date)'" | tee -a "$new_dir/time" | |
oc get pods -n $NAMESPACE | tee -a "$new_dir/get_pods" | |
for pod in $(oc get pods -n $NAMESPACE -o=jsonpath='{.items..metadata.name}'); do | |
if [[ $pod =~ "ovnkube-node" ]]; then | |
for container in ${KUBE_NODE_CONTAINERS[@]}; do | |
kubectl logs $pod -n $NAMESPACE -c $container > "$new_dir/${pod}-$container.log" | |
done | |
kubectl describe pod $pod -n $NAMESPACE > "$new_dir/${pod}.desc" | |
fi | |
if [[ $pod =~ "ovnkube-master" ]]; then | |
for container in ${KUBE_MASTER_CONTAINERS[@]}; do | |
kubectl logs $pod -n $NAMESPACE -c $container > "$new_dir/${pod}-$container.log" | |
done | |
kubectl describe pod $pod -n $NAMESPACE > "$new_dir/${pod}.desc" | |
fi | |
done | |
echo "sleeping $sleep_duration" | |
sleep $sleep_duration | |
i=$((i+sleep_duration)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment