Search code examples
kubectlzsh-completion

kubectl exec with parameter -ti completion failed


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?


Solution

  • 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.