mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
63 lines
1.6 KiB
Plaintext
63 lines
1.6 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * serverless/functions/serverless-functions-getting-started.adoc
|
|
// * serverless/reference/kn-func-ref.adoc
|
|
|
|
:_content-type: PROCEDURE
|
|
[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.
|
|
|
|
.Prerequisites
|
|
|
|
* The {ServerlessOperatorName} and Knative Serving are installed on the cluster.
|
|
* You have installed the `kn` CLI.
|
|
|
|
.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
|
|
----
|