1

I am running the following kubectl exec & kubectl logs cmd at the same time on two different windows command prompt

kubectl exec ${pod} containername -n namespace -- bash -c "cd somebatch.ksh > /proc/1/fd/1 2>&1"

kubectl logs ${pod} containername -n namespace

both gets exited from the windows command prompt in between while the process is running in the container still.

If I run the kubectl logs cmd again, I could see the running logs

kubectl logs ${pod} containername -n namespace

What should I do to keep the kubectl exec & kubectl log commands running without exiting.

One Developer
  • 99
  • 5
  • 43
  • 103

1 Answers1

1

You can "tail" the logs command by including --follow.

The exec creates a shell in the container and runs the script. Once the shell is created and the script passed, the process is complete.

If you want to keep the session open, you should be able to exec just bash and then run the commands interactively. You may want to include --stdin --tty, i.e. kubectl exec --stdin --tty ... -- bash

DazWilkin
  • 32,823
  • 5
  • 47
  • 88