Skip to content

Instantly share code, notes, and snippets.

@terinjokes
Last active February 26, 2023 23:20
Show Gist options
  • Save terinjokes/7d2a2f85bc7e89541c8cecabacec50b4 to your computer and use it in GitHub Desktop.
Save terinjokes/7d2a2f85bc7e89541c8cecabacec50b4 to your computer and use it in GitHub Desktop.
FZF function for Kubernetes logs (including previewing)
klogs() {
pod="$(kubectl get po -o wide|tail -n+2|fzf -n1 --reverse --tac --preview='kubectl logs --tail=20 --all-containers=true {1}' --preview-window=down:50%:hidden --bind=ctrl-p:toggle-preview --header="^P: Preview Logs"|awk '{print $1}')"
if [[ -n $pod ]]; then
kubectl logs --all-containers=true $pod
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment