Skip to content

Commit aa65e64

Browse files
authored
Merge pull request #45722 from abrennan89/SRVOCF-288
[SRVOCF-288] Add on-cluster build docs
2 parents f29cc8b + 916e905 commit aa65e64

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * /serverless/functions/serverless-functions-getting-started.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="serverless-functions-creating-on-cluster-builds_{context}"]
7+
= Building and deploying functions on the cluster
8+
9+
You can use the Knative (`kn`) CLI to initiate a function project build and then deploy the function directly on the cluster. To build a function project in this way, the source code for your function project must exist in a Git repository branch that is accessible to your cluster.
10+
11+
:FeatureName: {FunctionsProductName}
12+
include::snippets/technology-preview.adoc[leveloffset=+1]
13+
14+
.Prerequisites
15+
16+
* {pipelines-title} must be installed on your cluster.
17+
18+
* You have installed the OpenShift (`oc`) CLI.
19+
20+
* You have installed the Knative (`kn`) CLI.
21+
22+
.Procedure
23+
24+
. In each namespace where you want to run {pipelines-shortname} and deploy a function, you must create the following resources:
25+
26+
.. Create the functions buildpacks Tekton task to be able to build the function image:
27+
+
28+
[source,terminal]
29+
----
30+
$ oc apply -f https://raw.githubusercontent.com/openshift-knative/kn-plugin-func/serverless-1.22.0/pipelines/resources/tekton/task/func-buildpacks/0.1/func-buildpacks.yaml
31+
----
32+
33+
.. Create the `kn func` deploy Tekton task to be able to deploy the function in the pipeline:
34+
+
35+
[source,terminal]
36+
----
37+
$ oc apply -f https://raw.githubusercontent.com/openshift-knative/kn-plugin-func/serverless-1.22.0/pipelines/resources/tekton/task/func-deploy/0.1/func-deploy.yaml
38+
----
39+
40+
. Create a function:
41+
+
42+
[source,terminal]
43+
----
44+
$ kn func create <function_name> -l <runtime>
45+
----
46+
47+
. After you have created a new function project, you must add the project to a Git repository and ensure that the repository is available to the cluster. Information about this Git repository is used to update the `func.yaml` file in the next step.
48+
49+
. Update the configuration in the `func.yaml` file for your function project to enable on-cluster builds for the Git repository:
50+
+
51+
[source,yaml]
52+
----
53+
...
54+
build: git <1>
55+
git:
56+
url: <git_repository_url> <2>
57+
revision: main <3>
58+
contextDir: <directory_path> <4>
59+
...
60+
----
61+
<1> Required. Specify `git` build type.
62+
<2> Required. Specify the Git repository that contains your function's source code.
63+
<3> Optional. Specify the Git repository revision to be used. This can be a branch, tag or commit.
64+
<4> Optional. Specify the function's directory path if the function is not located in the Git repository root folder.
65+
66+
. Implement the business logic of your function. Then, use Git to commit and push the changes.
67+
68+
. Deploy your function:
69+
+
70+
[source,terminal]
71+
----
72+
$ kn func deploy
73+
----
74+
+
75+
If you are not logged into the container registry referenced in your function configuration, you are prompted to provide credentials for the remote container registry that hosts the function image:
76+
+
77+
.Example output and prompts
78+
[source,terminal]
79+
----
80+
🕕 Creating Pipeline resources
81+
Please provide credentials for image registry used by Pipeline.
82+
? Server: https://index.docker.io/v1/
83+
? Username: my-repo
84+
? Password: ********
85+
Function deployed at URL: http://test-function.default.svc.cluster.local
86+
----
87+
88+
. To update your function, commit and push new changes by using Git, then run the `kn func deploy` command again.

serverless/functions/serverless-functions-getting-started.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Before you can complete the following procedures, you must ensure that you have
1818

1919
include::modules/serverless-create-func-kn.adoc[leveloffset=+1]
2020
include::modules/serverless-build-func-kn.adoc[leveloffset=+1]
21+
include::modules/serverless-functions-on-cluster-builds.adoc[leveloffset=+1]
2122
include::modules/serverless-deploy-func-kn.adoc[leveloffset=+1]
2223
include::modules/serverless-kn-func-invoke.adoc[leveloffset=+1]
2324

0 commit comments

Comments
 (0)