Skip to content

Instantly share code, notes, and snippets.

@epcim
Created March 29, 2019 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epcim/33e78f21452a6058d6aeca998a501118 to your computer and use it in GitHub Desktop.
Save epcim/33e78f21452a6058d6aeca998a501118 to your computer and use it in GitHub Desktop.
kubernetes k8s kubectl
# p cmd pritns pods in cluster &&
# store Kubernetes pod name & namespace to env variable
[[ -z $ZSH_NAME ]] || setopt SH_WORD_SPLIT
function p() {
eval $(kubectl get po --all-namespaces -L app -o wide | tee /dev/stderr|awk '{gsub(/.*-/,"",$8);gsub(/-/,"",$10);printf "%s%s=\x27-n %s %s\x27\n", $10,$8, $1, $2}'|grep -v "^=");
}
p
k logs $fluentbit1
k describe po $fluentd2
## Where to improve
# depend on having Label set (app, in this case), but can be easily tweeked to use any other pattern
# $8 expect's nodes has name ending xyz-N (where -N is the index number), change to use real pod index number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment