I was running kubectl command to deploy my application in the gcloud. But suddenly the kubectl command stopped working. kubectl
command is working fine but for everything else it say command not found.
kubectl create
bash: kubectl create: command not found
kubectl run
bash: kubectl run: command not found
SBGML02586:~ mku01$ kubectl
kubectl controls the Kubernetes cluster manager.
Find more information at: https://kubernetes.io/docs/reference/kubectl/overview/
Basic Commands (Beginner):
create Create a resource from a file or from stdin.
expose Take a replication controller, service, deployment or pod and
expose it as a new Kubernetes Service
run Run a particular image on the cluster
set Set specific features on objects......
I had a similar error when I was setting up Kubernetes on Linux for the first time:
When I try to run the commands:
kubectl cluster-info
kubectl version
I get the error:
-bash: kubectl: command not found
Here's how I fixed it:
Download the latest Kubernetes release with the command:
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
Make the kubectl binary executable:
chmod +x ./kubectl
Move the binary in to your PATH:
sudo mv ./kubectl /usr/local/bin/kubectl
Test to ensure the version you installed is up-to-date:
kubectl cluster-info
kubectl version
You can read up more about it in the Kubernetes Official Docs: Install and Set Up kubectl
That's all.
I hope this helps
I got this message while using wsl on windows. kubectl
was working but suddenly started showing the same error
/mnt/c/Users/xxxx$ kubectl
kubectl: command not found
The issue was that docker was not started after I had restarted my laptop
:/usr/local/bin$ ls -ltr
total 2548
-rwxr-xr-x 1 root root 221 Sep 18 2020 pip3.8
-rwxr-xr-x 1 root root 221 Sep 18 2020 pip3
-rwxr-xr-x 1 root root 221 Sep 18 2020 pip
-rwxr-xr-x 1 root root 208 Sep 18 2020 wheel
-rwxr-xr-x 1 root root 2592768 Apr 5 10:57 kubectx
lrwxrwxrwx 1 root root 55 May 24 11:22 kubectl -> /mnt/wsl/docker-desktop/cli-tools/usr/local/bin/kubect
It started working once I started my docker application (I use docker-desktop for windows, and I had disabled auto-start on startup)
Homebrew users might fix it with:
brew reinstall kubectl
May need to follow it with:
brew link --overwrite kubernetes-cli
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With