Chapter 3. Installing the Knative CLI


The Knative (kn) CLI does not have its own login mechanism. To log in to the cluster, you must install the OpenShift CLI (oc) and use the oc login command. Installation options for the command-line interface (CLI) can vary depending on your operating system.

You cannot install OpenShift Serverless by using the Knative (kn) CLI. A cluster administrator must install the OpenShift Serverless Operator and set up the Knative components, as described in the OpenShift Serverless Operator documentation.

Using the OpenShift Container Platform web console provides a streamlined and intuitive user interface to install the Knative (kn) CLI. Once you install the OpenShift Serverless Operator, you will see a link to download the Knative (kn) CLI for Linux (amd64, s390x, ppc64le), macOS, or Windows from the Command Line Tools page in the OpenShift Container Platform web console.

Important

If you try to use an older version of the Knative (kn) CLI with a newer OpenShift Serverless release, the API is not found and an error occurs.

For example, the 1.23.0 release of the Knative (kn) CLI uses version 1.2. The 1.24.0 OpenShift Serverless release uses version 1.3 of the Knative Serving and Knative Eventing APIs. The CLI fails because it looks for the outdated 1.2 API versions.

Ensure that you are using the latest Knative (kn) CLI version for your OpenShift Serverless release to avoid issues.

Prerequisites

  • You have logged in to the OpenShift Container Platform web console.
  • You have installed the OpenShift Serverless Operator and Knative Serving on your OpenShift Container Platform cluster.

    Important

    If libc is not available, you might see the following error when you run CLI commands:

    $ kn: No such file or directory
  • If you want to use the verification steps for this procedure, you must install the OpenShift (oc) CLI.

Procedure

  1. Download the Knative (kn) CLI from the Command Line Tools page. You can access the Command Line Tools page by clicking the question circle icon in the top right corner of the web console and selecting Command Line Tools in the list.
  2. Unpack the archive:

    $ tar -xf <file>
  3. Move the kn binary to a directory on your PATH.
  4. To check your PATH, run:

    $ echo $PATH

Verification

  • Run the following commands to check that the correct Knative CLI resources and route have been created:

    $ oc get ConsoleCLIDownload

    You get an output similar to the following example:

    NAME                  DISPLAY NAME                                             AGE
    kn                    kn - OpenShift Serverless Command Line Interface (CLI)   2022-09-20T08:41:18Z
    oc-cli-downloads      oc - OpenShift Command Line Interface (CLI)              2022-09-20T08:00:20Z
    $ oc get route -n openshift-serverless

    You get an output similar to the following example:

    NAME   HOST/PORT                                  PATH   SERVICES                      PORT       TERMINATION     WILDCARD
    kn     kn-openshift-serverless.apps.example.com          knative-openshift-metrics-3   http-cli   edge/Redirect   None

For Red Hat Enterprise Linux (RHEL), you can install the Knative (kn) CLI as an RPM by using a package manager, such as yum or dnf. This allows the Knative CLI version to be automatically managed by the system. For example, using a command such as dnf upgrade upgrades all packages, including kn, if a new version is available.

Prerequisites

  • You have an active OpenShift Container Platform subscription on your Red Hat account.

Procedure

  1. Register with Red Hat Subscription Manager:

    # subscription-manager register
  2. Pull the latest subscription data:

    # subscription-manager refresh
  3. Attach the subscription to the registered system:

    # subscription-manager attach --pool=<pool_id>
    <pool_id>
    Pool ID for an active OpenShift Container Platform subscription
  4. Enable the repositories required by the Knative (kn) CLI:

    • Linux (x86_64, amd64)

      # subscription-manager repos --enable="openshift-serverless-1-for-rhel-9-x86_64-rpms"
    • Linux on IBM zSystems and IBM® LinuxONE (s390x)

      # subscription-manager repos --enable="openshift-serverless-1-for-rhel-9-s390x-rpms"
    • Linux on IBM Power (ppc64le)

      # subscription-manager repos --enable="openshift-serverless-1-for-rhel-9-ppc64le-rpms"
  5. Install the Knative (kn) CLI as an RPM by using a package manager similar to the following example:

    # yum install openshift-serverless-clients

You can use a Knative (kn) CLI version that is in the Maintenance Phase, even if it is not the most recent. Lock the kn version to prevent upgrades.

Procedure

  1. Install the versionlock plugin for the DNF package manager:

    # dnf install 'dnf-command(versionlock)'
  2. Lock the version of kn by running:

    # dnf versionlock add --raw 'openshift-serverless-clients-1.7.*'

    This command locks kn to be the version based on Knative 1.7, which is in Maintenance Phase at the time of release of OpenShift Serverless 1.29.

3.4. Upgrading the Knative CLI with locked version

You can manually upgrade the Knative (kn) CLI version after you remove the version lock.

Procedure

  1. Check whether upgraded packages are available:

    # dnf search --showduplicates openshift-serverless-clients
  2. Remove the version lock of kn:

    # dnf versionlock delete openshift-serverless-clients
  3. Lock kn to the new version:

    # dnf versionlock add --raw 'openshift-serverless-clients-1.8.*'

    This example uses the kn version that is based on Knative 1.8.

  4. Upgrade to the new available version:

    # dnf install --upgrade openshift-serverless-clients

3.5. Installing the Knative CLI for Linux

If you are using a Linux distribution that does not have RPM or another package manager installed, you can install the Knative (kn) CLI as a binary file. To do this, you must download and unpack a tar.gz archive and add the binary to a directory on your PATH.

Prerequisites

  • If you are not using RHEL or Fedora, ensure that libc is installed in a directory on your library path.

    Important

    If libc is not available, you might see the following error when you run CLI commands:

    $ kn: No such file or directory

Procedure

  1. Download the relevant Knative (kn) CLI tar.gz archive:

    You can also download any version of kn by navigating to that version’s corresponding directory in the Serverless client download mirror.

  2. Unpack the archive:

    $ tar -xf <filename>
  3. Move the kn binary to a directory on your PATH.
  4. To check your PATH, run:

    $ echo $PATH

3.6. Installing the Knative CLI for macOS

If you are using macOS, you can install the Knative (kn) CLI as a binary file. To do this, you must download and unpack a tar.gz archive and add the binary to a directory on your PATH.

Procedure

  1. Download the relevant Knative (kn) CLI tar.gz archive:

  2. Unpack and extract the archive.
  3. Move the kn binary to a directory on your PATH.
  4. To check your PATH, open a terminal window and run:

    $ echo $PATH

3.7. Installing the Knative CLI for Windows

If you are using Windows, you can install the Knative (kn) CLI as a binary file. To do this, you must download and unpack a ZIP archive and add the binary to a directory on your PATH.

Procedure

  1. Download the Knative (kn) CLI ZIP archive.

    You can also download any version of kn by navigating to that version’s corresponding directory in the Serverless client download mirror.

  2. Extract the archive with a ZIP program.
  3. Move the kn binary to a directory on your PATH.
  4. To check your PATH, open the Command Prompt and run the command:

    C:\> path
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2026 Red Hat
Back to top