Can you avoid the pod to be restarted after kubectl attach?

2/10/2022

I have an ubuntu image that I use for debugging. I do kubectl attach my-app -c my-app -it and then many apt-get install and other configurations I need.

The problem is when I exit ctrl+c the pod seems to get restarted and I loose all what I did <br>Is there a way like --restart=never to avoid the container to be recreated

-- Carlos Garcia
kubectl
kubernetes

1 Answer

2/10/2022

Run another shell session kubectl exec my-app -c my-app -it -- bash to prepare your container. Alternately, if your pod spec has the following set to true:

stdin: true 
tty: true 

You use the escape sequence Ctrl+P followed by Ctrl+Q to detach from the container after kubectl attach -it to the container.

-- gohm&#39;c
Source: StackOverflow