kubectl-aliases icon indicating copy to clipboard operation
kubectl-aliases copied to clipboard

kubectl exec [POD] [COMMAND] is DEPRECATED

Open achton opened this issue 4 years ago • 3 comments

When running a command like kexn test varnish-529679cb57-mjn62 bash it translates to kubectl exec -i -t --namespace test varnish-529679cb57-mjn62 bash and kubectl returns a deprecation warning:

kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl kubectl exec [POD] -- [COMMAND] instead.

The problem is that --namespace is a positional argument, but to fix this issue it will need to not be last, but come before the --. See https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#exec

achton avatar Apr 21 '20 08:04 achton

I believe this is something we cannot fix. Take this for example:

alias kex='kubectl exec -i -t'

Because you need to provide POD before --, alias cannot add that -- for you. We need a bash function for that.

Though, I'm not planning to add bash functions, and I might actually remove exec functionality from this since there are only 2 aliases about this kex and kexn. Thoughts?

ahmetb avatar Apr 29 '20 17:04 ahmetb

@ahmetb , I think kex and kexn are great aliases. If the user adds the -- between pod's name and the command, then the deprecation warning is not shown. Maybe you could just add a note in README.md about this issue

francilioaraujo avatar Mar 10 '21 16:03 francilioaraujo