Installing Knative Functions¶
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.
Match the Knative release and CLI version
Knative release tags and the Functions CLI version number are different. For Knative v1.24.0 (knative-v1.24.0 release), the release build sets the CLI version to v0.51.0, not 1.24.0. Check your actual artifact with func version --verbose or kn func version --verbose, recording the reported CLI version, Knative version, and commit when available.
Earlier checks of the knative-v1.23.0 release reported 0.50.0; those results are historical, not validation of v1.24. References to Functions from Knative v1.24.0 name the release/source tag. Use the corresponding upstream reference: a current Homebrew package or a build from main does not necessarily install that release.
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.
-
Download the binary for your system from the
funcrelease page. -
Rename the binary to
funcand make it executable by running the following commands:mv <path-to-binary-file> funcchmod +x funcWhere
<path-to-binary-file>is the path to the binary file you downloaded in the previous step, for example,func_darwin_amd64orfunc_linux_amd64. -
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 sameexportto your shell's startup configuration for future terminals. -
Verify that the CLI is working by running the command:
func version
-
Check out the
funcclient repository and navigate to thefuncdirectory:git clone https://github.com/knative/func.git funccd func/ -
Build an executable binary:
make -
Move
funcinto your system path, and verify thatfunccommands 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.
-
Download the binary for your system from the
funcrelease page. -
Rename the binary to
kn-func, and make it executable by running the following commands:mv <path-to-binary-file> kn-funcchmod +x kn-funcWhere
<path-to-binary-file>is the path to the binary file you downloaded in the previous step, for example,func_darwin_amd64orfunc_linux_amd64. -
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 sameexportto your shell's startup configuration for future terminals. -
Verify that the CLI is working by running the command:
kn func version