Prasun Barthwal:
Hi,
I am using below two commands on the terminal of practice tests
alias k = kubectl
source < ( kubectl completion bash )
Both are working & I can run commands like “k get po” , however when I am trying to take advantage of the completion bash setup it is not working with alias.
kubectl run [tab] : This is working
k run [tab] : This isn’t working , I have created alias k for kubectl so I think this should also work. Any clue what I am doing wrong here
Arpit Goyal:
I think the completion works only when full kubectl is typed. That is what I noticed
By the way in exam as far as I know you don’t need it. I just used k and kn (to change namespace) and $do for dry run/yaml generation. And I had lot of time.
You can always do k <object> -h | more
to see the example and copy paste them. Or you can use k explain <object>.spec —recursive | grep -i C2 <regex >
both are sufficient!
Kicky:
alias k=kubectl
complete -F __start_kubectl k
After executing the above, u can use autocompletion with command k
Prasun Barthwal:
thanks Kicky, it works. Just noticed it is mentioned in the docs , I thought it is just an alternate way of writing the same command plain lazy https://kubernetes.io/docs/reference/kubectl/cheatsheet/