Building a function

Before you can run a function, you must build the function project by using the kn func build command. The build command reads the func.yaml file in the directory for your function to determine the image name and registry.

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: {}

If both of these values are unset, you will be prompted to provide a registry. An image name is then be derived from the registry.

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.

Procedure
  • Build a function:

    $ kn func build [-i <image> -r <registry> -p <path>]

    This step creates an OCI container image that can be run locally on your computer, or on a Kubernetes cluster.