0

Zsh completion works fine for kubectl exec, but failed for kubectl exec -ti.

I already did this echo "[[ $commands[kubectl] ]] && source <(kubectl completion zsh)" >> ~/.zshrc # add autocomplete permanently to your zsh shell from official document Kubectl autocomplete

When I press tab key after input kubectl exec, pod names were list, but nothing return when I press tab after input -ti or -it. No error info in the command line.

Where can I find the completion log? How to troubleshooting this?

Peter
  • 357
  • 3
  • 10
  • Can you elaborate more on the commands and the error thrown. – Srividya Sep 09 '21 at 12:31
  • @Srividya When I press `tab` key after input `kubectl exec`, pod names were list, but nothing return when I press `tab` after input `-ti`. No error info in the command line. Where can I find the error? – Peter Sep 10 '21 at 07:34
  • You are using command "kubectl exec -ti" but instead of that use "kubectl exec -it", or "kubectl exec -stdin". Refer [here](https://v1-17.docs.kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/#getting-a-shell-to-a-container) for more details. – Bakul Mitra Sep 10 '21 at 12:35

1 Answers1

1

It is a compatible issue.

The server version is 1.16 and the client version of kubectl is 1.22, which is not supported perfectly to the server.

When I execute kubectl version, got the warning below:

WARNING: version difference between client (1.22) and server (1.16) exceeds the supported minor version skew of +/-1

So I downloaded a specific version kubectl with curl -LO " https://dl.k8s.io/release/v1.16.6/bin/darwin/amd64/kubectl". The completion works.

Peter
  • 357
  • 3
  • 10