Skip to content

Commit 253bbc7

Browse files
committed
change the function access method from Domain to Gateway
Signed-off-by: wrongerror <[email protected]>
1 parent d11caf0 commit 253bbc7

File tree

4 files changed

+70
-29
lines changed

4 files changed

+70
-29
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/
16+
.idea/
1617
.vscode/
1718
.venv/
1819

functions/knative/hello-world-go/README.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,40 @@ You can create this secret by editing the ``REGISTRY_SERVER``, ``REGISTRY_USER``
6868
```shell
6969
kubectl get functions.core.openfunction.io
7070
71-
NAME BUILDSTATE SERVINGSTATE BUILDER SERVING URL AGE
72-
function-sample Succeeded Running builder-jgnzp serving-q6wdp http://openfunction.io/default/function-sample 22m
71+
NAME BUILDSTATE SERVINGSTATE BUILDER SERVING ADDRESS AGE
72+
function-sample Succeeded Running builder-jgnzp serving-q6wdp http://function-sample.default.ofn.io/ 22m
7373
```
7474

75-
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.
75+
The `Function.status.addresses` field provides various methods for accessing functions.
76+
Get `Function` addresses by running following command:
77+
```shell
78+
kubectl get function function-sample -o=jsonpath='{.status.addresses}'
79+
```
80+
You will get the following address:
81+
```json
82+
[{"type":"External","value":"http://function-sample.default.ofn.io/"},
83+
{"type":"Internal","value":"http://function-sample.default.svc.cluster.local/"}]
84+
```
7685

7786
> You can use the following command to create a pod in the cluster and access the function from the pod:
7887
>
7988
> ```shell
8089
> kubectl run curl --image=radial/busyboxplus:curl -i --tty
8190
> ```
82-
83-
Access the function via `URL`:
84-
91+
92+
Access functions by the internal address:
8593
```shell
86-
[ root@curl:/ ]$ curl http://openfunction.io.svc.cluster.local/default/function-sample/World
87-
Hello, World!
88-
89-
[ root@curl:/ ]$ curl http://openfunction.io.svc.cluster.local/default/function-sample/OpenFunction
94+
[ root@curl:/ ]$ curl http://function-sample.default.svc.cluster.local/OpenFunction
9095
Hello, OpenFunction!
9196
```
97+
98+
Access functions by the external address:
99+
> 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).
100+
101+
```shell
102+
[ root@curl:/ ]$ curl http://function-sample.default.ofn.io/World
103+
Hello, World!
104+
```
92105

93106
There is also an alternative way to trigger the function via the access address provided by the Knative Services:
94107

functions/knative/multiple-functions-go/README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,24 +73,36 @@ You can create this secret by editing the ``REGISTRY_SERVER``, ``REGISTRY_USER``
7373
kubectl get functions.core.openfunction.io
7474
7575
NAME BUILDSTATE SERVINGSTATE BUILDER SERVING URL AGE
76-
function-sample Succeeded Running builder-jgnzp serving-q6wdp http://openfunction.io/default/function-sample 22m
76+
function-sample Succeeded Running builder-jgnzp serving-q6wdp http://function-sample.default.ofn.io/ 22m
7777
```
78-
79-
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.
78+
The `Function.status.addresses` field provides various methods for accessing functions.
79+
Get `Function` addresses by running following command:
80+
```shell
81+
kubectl get function function-sample -o=jsonpath='{.status.addresses}'
82+
```
83+
You will get the following address:
84+
```json
85+
[{"type":"External","value":"http://function-sample.default.ofn.io/"},
86+
{"type":"Internal","value":"http://function-sample.default.svc.cluster.local/"}]
87+
```
8088

8189
> You can use the following command to create a pod in the cluster and access the function from the pod:
8290
>
8391
> ```shell
8492
> kubectl run curl --image=radial/busyboxplus:curl -i --tty
8593
> ```
86-
87-
Access the function via `URL`:
88-
94+
95+
Access functions by the internal address:
8996
```shell
90-
[ root@curl:/ ]$ curl http://openfunction.io.svc.cluster.local/default/function-sample/foo
97+
[ root@curl:/ ]$ curl http://function-sample.default.svc.cluster.local/foo
9198
{"hello":"foo!"}%
92-
93-
[ root@curl:/ ]$ curl http://openfunction.io.svc.cluster.local/default/function-sample/bar
99+
```
100+
101+
Access functions by the external address:
102+
> 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).
103+
104+
```shell
105+
[ root@curl:/ ]$ curl http://function-sample.default.ofn.io/bar
94106
hello, bar!
95107
```
96108

functions/knative/with-output-binding/README.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,26 +130,41 @@ kubectl apply -f function-front.yaml
130130
Check the current function status:
131131
132132
```shell
133-
~# kubectl get functions.core.openfunction.io
133+
kubectl get functions.core.openfunction.io
134134
135135
NAME BUILDSTATE SERVINGSTATE BUILDER SERVING URL AGE
136-
function-front Succeeded Running builder-bhbtk serving-vc6jw http://openfunction.io/default/function-front 2m41s
137-
kafka-input Succeeded Running builder-dprfd serving-75vrt 2m21s
136+
function-front Succeeded Running builder-bhbtk serving-vc6jw http://function-front.default.ofn.io/ 2m41s
137+
kafka-input Succeeded Running builder-dprfd serving-75vrt 2m21s
138138
```
139139
140-
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.
140+
The `Function.status.addresses` field provides various methods for accessing functions.
141+
Get `Function` addresses by running following command:
142+
```shell
143+
kubectl get function function-front -o=jsonpath='{.status.addresses}'
144+
```
145+
You will get the following address:
146+
```json
147+
[{"type":"External","value":"http://function-front.default.ofn.io/"},
148+
{"type":"Internal","value":"http://function-front.default.svc.cluster.local/"}]
149+
```
141150
142151
> You can use the following command to create a pod in the cluster and access the function from the pod:
143152
>
144153
> ```shell
145-
> kubectl run curl --image=radial/busyboxplus:curl -i --tty --rm
146-
> ```
154+
> kubectl run curl --image=radial/busyboxplus:curl -i --tty
155+
> ```
147156
148-
Access the function via `URL`:
157+
Access functions by the internal address:
158+
```shell
159+
[ root@curl:/ ]$ curl -d '{"message":"Awesome OpenFunction!"}' -H "Content-Type: application/json" -X POST http://function-front.default.svc.cluster.local/
160+
```
149161
150-
```shell
151-
[ root@curl:/ ]$ curl -d '{"message":"Awesome OpenFunction!"}' -H "Content-Type: application/json" -X POST http://openfunction.io.svc.cluster.local/default/function-front
152-
```
162+
Access functions by the external address:
163+
> 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).
164+
165+
```shell
166+
[ root@curl:/ ]$ curl -d '{"message":"Awesome OpenFunction!"}' -H "Content-Type: application/json" -X POST http://function-front.default.ofn.io/
167+
```
153168
154169
Query `function-front`'s log:
155170

0 commit comments

Comments
 (0)