mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-06 06:46:26 +01:00
52 lines
1.3 KiB
Plaintext
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
|
|
----
|