Skip to content

Commit c5de99e

Browse files
authored
Merge pull request #49542 from abrennan89/SRVOCF-426
[SRVOCF-426]: Add push flag docs for kn func build command
2 parents 4f2818f + 5a52e7e commit c5de99e

File tree

1 file changed

+46
-9
lines changed

1 file changed

+46
-9
lines changed

modules/serverless-build-func-kn.adoc

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,38 @@
66
[id="serverless-build-func-kn_{context}"]
77
= Building functions
88

9-
Before you can run a function, you must build the function project by using the `kn func build` command. This command creates an OCI container image that can be run locally on your computer or on an {product-title} cluster. The build command uses the function project name and the image registry name to construct a fully qualified image name for your function.
9+
Before you can run a function, you must build the function project. If you are using the `kn func run` command, the function is built automatically. However, you can use the `kn func build` command to build a function without running it, which can be useful for advanced users or debugging scenarios.
1010

11-
By default, `kn func build` creates a container image using the Red Hat Source-to-Image (S2I) technology. To use the link:https://buildpacks.io/[CNCF Cloud Native Buildpacks] technology instead, supply the `-b` flag:
11+
The `kn func build` command creates an OCI container image that can be run locally on your computer or on an {product-title} cluster. This command uses the function project name and the image registry name to construct a fully qualified image name for your function.
1212

13-
.Example build command
13+
[id="serverless-build-func-kn-image-containers_{context}"]
14+
== Image container types
15+
16+
By default, `kn func build` creates a container image by using Red Hat Source-to-Image (S2I) technology.
17+
18+
.Example build command using Red Hat Source-to-Image (S2I)
19+
[source,terminal]
20+
----
21+
$ kn func build
22+
----
23+
24+
You can use link:https://buildpacks.io/[CNCF Cloud Native Buildpacks] technology instead, by adding the `--builder` flag to the command and specifying the `pack` strategy:
25+
26+
.Example build command using CNCF Cloud Native Buildpacks
27+
[source,terminal]
28+
----
29+
$ kn func build --builder pack
30+
----
31+
32+
[id="serverless-build-func-kn-image-registries_{context}"]
33+
== Image registry types
34+
35+
The OpenShift Container Registry is used by default as the image registry for storing function images.
36+
37+
.Example build command using OpenShift Container Registry
1438
[source,terminal]
1539
----
16-
$ kn func build -b pack
40+
$ kn func build
1741
----
1842

1943
.Example output
@@ -23,14 +47,13 @@ Building function image
2347
Function image has been built, image: registry.redhat.io/example/example-function:latest
2448
----
2549

26-
The OpenShift Container Registry is used by default as the image registry for storing function images. You can override this by using the `-r` flag:
50+
You can override using OpenShift Container Registry as the default image registry by using the `--registry` flag:
2751

28-
.Example build command
52+
.Example build command overriding OpenShift Container Registry to use quay.io
2953
[source,terminal]
3054
----
31-
$ kn func build -r quay.io/username
55+
$ kn func build --registry quay.io/username
3256
----
33-
// removed mentioning the `FUNC_REGISTRY` environment variable because we didn't provide an example and it seems unnecessary - can add it in later if it's important
3457

3558
.Example output
3659
[source,terminal]
@@ -39,7 +62,21 @@ Building function image
3962
Function image has been built, image: quay.io/username/example-function:latest
4063
----
4164

42-
To learn more about `kn func build` command options, you can use the help command:
65+
[id="serverless-build-func-kn-push_{context}"]
66+
== Push flag
67+
68+
You can add the `--push` flag to a `kn func build` command to automatically push the function image after it is successfully built:
69+
70+
.Example build command using OpenShift Container Registry
71+
[source,terminal]
72+
----
73+
$ kn func build --push
74+
----
75+
76+
[id="serverless-build-func-kn-help_{context}"]
77+
== Help command
78+
79+
You can use the help command to learn more about `kn func build` command options:
4380

4481
.Build help command
4582
[source,terminal]

0 commit comments

Comments
 (0)