×

Before you can build and deploy a function, you must create it. You can create functions using the Knative (kn) CLI.

Creating a function by using the Knative CLI

You can specify the path, runtime, template, and image registry for a function as flags on the command line, or use the -c flag to start the interactive experience in the terminal.

Prerequisites
  • The OpenShift Serverless Operator and Knative Serving are installed on the cluster.

  • You have installed the Knative (kn) CLI.

Procedure
  • Create a function project:

    $ 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
      $ kn func create -l typescript -t cloudevents examplefunc
      Example output
      Created typescript function in /home/user/demo/examplefunc
    • Alternatively, you can specify a repository that contains a custom template.

      Example command
      $ kn func create -r https://github.com/boson-project/templates/ -l node -t hello-world examplefunc
      Example output
      Created node function in /home/user/demo/examplefunc