Skip to content

Installing CLI Tools

This page covers two CLI tools and an optional plugin:

  • Kubernetes CLI — kubectl, for Kubernetes resources and YAML manifests.
  • Knative CLI — kn, for Knative resource workflows.
  • Knative Operator plugin — the separate kn-operator executable, which extends kn with the kn operator command group for installing and managing Operator-based Knative installations. It is not another core CLI named kn.

Use core kn commands for Knative resources, or kubectl to apply their YAML manifests. Installation workflows such as kn operator install require the separately installed Operator plugin and administrator permissions; see the Operator CLI installation guide.

For function-project workflows, install func or the kn func plugin separately.

Install Kubernetes CLI

Install the Kubernetes CLI (kubectl) to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs.

Install the Knative CLI

The Knative CLI (kn) provides a quick and easy interface for creating Knative resources, such as Knative Services and Event Sources, without the need to create or modify YAML files directly.

The kn CLI also simplifies completion of otherwise complex procedures such as autoscaling and traffic splitting.

Do one of the following:

  • To install kn by using Homebrew, run the command (Use brew upgrade instead if you are upgrading from a previous version):

    brew install knative/client/kn
    

You can install kn by downloading the executable binary for your system and placing it in the system path.

  1. Download the binary for your system from the kn release page.

  2. Rename the binary to kn and make it executable by running the commands:

    mv <path-to-binary-file> kn
    chmod +x kn
    

    Where <path-to-binary-file> is the path to the binary file you downloaded in the previous step, for example, kn-darwin-amd64 or kn-linux-amd64.

  3. Move the executable to a writable directory on your PATH. For example:

    mkdir -p "$HOME/.local/bin"
    mv kn "$HOME/.local/bin/kn"
    export PATH="$HOME/.local/bin:$PATH"
    

    If this directory is not already on your PATH, add the same export to your shell's startup configuration for future terminals.

  4. Verify that kn commands are working properly. For example:

    kn version
    
  1. Check out the kn client repository:

    git clone https://github.com/knative/client.git
    cd client/
    
  2. Build an executable binary:

    hack/build.sh -f
    
  3. Move the executable to a writable directory on your PATH, as described in the binary installation option above.

  4. Verify that kn commands are working properly. For example:

    kn version
    

Links to images are available here:

You can run kn from a container image. For example:

docker run --rm -v "$HOME/.kube/config:/root/.kube/config" gcr.io/knative-releases/knative.dev/client/cmd/kn:latest service list

Note

Running kn from a container image does not place the binary on a permanent path. This procedure must be repeated each time you want to use kn.

Install kn using the nightly-built binary

Warning

Nightly container images include features which may not be included in the latest Knative release and are not considered to be stable.

Nightly-built executable binaries are available for users who want to install the latest pre-release build of kn.

Links to the latest nightly-built executable binaries are available here:

Using kn with Tekton

See the Tekton documentation.

Install the Knative Operator CLI Plugin

Before you install the Knative Operator CLI Plugin, first install the Knative CLI described earlier. The executable installed below is named kn-operator; kn discovers it as a plugin and exposes its commands as kn operator.

  1. Download the binary kn-operator-darwin-amd64 for your system from the release page.

  2. Rename the binary to kn-operator:

    mv kn-operator-darwin-amd64 kn-operator
    
  1. Download the binary kn-operator-linux-amd64 for your system from the release page.

  2. Rename the binary to kn-operator:

    mv kn-operator-linux-amd64 kn-operator
    

Make the plugin executable by running the command:

chmod +x kn-operator

Create the directory for the kn plugin:

mkdir -p ~/.config/kn/plugins

Move the file to a plugin directory for kn:

cp kn-operator ~/.config/kn/plugins

Verify the installation of the Knative Operator CLI Plugin

You can run the following command to verify the installation:

kn operator -h

You should see more information about how to use this CLI plugin.

We use analytics and cookies to understand site traffic. Information about your use of our site is shared with Google for that purpose. Learn more.