Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubectl exec [POD] [COMMAND] is DEPRECATED #44

Open
achton opened this issue Apr 21, 2020 · 4 comments
Open

kubectl exec [POD] [COMMAND] is DEPRECATED #44

achton opened this issue Apr 21, 2020 · 4 comments

Comments

@achton
Copy link
Contributor

achton commented Apr 21, 2020

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

@ahmetb
Copy link
Owner

ahmetb commented Apr 29, 2020

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?

@francilioaraujo
Copy link

@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

@wanddynosios
Copy link

The old syntax has been removed with v1.31.0. I fixed it for zsh like this:

alias kex='f() { kubectl exec $1 -i -t -- "${@:2}"};f' #manual edit

@howardjohn
Copy link

The old syntax has been removed with v1.31.0. I fixed it for zsh like this:

alias kex='f() { kubectl exec $1 -i -t -- "${@:2}"};f' #manual edit

The nice part about the old usage is you can do kex -some-flag ls, kex -some-flag -- ls, kex -- ls, kex ls -- all options availble.

Now this is impossible. I opened an upstream issue to revert it, though I wouldn't expect much. kubernetes/kubectl#1687.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants