Search code examples
kubernetesgcloudkubectl

Kubernetes: kubectl run: command not found


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......

Solution

  • 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