This is a cache of https://docs.openshift.com/serverless/1.28/functions/serverless-functions-creating.html. It is a snapshot of the page at 2024-11-25T17:11:46.308+0000.
Creating functions | Functions | Red Hat OpenShift Serverless 1.28
×

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

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 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