File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -503,7 +503,7 @@ function k8s_namespace() {
503503}
504504
505505function k8s_log() {
506- local resource
506+ local resource follow
507507
508508 if [[ $# -ne 0 ]] ; then
509509 if kubectl get pod " $1 " & > /dev/null ; then
@@ -519,6 +519,10 @@ function k8s_log() {
519519 if [[ -z " $resource " ]] ; then
520520 return 1
521521 fi
522+
523+ if [[ $( kubectl get pod " $resource " -o jsonpath=' {.status.phase}' ) == " Running" ]] ; then
524+ follow=1
525+ fi
522526 else
523527 echo " Usage: kl {resource} {option}…"
524528 return 0
@@ -531,7 +535,7 @@ function k8s_log() {
531535 fi
532536
533537 if [[ -f " $HOME /.bin/lj" ]] ; then
534- if [[ $@ =~ (-F| --follow) ]] ; then
538+ if [[ $@ =~ (-F| --follow) || -n " $follow " ]] ; then
535539 kubectl logs " $resource " -f | lj $@
536540 return $?
537541 else
You can’t perform that action at this time.
0 commit comments