Menu Close
13.5. kn func
13.5.1. 创建功能
您可以使用 kn
CLI 创建基本无服务器功能。
您可以使用模板在命令行中作为标志来指定路径、运行时、模板和存储库,或者使用 -c
标志在终端中启动交互式体验。
流程
创建功能项目:
$ kn func create -r <repository> -l <runtime> -t <template> <path>
-
支持的运行时包括
node
、go
、python
、quarkus
和typescript
。 支持的模板包括
http
和events
。示例命令
$ kn func create -l typescript -t events examplefunc
输出示例
Project path: /home/user/demo/examplefunc Function name: examplefunc Runtime: typescript Template: events Writing events to /home/user/demo/examplefunc
或者,您可以指定包含自定义模板的存储库。
示例命令
$ kn func create -r https://github.com/boson-project/templates/ -l node -t hello-world examplefunc
输出示例
Project path: /home/user/demo/examplefunc Function name: examplefunc Runtime: node Template: hello-world Writing events to /home/user/demo/examplefunc
-
支持的运行时包括