kubectl run - How to pass some commands to be executed before reaching the interactive terminal? kubectl run - How to pass some commands to be executed before reaching the interactive terminal? kubernetes kubernetes

kubectl run - How to pass some commands to be executed before reaching the interactive terminal?


You can use the shell's exec to hand control over from your initial "outer" bash, responsible for doing the initialization steps you want, over to a fresh one (fresh in the sense that it does not have -c and can optionally be a login shell) which runs after your pre-steps:

kubectl run sample -it --image=ubuntu:20.04 -- \    bash -c "apt update; apt install -y zip; exec bash -il"