Creating functions

You can create a function by using the kn func create command.

Example command
$ kn func create <path> -r <registry> -l <runtime> -t <trigger> -i <image> -n <namespace> -c

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 value(s) 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
name: fn.example.io
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 Functions project:

    $ kn func create <path> -r <registry> -l <runtime> -t <trigger> -i <image> -n <namespace>

    If the image is unspecified, you will be prompted for a registry name. The image name will be derived from this registry and the function name.

    Example command
    $ kn func create functions/fn.example.io
    Example output
    Project path: /home/user/functions/fn.example.io
    Function name: fn.example.io
    Runtime: go
    Trigger: http