From 253bbc7388e6a6b10c675dd252606a76249cf6ab Mon Sep 17 00:00:00 2001 From: wrongerror Date: Fri, 5 Aug 2022 16:46:43 +0800 Subject: [PATCH] change the function access method from Domain to Gateway Signed-off-by: wrongerror --- .gitignore | 1 + functions/knative/hello-world-go/README.md | 33 +++++++++++------ .../knative/multiple-functions-go/README.md | 30 +++++++++++----- .../knative/with-output-binding/README.md | 35 +++++++++++++------ 4 files changed, 70 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 65c3e7c..43a1a1f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ # Dependency directories (remove the comment below to include it) # vendor/ +.idea/ .vscode/ .venv/ diff --git a/functions/knative/hello-world-go/README.md b/functions/knative/hello-world-go/README.md index cb7e448..1eb9c79 100644 --- a/functions/knative/hello-world-go/README.md +++ b/functions/knative/hello-world-go/README.md @@ -68,27 +68,40 @@ You can create this secret by editing the ``REGISTRY_SERVER``, ``REGISTRY_USER`` ```shell kubectl get functions.core.openfunction.io - NAME BUILDSTATE SERVINGSTATE BUILDER SERVING URL AGE - function-sample Succeeded Running builder-jgnzp serving-q6wdp http://openfunction.io/default/function-sample 22m + NAME BUILDSTATE SERVINGSTATE BUILDER SERVING ADDRESS AGE + function-sample Succeeded Running builder-jgnzp serving-q6wdp http://function-sample.default.ofn.io/ 22m ``` - The `URL` is the address provided by the OpenFunction Domain that can be accessed. To access the function via this URL address, you need to make sure that DNS can resolve this address. + The `Function.status.addresses` field provides various methods for accessing functions. + Get `Function` addresses by running following command: + ```shell + kubectl get function function-sample -o=jsonpath='{.status.addresses}' + ``` + You will get the following address: + ```json + [{"type":"External","value":"http://function-sample.default.ofn.io/"}, + {"type":"Internal","value":"http://function-sample.default.svc.cluster.local/"}] + ``` > You can use the following command to create a pod in the cluster and access the function from the pod: > > ```shell > kubectl run curl --image=radial/busyboxplus:curl -i --tty > ``` - - Access the function via `URL`: - + + Access functions by the internal address: ```shell - [ root@curl:/ ]$ curl http://openfunction.io.svc.cluster.local/default/function-sample/World - Hello, World! - - [ root@curl:/ ]$ curl http://openfunction.io.svc.cluster.local/default/function-sample/OpenFunction + [ root@curl:/ ]$ curl http://function-sample.default.svc.cluster.local/OpenFunction Hello, OpenFunction! ``` + + Access functions by the external address: + > To access the function via the Address of type `External` in `Funtion.status`, you should configure local domain first, see [Configure Local Domain](https://openfunction.dev/docs/concepts/networking/local-domain). + + ```shell + [ root@curl:/ ]$ curl http://function-sample.default.ofn.io/World + Hello, World! + ``` There is also an alternative way to trigger the function via the access address provided by the Knative Services: diff --git a/functions/knative/multiple-functions-go/README.md b/functions/knative/multiple-functions-go/README.md index 72142b1..a63bf2b 100644 --- a/functions/knative/multiple-functions-go/README.md +++ b/functions/knative/multiple-functions-go/README.md @@ -73,24 +73,36 @@ You can create this secret by editing the ``REGISTRY_SERVER``, ``REGISTRY_USER`` kubectl get functions.core.openfunction.io NAME BUILDSTATE SERVINGSTATE BUILDER SERVING URL AGE - function-sample Succeeded Running builder-jgnzp serving-q6wdp http://openfunction.io/default/function-sample 22m + function-sample Succeeded Running builder-jgnzp serving-q6wdp http://function-sample.default.ofn.io/ 22m ``` - - The `URL` is the address provided by the OpenFunction Domain that can be accessed. To access the function via this URL address, you need to make sure that DNS can resolve this address. + The `Function.status.addresses` field provides various methods for accessing functions. + Get `Function` addresses by running following command: + ```shell + kubectl get function function-sample -o=jsonpath='{.status.addresses}' + ``` + You will get the following address: + ```json + [{"type":"External","value":"http://function-sample.default.ofn.io/"}, + {"type":"Internal","value":"http://function-sample.default.svc.cluster.local/"}] + ``` > You can use the following command to create a pod in the cluster and access the function from the pod: > > ```shell > kubectl run curl --image=radial/busyboxplus:curl -i --tty > ``` - - Access the function via `URL`: - + + Access functions by the internal address: ```shell - [ root@curl:/ ]$ curl http://openfunction.io.svc.cluster.local/default/function-sample/foo + [ root@curl:/ ]$ curl http://function-sample.default.svc.cluster.local/foo {"hello":"foo!"}% - - [ root@curl:/ ]$ curl http://openfunction.io.svc.cluster.local/default/function-sample/bar + ``` + + Access functions by the external address: + > To access the function via the Address of type `External` in `Funtion.status`, you should configure local domain first, see [Configure Local Domain](https://openfunction.dev/docs/concepts/networking/local-domain). + + ```shell + [ root@curl:/ ]$ curl http://function-sample.default.ofn.io/bar hello, bar! ``` diff --git a/functions/knative/with-output-binding/README.md b/functions/knative/with-output-binding/README.md index 7b38a9f..7e25027 100644 --- a/functions/knative/with-output-binding/README.md +++ b/functions/knative/with-output-binding/README.md @@ -130,26 +130,41 @@ kubectl apply -f function-front.yaml Check the current function status: ```shell -~# kubectl get functions.core.openfunction.io +kubectl get functions.core.openfunction.io NAME BUILDSTATE SERVINGSTATE BUILDER SERVING URL AGE -function-front Succeeded Running builder-bhbtk serving-vc6jw http://openfunction.io/default/function-front 2m41s -kafka-input Succeeded Running builder-dprfd serving-75vrt 2m21s +function-front Succeeded Running builder-bhbtk serving-vc6jw http://function-front.default.ofn.io/ 2m41s +kafka-input Succeeded Running builder-dprfd serving-75vrt 2m21s ``` -The `URL` is the address provided by the OpenFunction Domain that can be accessed. To access the function via this URL address, you need to make sure that DNS can resolve this address. +The `Function.status.addresses` field provides various methods for accessing functions. +Get `Function` addresses by running following command: + ```shell + kubectl get function function-front -o=jsonpath='{.status.addresses}' + ``` +You will get the following address: + ```json + [{"type":"External","value":"http://function-front.default.ofn.io/"}, + {"type":"Internal","value":"http://function-front.default.svc.cluster.local/"}] + ``` > You can use the following command to create a pod in the cluster and access the function from the pod: > > ```shell -> kubectl run curl --image=radial/busyboxplus:curl -i --tty --rm -> ``` + > kubectl run curl --image=radial/busyboxplus:curl -i --tty + > ``` -Access the function via `URL`: +Access functions by the internal address: + ```shell + [ root@curl:/ ]$ curl -d '{"message":"Awesome OpenFunction!"}' -H "Content-Type: application/json" -X POST http://function-front.default.svc.cluster.local/ + ``` -```shell -[ root@curl:/ ]$ curl -d '{"message":"Awesome OpenFunction!"}' -H "Content-Type: application/json" -X POST http://openfunction.io.svc.cluster.local/default/function-front -``` +Access functions by the external address: +> To access the function via the Address of type `External` in `Funtion.status`, you should configure local domain first, see [Configure Local Domain](https://openfunction.dev/docs/concepts/networking/local-domain). + + ```shell + [ root@curl:/ ]$ curl -d '{"message":"Awesome OpenFunction!"}' -H "Content-Type: application/json" -X POST http://function-front.default.ofn.io/ + ``` Query `function-front`'s log: