Skip to content

Instantly share code, notes, and snippets.

@avence12
Created July 10, 2019 06:40
Show Gist options
  • Save avence12/154c12fe781e544aca4626d1e2acd028 to your computer and use it in GitHub Desktop.
Save avence12/154c12fe781e544aca4626d1e2acd028 to your computer and use it in GitHub Desktop.
Interactive fzf UI for getting into kubernetes pods
#!/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