Created
June 24, 2019 08:30
-
-
Save kneilb/467ee926b45664d97efbf60521a06985 to your computer and use it in GitHub Desktop.
Run bash in a pod
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 | |
http_proxy= | |
ns=mfsp-island80-k8snew | |
pod_expr=spark-mux | |
container=spark-mux | |
while getopts ":hn:p:c:" arg; do | |
case $arg in | |
n) | |
ns=$OPTARG | |
;; | |
p) | |
pod_expr=$OPTARG | |
;; | |
c) | |
container=$OPTARG | |
;; | |
*) | |
echo "-h Help" | |
echo "-n NAMESPACE Choose a namespace (Default $ns)" | |
echo "-p PODEXPR Choose a pod expression (Default $pod_expr)" | |
echo "-c CONTAINER Choose a container name (Default $container)" | |
exit 0 | |
;; | |
esac | |
done | |
pod=$(kubectl -n $ns get pods | awk "/${pod_expr}/"'{print $1}') | |
echo $pod | |
if [ -z "$pod" ]; then | |
echo NO POD FOUND! | |
exit 1 | |
fi | |
kubectl -n $ns logs $pod -c $container | |
kubectl -n $ns exec $pod -c $container -it bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment