Templates and runtimes¶
Knative Functions includes built-in language runtimes and templates, and lets you pull custom templates from Git repositories via language packs.
Choose a runtime¶
Pass -l <language> to func create. Built-in runtimes:
| Runtime | -l value |
|---|---|
| Go | go |
| Node.js | node |
| TypeScript | typescript |
| Python | python |
| Quarkus (Java) | quarkus |
| Spring Boot (Java) | springboot |
| Rust | rust |
Choose HTTP or CloudEvents¶
Pass -t <template> to func create (default http):
http— handles standard HTTP requests and responses.cloudevents— receives and optionally returns CloudEvents; use this when connecting a function to Knative Eventing or Kafka.
func create -l python -t cloudevents my-event-fn
Use an external repository¶
To scaffold a function from a remote Git template repository without installing
it locally, pass --repository:
func create -l go \
--template <template-name> \
--repository <git-repo-url> \
my-function
Verify the generated my-function/ directory contains func.yaml and the
expected template files.
Installed repositories¶
Install a trusted template repository locally with func repository so you can
reuse its templates by name:
-
Add the repository and verify it appears in the list:
func repository add my-pack <git-repo-url> func repository listThe output lists
defaultalongsidemy-pack. -
Create a function using
<repo-name>/<template-name>:func create -l go -t my-pack/<template-name> my-function -
Rename or remove installed repositories when needed:
func repository rename my-pack renamed-pack func repository remove renamed-pack
For all repository flags, see the
func repository reference.
To author your own language pack, see the
language pack contract.