Created
July 8, 2022 14:13
-
-
Save JensAc/cd37826ebb1e28fd46b1f82942f9fc54 to your computer and use it in GitHub Desktop.
Simple tmux session setup for working with multiple kubernetes clusters
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 | |
# This simple script simplifies working with multiple Kubernetes clusters | |
# Call it with a path to a kubeconfig.yaml as input and it will create | |
# a new tmux window with 2 panes, one for k9s and one for a shell | |
KUBECONFIG=$(readlink -f $1) | |
SESSIONNAME=kube | |
WINDOWNAME=$(basename -s .yaml $KUBECONFIG) | |
if [[ $(tmux has -t $SESSIONNAME 2>/dev/null) != 0 ]]; then | |
tmux new-session -d -s $SESSIONNAME | |
fi | |
tmux neww -b -t $SESSIONNAME:1 -n $WINDOWNAME -e "KUBECONFIG=$KUBECONFIG" k9s | |
tmux splitw -v -l 20% -e "KUBECONFIG=$KUBECONFIG" | |
tmux kill-window -t $SESSIONNAME:0 | |
tmux attach -t $SESSIONNAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment