Using sudo -i
might work for autocompletion for the root user as it is set up properly. But for regular users, it might need appropriate shell configuration or a package is not installed by default.
To enable shell autocompletion you need to install bash-completion package :
apt-get install bash-completion
After installing you need generate the required kubectl
completion script :
echo 'source <(kubectl completion bash)' >>~/.bashrc
To enable bash autocompletion in current session run the command below :
source ~/.bashrc
For additional information follow this documentation for further guidance.