Kubectl exec question

Hi

There is a difference when you are using exec like this:

K exec my-pod -- nslookup webapp-service

and this:

k exec my-pod -it -- nslookup webapp-service

I get it the use of flag -it when you are creating containers with run and without restart. But in this case does change something that should I consider ? There are some answers in the cka mock exams with one or the other implementation.

-it is used for interactive/terminal cases, where you need exec to give you access to a terminal for editing. There’s no need to use this in the case you name, but you would need it for k exec -it -- sh, since with the -it flags, you’d immediate exit w/o being left to interact with the shell.

1 Like