How to install kubectl on Ubuntu

Problem:

You want to run the Kubernetes kubectl command on Ubuntu but you see an error message like this:

install_kubectl_output.txt
command not found: kubectl

Solution

Install kubectl using snap:

install_kubectl_snap.sh
sudo snap install kubectl --classic

After this command has finished installing kubectl, in most cases you can use it immediately. In case you still get the command not found: kubectl error message, run $SHELL to reload your shell and check if /snap/bin is in your $PATH environment variable.


Check out similar posts by category: Container, Kubernetes, Linux