Skip to content

Instantly share code, notes, and snippets.

@epcim epcim/kubectl.sh
Created Mar 29, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.