Created
April 17, 2020 17:38
-
-
Save alloy-d/974fce79e0e95a23f467d2fb4886f69a to your computer and use it in GitHub Desktop.
fish function to tail the logs from a bunch of k8s pods in a tmux window
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
function tail-all-pods | |
set kubectl $argv[1] | |
set pattern $argv[2] | |
echo "Using $kubectl to tail all pods matching $pattern..." | |
set pods ($kubectl get pods | kng "$pattern") | |
echo "will open panes to tail pods: $pods" | |
if tmux list-windows | grep -q "$pattern" | |
echo "killing already-open window" | |
tmux kill-window -t "$pattern" | |
end | |
echo "opening window to tail $pods[1]" | |
tmux new-window -n "$pattern" fish -c "$kubectl logs --tail=10 -f $pods[1]" | |
for pod in $pods[2..-1] | |
echo "opening pane to tail $pod" | |
tmux split-window -f -t "$pattern" fish -c "$kubectl logs --tail=10 -f $pod" | |
end | |
tmux select-layout -t "$pattern" even-vertical | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment