安装 Knative 函数¶
您可以通过使用独立的 func 命令行安装Knative函数,或者通过安装可用于Knative kn 命令行的 kn func 插件。
安装 func 命令行¶
要使用Homebrew安装 func,运行以下命令:
brew tap knative-sandbox/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 executable binary file to a directory on your PATH by running the command:
mv func /usr/local/bin -
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
从容器映像运行 func。例如:
docker run --rm -it ghcr.io/knative/func/func create -l node -t http myfunc
Links to images are available here:
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.
安装 kn func 命令行插件¶
通过下载系统的可执行二进制文件并将其放在系统路径中,您可以将Knative函数作为 kn CLI插件安装。
-
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 binary file to a directory on your PATH by running the command:
mv kn-func /usr/local/bin -
Verify that the CLI is working by running the command:
kn func version