mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
53 lines
1.5 KiB
Plaintext
53 lines
1.5 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * serverless/functions/serverless-functions-getting-started.adoc
|
|
// * serverless/reference/kn-func-ref.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="serverless-create-func-kn_{context}"]
|
|
= Creating functions
|
|
|
|
Before you can build and deploy a function, you must create it by using the Knative (`kn`) CLI. You can specify the path, runtime, template, and image registry 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 Knative (`kn`) CLI.
|
|
|
|
.Procedure
|
|
|
|
* Create a function project:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ kn func create -r <repository> -l <runtime> -t <template> <path>
|
|
----
|
|
** Accepted runtime values include `quarkus`, `node`, `typescript`, `go`, `python`, `springboot`, and `rust`.
|
|
** Accepted template values include `http` and `cloudevents`.
|
|
+
|
|
.Example command
|
|
[source,terminal]
|
|
----
|
|
$ kn func create -l typescript -t cloudevents examplefunc
|
|
----
|
|
+
|
|
.Example output
|
|
[source,terminal]
|
|
----
|
|
Created typescript function in /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]
|
|
----
|
|
Created node function in /home/user/demo/examplefunc
|
|
----
|