Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,8 @@ include::_attributes/common-attributes.adoc[]
toc::[]

[role="_abstract"]
After your functions have been deployed to the cluster, they can access data stored in secrets and config maps. This data can be mounted as volumes, or assigned to environment variables. You can configure this access interactively by using the Knative CLI, or by manually by editing the function configuration YAML file.

[IMPORTANT]
====
To access secrets and config maps, the function must be deployed on the cluster. This functionality is not available to a function running locally.

If a secret or config map value cannot be accessed, the deployment fails with an error message specifying the inaccessible values.
====
After you deploy functions to the cluster, they can access data in secrets and config maps. Mount this data as volumes or assign it to environment variables. Configure this access by using the Knative CLI or by editing the function configuration YAML file.

include::modules/serverless-functions-secrets-configmaps-interactively.adoc[leveloffset=+1]

include::modules/serverless-functions-secrets-configmaps-interactively-specialized.adoc[leveloffset=+1]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:_mod-docs-content-type: ASSEMBLY
[id="serverless-functions-secrets-configmaps-manually"]
== Adding function access to secrets and config maps manually
= Adding function access to secrets and config maps manually
include::_attributes/common-attributes.adoc[]
:context: serverless-functions-yaml

Expand All @@ -9,9 +9,14 @@ toc::[]
[role="_abstract"]
You can manually add configuration for accessing secrets and config maps to your function. This might be preferable to using the `kn func config` interactive utility and commands, for example when you have an existing configuration snippet.

include::modules/serverless-functions-mounting-secret-as-volume.adoc[leveloffset=+2]
include::modules/serverless-functions-mounting-configmap-as-volume.adoc[leveloffset=+2]
include::modules/serverless-functions-key-value-in-secret-to-env-variable.adoc[leveloffset=+2]
include::modules/serverless-functions-key-value-in-configmap-to-env-variable.adoc[leveloffset=+2]
include::modules/serverless-functions-all-values-in-secret-to-env-variables.adoc[leveloffset=+2]
include::modules/serverless-functions-all-values-in-configmap-to-env-variables.adoc[leveloffset=+2]
include::modules/serverless-functions-mounting-secret-as-volume.adoc[leveloffset=+1]

include::modules/serverless-functions-mounting-configmap-as-volume.adoc[leveloffset=+1]

include::modules/serverless-functions-key-value-in-secret-to-env-variable.adoc[leveloffset=+1]

include::modules/serverless-functions-key-value-in-configmap-to-env-variable.adoc[leveloffset=+1]

include::modules/serverless-functions-all-values-in-secret-to-env-variables.adoc[leveloffset=+1]

include::modules/serverless-functions-all-values-in-configmap-to-env-variables.adoc[leveloffset=+1]
18 changes: 6 additions & 12 deletions functions/configuring/serverless-functions-yaml.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,21 @@ include::_attributes/common-attributes.adoc[]
toc::[]

[role="_abstract"]
The `func.yaml` file contains the configuration for your function project. Values specified in `func.yaml` are used when you execute a `kn func` command. For example, when you run the `kn func build` command, the value in the `build` field is used. In some cases, you can override these values with command line flags or environment variables.
The `func.yaml` file has the configuration for your function project. The `kn func` command uses the values in `func.yaml`. For example, when you run kn `func build`, the command uses the value in the build field. You can override these values with command-line flags or environment variables.

include::modules/serverless-functions-func-yaml-environment-variables.adoc[leveloffset=+1]

[id="serverless-functions-annotations"]
== Adding annotations to functions

You can add Kubernetes annotations to a deployed Serverless function. Annotations enable you to attach arbitrary metadata to a function, for example, a note about the function's purpose. Annotations are added to the `annotations` section of the `func.yaml` configuration file.

There are two limitations of the function annotation feature:

* After a function annotation propagates to the corresponding Knative service on the cluster, it cannot be removed from the service by deleting it from the `func.yaml` file. You must remove the annotation from the Knative service by modifying the YAML file of the service directly, or by using the {ocp-product-title} web console.

* You cannot set annotations that are set by Knative, for example, the `autoscaling` annotations.
include::modules/serverless-adding-annotations-to-functions.adoc[leveloffset=+1]

include::modules/serverless-functions-adding-annotations.adoc[leveloffset=+1]

[id="additional-resources_serverless-functions-project-configuration"]
[role="_additional-resources"]
== Additional resources

* xref:../serverless-functions-getting-started.adoc#serverless-functions-getting-started[Getting started with functions]

* link:https://knative.dev/docs/serving/autoscaling/[Knative documentation on Autoscaling]

* link:https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/[Kubernetes documentation on managing resources for containers]

* link:https://knative.dev/docs/serving/autoscaling/concurrency/[Knative documentation on configuring concurrency]
36 changes: 21 additions & 15 deletions functions/reference/serverless-developing-go-functions.adoc
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
:_mod-docs-content-type: ASSEMBLY
[id="serverless-developing-go-functions"]
= Developing Go functions
:context: serverless-developing-go-functions
include::_attributes/common-attributes.adoc[]
:context: serverless-developing-go-functions

toc::[]

[role="_abstract"]
After you have created a Go function project, you can change the template files provided to add business logic to your function. This includes configuring function invocation and the returned headers and status codes.

:FeatureName: {FunctionsProductName} with Go
include::snippets/technology-preview.adoc[leveloffset=+2]

After you have xref:../../functions/serverless-functions-creating.adoc#serverless-create-func-kn_serverless-functions-creating[created a Go function project], you can modify the template files provided to add business logic to your function. This includes configuring function invocation and the returned headers and status codes.

[id="prerequisites_serverless-developing-go-functions"]
== Prerequisites

* Before you can develop functions, you must complete the steps in xref:../../install/configuring-serverless-functions.adoc#configuring-serverless-functions[Configuring {FunctionsProductName}].

include::modules/serverless-go-template.adoc[leveloffset=+1]

[id="serverless-developing-go-functions-about-invoking"]
== About invoking Go functions

When using the Knative (`kn`) CLI to create a function project, you can generate a project that responds to CloudEvents, or one that responds to simple HTTP requests. Go functions are invoked by using different methods, depending on whether they are triggered by an HTTP request or a CloudEvent.
include::modules/serverless-about-invoking-go-functions.adoc[leveloffset=+1]

include::modules/serverless-invoking-go-functions-http.adoc[leveloffset=+2]

include::modules/serverless-invoking-go-functions-cloudevent.adoc[leveloffset=+2]

include::modules/serverless-go-function-return-values.adoc[leveloffset=+1]

include::modules/serverless-testing-go-functions.adoc[leveloffset=+1]

[id="next-steps_serverless-developing-go-functions"]
== Next steps
[role="_additional-resources"]
== Additional resources

* link:https://golang.org/pkg/context/[Go Context]

* link:https://golang.org/pkg/net/http/#ResponseWriter[`http.ResponseWriter` parameter]

* link:https://golang.org/pkg/net/http/#Request[`http.Request` parameter]

* link:https://cloudevents.github.io/sdk-go/[CloudEvents Go SDK]

* xref:../../install/configuring-serverless-functions.adoc#configuring-serverless-functions[Configuring {FunctionsProductName}]

* xref:../../functions/serverless-functions-building.adoc#serverless-build-func-kn_serverless-functions-building[Build a function]

* xref:../../functions/serverless-functions-building.adoc#serverless-build-func-kn_serverless-functions-building[Build] and xref:../../functions/serverless-functions-deploying.adoc#serverless-deploy-func-kn_serverless-functions-deploying[deploy] a function.
* xref:../../functions/serverless-functions-deploying.adoc#serverless-deploy-func-kn_serverless-functions-deploying[deploy a function]
32 changes: 16 additions & 16 deletions functions/reference/serverless-developing-nodejs-functions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ include::_attributes/common-attributes.adoc[]
toc::[]

[role="_abstract"]
After you have xref:../../functions/serverless-functions-creating.adoc#serverless-create-func-kn_serverless-functions-creating[created a Node.js function project], you can modify the template files provided to add business logic to your function. This includes configuring function invocation and the returned headers and status codes.

[id="prerequisites_serverless-developing-nodejs-functions"]
== Prerequisites

* Before you can develop functions, you must complete the steps in xref:../../install/configuring-serverless-functions.adoc#configuring-serverless-functions[Configuring {FunctionsProductName}].
After you have created a Node.js function project, you can change the template files provided to add business logic to your function. This includes configuring function invocation and the returned headers and status codes.

include::modules/serverless-nodejs-template.adoc[leveloffset=+1]

[id="serverless-developing-nodejs-functions-about-invoking"]
== About invoking Node.js functions

When using the Knative (`kn`) CLI to create a function project, you can generate a project that responds to CloudEvents, or one that responds to simple HTTP requests. CloudEvents in Knative are transported over HTTP as a POST request, so both function types listen for and respond to incoming HTTP events.

Node.js functions can be invoked with a simple HTTP request. When an incoming request is received, functions are invoked with a `context` object as the first parameter.
include::modules/serverless-about-invoking-nodejs-functions.adoc[leveloffset=+1]

include::modules/serverless-nodejs-functions-context-objects.adoc[leveloffset=+2]

include::modules/serverless-nodejs-function-return-values.adoc[leveloffset=+1]

include::modules/serverless-testing-nodejs-functions.adoc[leveloffset=+1]
include::modules/serverless-nodejs-functions-overriding-liveness-readiness.adoc[leveloffset=+1]

include::modules/serverless-overriding-liveness-readiness-nodejs-functions.adoc[leveloffset=+1]

include::modules/serverless-nodejs-context-object-reference.adoc[leveloffset=+1]

[id="next-steps_serverless-developing-nodejs-functions"]
== Next steps
[role="_additional-resources"]
== Additional resources

* xref:../../functions/serverless-functions-creating.adoc#serverless-create-func-kn_serverless-functions-creating[created a Node.js function project]

* xref:../../functions/serverless-functions-building.adoc#serverless-build-func-kn_serverless-functions-building[Build a function]

* xref:../../functions/serverless-functions-deploying.adoc#serverless-deploy-func-kn_serverless-functions-deploying[deploy a function]

* xref:../../functions/serverless-functions-building.adoc#serverless-build-func-kn_serverless-functions-building[Build] and xref:../../functions/serverless-functions-deploying.adoc#serverless-deploy-func-kn_serverless-functions-deploying[deploy] a function.
* link:https://getpino.io/#/docs/api[Pino logging API]
30 changes: 16 additions & 14 deletions functions/reference/serverless-developing-python-functions.adoc
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
:_mod-docs-content-type: ASSEMBLY
[id="serverless-developing-python-functions"]
= Developing Python functions
:context: serverless-developing-python-functions
include::_attributes/common-attributes.adoc[]
:context: serverless-developing-python-functions

toc::[]

[role="_abstract"]
After you have xref:../../functions/serverless-functions-creating.adoc#serverless-create-func-kn_serverless-functions-creating[created a Python function project], you can modify the template files provided to add business logic to your function. This includes configuring function invocation and the returned headers and status codes.

[id="prerequisites_serverless-developing-python-functions"]
== Prerequisites
After you have created a Python function project, you can change the template files provided to add business logic to your function. This includes configuring function invocation and the returned headers and status codes.

* Before you can develop functions, you must complete the steps in xref:../../install/configuring-serverless-functions.adoc#configuring-serverless-functions[Configuring {FunctionsProductName}].

//Python function template structure
include::modules/serverless-python-template.adoc[leveloffset=+1]
//About invoking Python functions

include::modules/serverless-invoking-python-functions.adoc[leveloffset=+1]
//Python function return values

include::modules/serverless-python-function-return-values.adoc[leveloffset=+1]
//Testing Python functions

include::modules/serverless-testing-python-functions.adoc[leveloffset=+1]

[id="next-steps_serverless-developing-python-functions"]
== Next steps
[role="_additional-resources"]
== Additional resources

* xref:../../functions/serverless-functions-creating.adoc#serverless-create-func-kn_serverless-functions-creating[created a Python function project]

* xref:../../functions/serverless-functions-building.adoc#serverless-build-func-kn_serverless-functions-building[Build a function]

* xref:../../functions/serverless-functions-deploying.adoc#serverless-deploy-func-kn_serverless-functions-deploying[deploy a function]

* link:https://flask.palletsprojects.com/en/1.1.x/quickstart/#about-responses[Flask]

* xref:../../functions/serverless-functions-building.adoc#serverless-build-func-kn_serverless-functions-building[Build] and xref:../../functions/serverless-functions-deploying.adoc#serverless-deploy-func-kn_serverless-functions-deploying[deploy] a function.
* link:https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#event-data[`CloudEvent` `data` property]
28 changes: 16 additions & 12 deletions functions/reference/serverless-developing-quarkus-functions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,29 @@ include::_attributes/common-attributes.adoc[]
toc::[]

[role="_abstract"]
After you have xref:../../functions/serverless-functions-creating.adoc#serverless-create-func-kn_serverless-functions-creating[created a Quarkus function project], you can modify the template files provided to add business logic to your function. This includes configuring function invocation and the returned headers and status codes.
After you have created a Quarkus function project, you can change the template files provided to add business logic to your function. This includes configuring function invocation and the returned headers and status codes.

[id="prerequisites_serverless-developing-quarkus-functions"]
== Prerequisites

* Before you can develop functions, you must complete the setup steps in xref:../../install/configuring-serverless-functions.adoc#configuring-serverless-functions[Configuring {FunctionsProductName}].

// templates, invoking
include::modules/serverless-quarkus-template.adoc[leveloffset=+1]

include::modules/serverless-invoking-quarkus-functions.adoc[leveloffset=+1]

include::modules/serverless-quarkus-cloudevent-attributes.adoc[leveloffset=+1]
// return values

include::modules/serverless-quarkus-function-return-values.adoc[leveloffset=+1]

include::modules/serverless-functions-quarkus-return-value-types.adoc[leveloffset=+2]
// testing

include::modules/serverless-testing-quarkus-functions.adoc[leveloffset=+1]

include::modules/serverless-quarkus-functions-overriding-liveness-readiness.adoc[leveloffset=+1]

[id="next-steps_serverless-developing-quarkus-functions"]
== Next steps
[role="_additional-resources"]
== Additional resources

* xref:../../functions/serverless-functions-creating.adoc#serverless-create-func-kn_serverless-functions-creating[created a Python function project]

* xref:../../functions/serverless-functions-building.adoc#serverless-build-func-kn_serverless-functions-building[Build a function]

* xref:../../functions/serverless-functions-deploying.adoc#serverless-deploy-func-kn_serverless-functions-deploying[deploy a function]

* xref:../../functions/serverless-functions-building.adoc#serverless-build-func-kn_serverless-functions-building[Build] and xref:../../functions/serverless-functions-deploying.adoc#serverless-deploy-func-kn_serverless-functions-deploying[deploy] a function.
* xref:../../install/configuring-serverless-functions.adoc#configuring-serverless-functions[Configuring {FunctionsProductName}].
33 changes: 16 additions & 17 deletions functions/reference/serverless-developing-typescript-functions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,29 @@ include::_attributes/common-attributes.adoc[]
toc::[]

[role="_abstract"]
After you have xref:../../functions/serverless-functions-creating.adoc#serverless-create-func-kn_serverless-functions-creating[created a TypeScript function project], you can modify the template files provided to add business logic to your function. This includes configuring function invocation and the returned headers and status codes.

[id="prerequisites_serverless-developing-typescript-functions"]
== Prerequisites

* Before you can develop functions, you must complete the steps in xref:../../install/configuring-serverless-functions.adoc#configuring-serverless-functions[Configuring {FunctionsProductName}].
After you have created a TypeScript function project, you can change the template files provided to add business logic to your function. This includes configuring function invocation and the returned headers and status codes.

include::modules/serverless-typescript-template.adoc[leveloffset=+1]

[id="serverless-developing-typescript-functions-about-invoking"]
== About invoking TypeScript functions

When using the Knative (`kn`) CLI to create a function project, you can generate a project that responds to CloudEvents or one that responds to simple HTTP requests. CloudEvents in Knative are transported over HTTP as a POST request, so both function types listen for and respond to incoming HTTP events.

TypeScript functions can be invoked with a simple HTTP request. When an incoming request is received, functions are invoked with a `context` object as the first parameter.
include::modules/serverless-about-invoking-typescript-functions.adoc[leveloffset=+1]

include::modules/serverless-typescript-functions-context-objects.adoc[leveloffset=+2]

include::modules/serverless-typescript-function-return-values.adoc[leveloffset=+1]

include::modules/serverless-testing-typescript-functions.adoc[leveloffset=+1]
include::modules/serverless-typescript-functions-overriding-liveness-readiness.adoc[leveloffset=+1]

include::modules/serverless-overriding-liveness-readiness-typescript-functions.adoc[leveloffset=+1]

include::modules/serverless-typescript-context-object-reference.adoc[leveloffset=+1]

[id="next-steps_serverless-developing-typescript-functions"]
== Next steps
[role="_additional-resources"]
== Additional resources

* xref:../../functions/serverless-functions-building.adoc#serverless-build-func-kn_serverless-functions-building[Build a function]

* xref:../../functions/serverless-functions-deploying.adoc#serverless-deploy-func-kn_serverless-functions-deploying[deploy a function]

* xref:../../install/configuring-serverless-functions.adoc#configuring-serverless-functions[Configuring {FunctionsProductName}]

* xref:../../functions/serverless-functions-building.adoc#serverless-build-func-kn_serverless-functions-building[Build] and xref:../../functions/serverless-functions-deploying.adoc#serverless-deploy-func-kn_serverless-functions-deploying[deploy] a function.
* See link:https://getpino.io/#/docs/api[the Pino API documentation] for more information about logging with functions.
link:https://getpino.io/#/docs/api[the Pino API documentation]
2 changes: 1 addition & 1 deletion functions/serverless-functions-building.adoc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
:_mod-docs-content-type: ASSEMBLY
[id="serverless-functions-building"]
= Building functions
:context: serverless-functions-building
include::_attributes/common-attributes.adoc[]
:context: serverless-functions-building

toc::[]

Expand Down
Loading