Skip to content

Installing Knative Functions

For the local-first Functions exercise, use standalone func. Follow Executable binary below, selecting the knative-v1.24.0 release for your operating system and architecture rather than a different release. Its CLI version is 0.51.0; the release tag and CLI version use different numbering. Do not use the historical v1.23 binary (0.50.0) for this selected release. This keeps the generated Go HTTP handler aligned with the next lesson.

Verify func version before proceeding. If you already have another CLI version installed, do not assume its generated template matches this exercise; use the selected release or consult the template documentation for your version. Other installation methods below are retained as alternatives, not additional steps.

You can install Knative Functions either by using the standalone func CLI, or by installing the kn func plugin that is available for the Knative kn CLI.

Installing the func CLI

To install func using Homebrew, run the following commands:

brew tap knative-extensions/kn-plugins
brew install func

If you have already installed the kn CLI by using Homebrew, the func CLI is automatically recognized as a plugin to kn, and can be referenced as kn func or func interchangeably.

Note

Use brew upgrade instead if you are upgrading from a previous version.

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

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

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

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

    Where <path-to-binary-file> is the path to the binary file you downloaded in the previous step, for example, func_darwin_amd64 or func_linux_amd64.

  3. Move the binary to a writable directory on your PATH. For example, use a directory owned by your user:

    mkdir -p "$HOME/.local/bin"
    mv func "$HOME/.local/bin/func"
    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 the CLI is working by running the command:

    func version
    
  1. Check out the func client repository and navigate to the func directory:

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

    make
    
  3. Move func into your system path, and verify that func commands are working properly. For example:

    func version
    

Run func from a container image. For example:

docker run --rm -it -v "$PWD:/workspace" -w /workspace \
  ghcr.io/knative/func/func create -l node -t http myfunc

The bind mount preserves the created myfunc project in your current host directory after the container exits. This example creates a project; building or deploying from a container requires additional runtime, registry, and cluster configuration.

For release information, see the func releases. The image above uses an unpinned tag; select a tested version for reproducible use.

Note

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

Installing the kn func CLI plugin

You can install Knative Functions as a kn CLI plugin, by downloading the executable binary for your system and placing it in the system path.

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

  2. Rename the binary to kn-func, and make it executable by running the following commands:

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

    Where <path-to-binary-file> is the path to the binary file you downloaded in the previous step, for example, func_darwin_amd64 or func_linux_amd64.

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

    mkdir -p "$HOME/.local/bin"
    mv kn-func "$HOME/.local/bin/kn-func"
    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 the CLI is working by running the command:

    kn func version
    

The separate plugin installation is not needed when following this exercise with standalone func.

Previous: Functions exercise · Next: Create a function

If you arrived from Bookstore, return to sentiment-analysis prerequisites after verifying installation.

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.