Skip to content

Commit 1736101

Browse files
authored
Merge pull request #51032 from rh-max/srvls-functions-updates
[SRVOCF-438] Serverless functions - updates and additions
2 parents f186d46 + 94afd7c commit 1736101

File tree

4 files changed

+82
-21
lines changed

4 files changed

+82
-21
lines changed

modules/serverless-create-func-kn.adoc

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
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.
1111

12+
:FeatureName: {FunctionsProductName}
13+
include::snippets/technology-preview.adoc[leveloffset=+1]
14+
1215
.Prerequisites
1316

1417
* The {ServerlessOperatorName} and Knative Serving are installed on the cluster.
@@ -22,23 +25,19 @@ Before you can build and deploy a function, you must create it by using the Knat
2225
----
2326
$ kn func create -r <repository> -l <runtime> -t <template> <path>
2427
----
25-
** Accepted runtime values include `node`, `go`, `python`, `quarkus`, and `typescript`.
26-
** Accepted template values include `http` and `events`.
28+
** Accepted runtime values include `quarkus`, `node`, `typescript`, `go`, `python`, `springboot`, and `rust`.
29+
** Accepted template values include `http` and `cloudevents`.
2730
+
2831
.Example command
2932
[source,terminal]
3033
----
31-
$ kn func create -l typescript -t events examplefunc
34+
$ kn func create -l typescript -t cloudevents examplefunc
3235
----
3336
+
3437
.Example output
3538
[source,terminal]
3639
----
37-
Project path: /home/user/demo/examplefunc
38-
Function name: examplefunc
39-
Runtime: typescript
40-
Template: events
41-
Writing events to /home/user/demo/examplefunc
40+
Created typescript function in /home/user/demo/examplefunc
4241
----
4342
+
4443
** Alternatively, you can specify a repository that contains a custom template.
@@ -52,9 +51,5 @@ $ kn func create -r https://github.com/boson-project/templates/ -l node -t hello
5251
.Example output
5352
[source,terminal]
5453
----
55-
Project path: /home/user/demo/examplefunc
56-
Function name: examplefunc
57-
Runtime: node
58-
Template: hello-world
59-
Writing events to /home/user/demo/examplefunc
54+
Created node function in /home/user/demo/examplefunc
6055
----
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * serverless/functions/serverless-functions-setup.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="serverless-functions-podman-macos_{context}"]
7+
= Setting up podman on macOS
8+
9+
To use advanced container management features, you might want to use podman with {FunctionsProductName}. To do so on macOS, you need to start the podman machine and configure the Knative (`kn`) CLI to connect to it.
10+
11+
.Procedure
12+
13+
. Create the podman machine:
14+
+
15+
[source,terminal]
16+
----
17+
$ podman machine init --memory=8192 --cpus=2 --disk-size=20
18+
----
19+
20+
. Start the podman machine, which serves the Docker API on a UNIX socket:
21+
+
22+
[source,terminal]
23+
----
24+
$ podman machine start
25+
Starting machine "podman-machine-default"
26+
Waiting for VM ...
27+
Mounting volume... /Users/myuser:/Users/user
28+
29+
[...truncated output...]
30+
31+
You can still connect Docker API clients by setting DOCKER_HOST using the
32+
following command in your terminal session:
33+
34+
export DOCKER_HOST='unix:///Users/myuser/.local/share/containers/podman/machine/podman-machine-default/podman.sock'
35+
36+
Machine "podman-machine-default" started successfully
37+
----
38+
+
39+
[NOTE]
40+
====
41+
On most macOS systems, this socket is located at `/Users/myuser/.local/share/containers/podman/machine/podman-machine-default/podman.sock`.
42+
====
43+
44+
. Establish the environment variable that is used to build a function:
45+
+
46+
[source,terminal]
47+
----
48+
$ export DOCKER_HOST='unix:///Users/myuser/.local/share/containers/podman/machine/podman-machine-default/podman.sock'
49+
----
50+
51+
. Run the build command inside your function project directory with the `-v` flag to see verbose output. You should see a connection to your local UNIX socket:
52+
+
53+
[source,terminal]
54+
----
55+
$ kn func build -v
56+
----

modules/serverless-kn-func-invoke.adoc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,25 @@
33
// * serverless/functions/serverless-functions-getting-started.adoc
44
// * serverless/reference/kn-func-ref.adoc
55

6-
:_content-type: REFERENCE
6+
:_content-type: PROCEDURE
77
[id="serverless-kn-func-invoke_{context}"]
88
= Invoking a deployed function with a test event
99

1010
You can use the `kn func invoke` CLI command to send a test request to invoke a function either locally or on your {product-title} cluster. This command can be used to test that a function is working and able to receive events correctly.
1111

12-
.Example command
12+
.Prerequisites
13+
14+
* The {ServerlessOperatorName} and Knative Serving are installed on the cluster.
15+
* You have installed the Knative (`kn`) CLI.
16+
* You have created a project or have access to a project with the appropriate roles and permissions to create applications and other workloads in {product-title}.
17+
* You must have already deployed the function that you want to invoke.
18+
19+
.Procedure
20+
21+
* Invoke a function:
22+
+
1323
[source,terminal]
1424
----
1525
$ kn func invoke
1626
----
17-
18-
The `kn func invoke` command executes on the local directory by default, and assumes that this directory is a function project.
27+
** The `kn func invoke` command executes on the local directory by default, and assumes that this directory is a function project.

serverless/functions/serverless-functions-setup.adoc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ Functions are deployed as a Knative service. If you want to use event-driven arc
2424
====
2525

2626
ifdef::openshift-enterprise[]
27-
* The xref:../../cli_reference/openshift_cli/getting-started-cli.adoc#cli-getting-started[`oc` CLI] is installed on your cluster.
27+
* You have the xref:../../cli_reference/openshift_cli/getting-started-cli.adoc#cli-getting-started[`oc` CLI] installed.
2828
endif::[]
2929
// need to wait til CLI docs are added to OSD and ROSA for this link to work
3030
// TODO: remove these conditionals once this is available
3131
ifdef::openshift-dedicated,openshift-rosa[]
32-
* The `oc` CLI is installed on your cluster.
32+
* You have the `oc` CLI installed.
3333
endif::[]
3434

35-
* The xref:../../serverless/cli_tools/installing-kn.adoc#installing-kn[Knative (`kn`) CLI] is installed on your cluster. Installing the Knative CLI enables the use of `kn func` commands which you can use to create and manage functions.
35+
* You have the xref:../../serverless/cli_tools/installing-kn.adoc#installing-kn[Knative (`kn`) CLI] installed. Installing the Knative CLI enables the use of `kn func` commands which you can use to create and manage functions.
3636

37-
* You have installed Docker Container Engine or podman version 3.3 or higher, and have access to an available image registry.
37+
* You have installed Docker Container Engine or podman version 3.4.7 or higher, and have access to an available image registry, such as the OpenShift Container Registry.
3838

3939
ifdef::openshift-enterprise[]
4040
* If you are using link:https://quay.io/[Quay.io] as the image registry, you must ensure that either the repository is not private, or that you have followed the {product-title} documentation on xref:../../openshift_images/managing_images/using-image-pull-secrets.adoc#images-allow-pods-to-reference-images-from-secure-registries_using-image-pull-secrets[Allowing pods to reference images from other secured registries].
@@ -55,6 +55,7 @@ ifdef::openshift-dedicated,openshift-rosa[]
5555
endif::[]
5656

5757
include::modules/serverless-functions-podman.adoc[leveloffset=+1]
58+
include::modules/serverless-functions-podman-macos.adoc[leveloffset=+1]
5859

5960
[id="next-steps_serverless-functions-setup"]
6061
== Next steps

0 commit comments

Comments
 (0)