Created
July 10, 2019 06:40
-
-
Save avence12/154c12fe781e544aca4626d1e2acd028 to your computer and use it in GitHub Desktop.
Interactive fzf UI for getting into kubernetes pods
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 | |
raw_selection=$(kubectl get pods | grep -v ^NAME | fzf --multi) | |
selection=() | |
arr=($raw_selection) | |
for ((i=0; i<${#arr[@]}; i+=5)); do | |
selection+=("${arr[$i]}") | |
done | |
if [ ${#selection[@]} -eq 1 ]; then | |
echo "${selection[0]}" | |
kubectl exec -it ${selection[0]} -- bash | |
elif [ ${#selection[@]} -gt 1 ]; then | |
echo "${selection[@]}" | |
echo "${selection[@]}" | xargs mssh-k8s | |
else | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment