Installing the Knative CLI

This guide provides details about how you can install the Knative kn CLI.

Verifying CLI binaries

Knative kn CLI releases from 1.9 onwards are signed with cosign. You can use the following steps to verify the CLI binaries:

  1. Download the files you want, and the checksums.txt, checksum.txt.pem, and checksums.txt.sig files from the releases page, by running the commands:

    1. wget https://github.com/knative/client/releases/download/<kn-version>/checksums.txt
    2. wget https://github.com/knative/client/releases/download/<kn-version>/kn-darwin-amd64
    3. wget https://github.com/knative/client/releases/download/<kn-version>/checksums.txt.sig
    4. wget https://github.com/knative/client/releases/download/<kn-version>/checksums.txt.pem

    Where <kn-version> is the version of the CLI that you want to verify. For example, knative-v1.8.0.

  2. Verify the signature by running the command:

    1. cosign verify-blob \
    2. --cert checksums.txt.pem \
    3. --signature checksums.txt.sig \
    4. --certificate-identity=signer@knative-releases.iam.gserviceaccount.com \
    5. --certificate-oidc-issuer=https://accounts.google.com \
    6. checksums.txt
  3. If the signature is valid, you can then verify the SHA256 sums match the downloaded binary, by running the command:

    1. sha256sum --ignore-missing -c checksums.txt

Note

Knative images are signed in KEYLESS mode. To learn more about keyless signing, please refer to Keyless Signatures. The signing identity for Knative releases is signer@knative-releases.iam.gserviceaccount.com, and the issuer is https://accounts.google.com.

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.

Using HomebrewUsing a binaryUsing GoUsing a container image

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):

    1. brew install knative/client/kn

    Having issues upgrading kn using Homebrew?

    If you are having issues upgrading using Homebrew, it might be due to a change to a CLI repository where the master branch was renamed to main. Resolve this issue by running the command:

    1. brew uninstall kn
    2. brew untap knative/client --force
    3. 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:

    1. mv <path-to-binary-file> kn
    2. 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 binary file to a directory on your PATH by running the command:

    1. mv kn /usr/local/bin
  4. Verify that kn commands are working properly. For example:

    1. kn version
  5. Check out the kn client repository:

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

    1. hack/build.sh -f
  7. Move the executable binary file to a directory on your PATH by running the command:

    1. mv kn /usr/local/bin
  8. Verify that kn commands are working properly. For example:

    1. kn version

Links to images are available here:

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

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