×

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

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

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, if you use the 1.16.0 release of the kn CLI, which uses version 0.22.0, with the 1.17.0 OpenShift Serverless release, which uses the 0.23.0 versions of the Knative Serving and Knative Eventing APIs, the CLI does not work because it continues to look for the outdated 0.22.0 API versions.

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

Installing the Knative CLI using the OpenShift Dedicated web console

Using the OpenShift Dedicated web console provides a streamlined and intuitive user interface to install the Knative (kn) CLI. After the OpenShift Serverless Operator is installed, 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 Dedicated web console.

Prerequisites
  • You have logged in to the OpenShift Dedicated web console.

  • The OpenShift Serverless Operator is installed on your OpenShift Dedicated cluster.

    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 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 drop-down menu.

  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

Installing the Knative CLI for Linux by using an RPM package manager

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 like dnf upgrade upgrades all packages, including kn, if a new version is available.

Prerequisites
  • You have an active OpenShift Dedicated 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> (1)
    1 Pool ID for an active OpenShift Dedicated subscription
  4. Enable the repositories required by the Knative (kn) CLI:

    # subscription-manager repos --enable="openshift-serverless-1-for-rhel-8-x86_64-rpms"
  5. Install the Knative (kn) CLI as an RPM by using a package manager:

    Example yum command
    # yum install openshift-serverless-clients

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.

    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 Knative (kn) CLI tar.gz archive.

  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

Installing the Knative CLI for Linux on IBM Power using an RPM

For Red Hat Enterprise Linux (RHEL), you can install the kn CLI as an RPM if you have an active OpenShift Dedicated subscription on your Red Hat account.

Procedure
  1. Register with a Red Hat Subscription Management (RHSM) service during the firstboot process:

    # subscription-manager register
  2. Refresh the RHSM:

    # subscription-manager refresh
  3. Attach the subscription to a system by specifying ID of the subscription pool, using the --pool option:

    # subscription-manager attach --pool=<pool_id> (1)
    1 Pool ID for an active OpenShift Dedicated subscription
  4. Enable the repository using Red Hat Subscription Manager:

    # subscription-manager repos --enable="openshift-serverless-1-for-rhel-8-ppc64le-rpms"
  5. Install the openshift-serverless-clients on the system:

    # yum install openshift-serverless-clients

Installing the Knative CLI for Linux on IBM Power

For Linux distributions, you can download the Knative CLI (kn) directly as a tar.gz archive.

Procedure
  1. Download the kn CLI.

  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

    If you do not use RHEL, ensure that libc is installed in a directory on your library path.

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

    $ kn: No such file or directory

Installing the Knative CLI for Linux on IBM Z and LinuxONE using an RPM

For Red Hat Enterprise Linux (RHEL), you can install the kn CLI as an RPM if you have an active OpenShift Dedicated subscription on your Red Hat account.

Procedure
  1. Register with a Red Hat Subscription Management (RHSM) service during the firstboot process:

    # subscription-manager register
  2. Refresh the RHSM:

    # subscription-manager refresh
  3. Attach the subscription to a system by specifying ID of the subscription pool, using the --pool option:

    # subscription-manager attach --pool=<pool_id> (1)
    1 Pool ID for an active OpenShift Dedicated subscription
  4. Enable the repository using Red Hat Subscription Manager:

    # subscription-manager repos --enable="openshift-serverless-1-for-rhel-8-s390x-rpms"
  5. Install the openshift-serverless-clients on the system:

    # yum install openshift-serverless-clients

Installing the Knative CLI for Linux on IBM Z and LinuxONE

For Linux distributions, you can download the kn CLI directly as a tar.gz archive.

Procedure
  1. Download the kn CLI.

  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

    If you do not use RHEL, ensure that libc is installed in a directory on your library path.

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

    $ kn: No such file or directory

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

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.

  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