Skip to content

Commit

Permalink
change the function access method from Domain to Gateway
Browse files Browse the repository at this point in the history
Signed-off-by: wrongerror <[email protected]>
  • Loading branch information
wrongerror committed Aug 5, 2022
1 parent d11caf0 commit 253bbc7
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# Dependency directories (remove the comment below to include it)
# vendor/
.idea/
.vscode/
.venv/

Expand Down
33 changes: 23 additions & 10 deletions functions/knative/hello-world-go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
30 changes: 21 additions & 9 deletions functions/knative/multiple-functions-go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
```

Expand Down
35 changes: 25 additions & 10 deletions functions/knative/with-output-binding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 253bbc7

Please sign in to comment.