1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 21:46:22 +01:00
Files
openshift-docs/modules/serverless-create-func-kn.adoc
Ashleigh Brennan a535c0126c Add kn func CLI docs
2021-05-20 17:37:48 +00:00

54 lines
1.4 KiB
Plaintext

// Module included in the following assemblies:
//
// * serverless/serverless-functions-getting-started.adoc
[id="serverless-create-func-kn_{context}"]
= Creating functions
You can create a basic serverless function using the `kn` CLI.
You can specify the runtime, trigger, image, and namespace as flags on the command line, or use the `-c` flag to start the interactive experience using the CLI prompt.
The values provided for image and registry are persisted to the `func.yaml` file, so that subsequent invocations do not require the user to specify these again.
.Example `func.yaml`
[source,yaml]
----
name: example-function
namespace: default
runtime: node
image: <image_from_registry>
imageDigest: ""
trigger: http
builder: default
builderMap:
default: quay.io/boson/faas-nodejs-builder
envVars: {}
----
.Procedure
* Create a function project:
+
[source,terminal]
----
$ kn func create <path> -r <registry> -l <runtime> -t <trigger> -i <image> -n <namespace>
----
** Supported runtimes include `node`, `go`, `python`, and `quarkus`.
** If the image is unspecified, you are prompted for a registry name. The image name is derived from this registry and the function name.
+
.Example command
[source,terminal]
----
$ kn func create functions/example-function
----
+
.Example output
[source,terminal]
----
Project path: /home/user/functions/example-function
Function name: example-function
Runtime: node
Trigger: http
----