1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-06 15:46:57 +01:00
Files
openshift-docs/modules/serverless-create-func-kn.adoc
Maxim Svistunov 3b64d1d11a Document the -r <repository> option of the kn func create command
Change argument order in a command
2021-10-20 16:16:17 +00:00

52 lines
1.3 KiB
Plaintext

[id="serverless-create-func-kn_{context}"]
= Creating functions
You can create a basic serverless function using the `kn` CLI.
You can specify the path, runtime, template, and repository with the template as flags on the command line, or use the `-c` flag to start the interactive experience in the terminal.
.Procedure
* Create a function project:
+
[source,terminal]
----
$ kn func create -r <repository> -l <runtime> -t <template> <path>
----
** Supported runtimes include `node`, `go`, `python`, `quarkus`, and `typescript`.
** Supported templates include `http` and `events`.
+
.Example command
[source,terminal]
----
$ kn func create -l typescript -t events examplefunc
----
+
.Example output
[source,terminal]
----
Project path: /home/user/demo/examplefunc
Function name: examplefunc
Runtime: typescript
Template: events
Writing events to /home/user/demo/examplefunc
----
+
** Alternatively, you can specify a repository that contains a custom template.
+
.Example command
[source,terminal]
----
$ kn func create -r https://github.com/boson-project/templates/ -l node -t hello-world examplefunc
----
+
.Example output
[source,terminal]
----
Project path: /home/user/demo/examplefunc
Function name: examplefunc
Runtime: node
Template: hello-world
Writing events to /home/user/demo/examplefunc
----