• Recent blogs

    How to Install kubectl on Linux


    Install and Set Up kubectl

    The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs.

    Before you begin

    You must use a kubectl version that is within one minor version difference of your cluster. For example, a v1.2 client should work with v1.1, v1.2, and v1.3 master. Using the latest version of kubectl helps avoid unforeseen issues.

    Install kubectl on Linux

    Install kubectl binary with curl on Linux

    1. 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"
    2. Install kubectl

      sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
    3. Test to ensure the version you installed is up-to-date:

      kubectl version --client

    To download a specific version, replace the $(curl -L -s https://dl.k8s.io/release/stable.txt) portion of the command with the specific version.

    For example, to download version v1.19.7 on Linux, type:

    curl -LO "https://dl.k8s.io/release/v1.19.7/bin/linux/amd64/kubectl"

    How to Install kubectl on Linux

    Install using native package management
    cat <<EOF > /etc/yum.repos.d/kubernetes.repo
    gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
    yum install -y kubectl

    sudo apt-get update && sudo apt-get install -y apt-transport-https gnupg2 curl
    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
    echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
    sudo apt-get update
    sudo apt-get install -y kubectl

    No comments