I'm trying to make my life easier and am coding a bash script. One of these allows me to kube into a pod with postgres access, get the credentials I need, and run the interactive psql shell.
However, upon running
kubectl <flags> exec $podname -- bash -c ' get_credentials && psql <psql args> -i -t
the terminal hangs.
I can't directly connect to the database, and the process to get the credentials is kinda cumbersome. Is there some bash concept I'm not understanding?
kubectl <flags> exec $podname
That exec
is missing its -i
and -t
for --stdin=true
and --tty=true
to describe to kubernetes that you wish your terminal and the remote terminal to be associated with one another:
kubectl exec -it $podname -- etc etc
If you are intending the -i
and -t
present at the end of your cited example above to be passed to exec
, be aware that the double dashes explicitly switch off argument parsing from kubectl
, so there is no way it will see them