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
kubectl is not available after enabling kubernetes in docker-desktop. Follow these steps to resolve the issue:
First step: Download the latest release with the command:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
Second step: Download the kubectl checksum file:
curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
Validate the kubectl binary against the checksum file:
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
If valid, the output is:
kubectl: OK
If the check fails, sha256 exits with nonzero status and prints output similar to:
Note: Download the same version of the binary and checksum.
Third step:
Install kubectl
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
Fourth step:
Test to ensure the version you installed is up-to-date:
kubectl version --client
or use this for detailed view of version:
kubectl version --client --output=yaml
Please check your nix config file and add "kubernetes.enable = true;" in tools.