Skip to content

Instantly share code, notes, and snippets.

@leepro
Last active December 14, 2022 07:05
Show Gist options
  • Save leepro/92c555b69d46aad7e02b14f4f87c77bf to your computer and use it in GitHub Desktop.
Save leepro/92c555b69d46aad7e02b14f4f87c77bf to your computer and use it in GitHub Desktop.
#!/bin/bash
function WaitPods {
while :
do
echo "waiting..."
sleep 1
BACKEND=$(kubectl get pods 2>&1 | grep backend- | awk '{ print $1 }')
FRONTEND=$(kubectl get pods 2>&1 | grep frontend- | awk '{ print $1 }')
JOB=$(kubectl get pods -n crawlers 2>&1 | grep job- | awk '{ print $1 }')
CRAWL=$(kubectl get pods -n crawlers 2>&1 | grep crawl- | awk '{ print $1 }')
REDIS=$(kubectl get pods -n crawlers 2>&1 | grep redis- | awk '{ print $1 }')
if [ -z "$BACKEND" ]; then
echo "not found a backend"
continue
fi
if [ -z "$FRONTEND" ]; then
echo "not found a frontend"
continue
fi
if [ -z "$JOB" ]; then
echo "not found a job"
continue
fi
if [ -z "$CRAWL" ]; then
echo "not found a crawl"
continue
fi
if [ -z "$REDIS" ]; then
echo "not found a redis"
continue
fi
break
done
}
WaitPods
sleep 2
echo "Ctrl+C for all tmux panes to quit"
sleep 2
tmux \
new-session \
"kubectl logs -f $CRAWL --tail 10 -n crawlers && echo DONE && sleep 10"\; \
split-window \
"kubectl logs -f $JOB --tail 10 -n crawlers && echo DONE && sleep 10"\; \
split-window \
"kubectl logs -f $BACKEND --tail 10 && echo DONE && sleep 10"\; \
split-window \
"kubectl logs -f $FRONTEND --tail 10 && echo DONE && sleep 10"\; \
split-window \
"kubectl exec -it $REDIS -n crawlers -- redis-cli monitor"\; \
select-layout tiled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment