$ kn func create -r <repository> -l <runtime> -t <template> <path>
Before you can build and deploy a function, you must create it. You can create functions using the Knative (kn
) 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.
The OpenShift Serverless Operator and Knative Serving are installed on the cluster.
You have installed the Knative (kn
) CLI.
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
.
$ kn func create -l typescript -t cloudevents examplefunc
Created typescript function in /home/user/demo/examplefunc
Alternatively, you can specify a repository that contains a custom template.
$ kn func create -r https://github.com/boson-project/templates/ -l node -t hello-world examplefunc
Created node function in /home/user/demo/examplefunc
You can create a function from a Git repository by using the Developer perspective of the OpenShift Container Platform web console.
Before you can create a function by using the web console, a cluster administrator must complete the following steps:
Install the OpenShift Serverless Operator and Knative Serving on the cluster.
Install the OpenShift Pipelines Operator on the cluster.
Create the following pipeline tasks so that they are available for all namespaces on the cluster:
$ oc apply -f https://raw.githubusercontent.com/openshift-knative/kn-plugin-func/serverless-1.30/pkg/pipelines/resources/tekton/task/func-s2i/0.1/func-s2i.yaml
$ oc apply -f https://raw.githubusercontent.com/openshift-knative/kn-plugin-func/serverless-1.30/pkg/pipelines/resources/tekton/task/func-deploy/0.1/func-deploy.yaml
$ oc apply -f https://raw.githubusercontent.com/openshift-knative/kn-plugin-func/serverless-1.30/pkg/pipelines/resources/tekton/pipeline/dev-console/0.1/nodejs-pipeline.yaml
You must log into the OpenShift Container Platform web console.
You must create a project or have access to a project with the appropriate roles and permissions to create applications and other workloads in OpenShift Container Platform.
You must create or have access to a Git repository that contains the code for your function. The repository must contain a func.yaml
file and use the s2i
build strategy.
In the Developer perspective, navigate to +Add → Create Serverless function. The Create Serverless function page is displayed.
Enter a Git Repo URL that points to the Git repository that contains the code for your function.
In the Pipelines section:
Select the Build, deploy and configure a Pipeline Repository radio button to create a new pipeline for your function.
Select the Use Pipeline from this cluster radio button to connect your function to an existing pipeline in the cluster.
Click Create.
After you have created a function, you can view it in the Topology view of the Developer perspective.