tokers commented on code in PR #7634:
URL: https://github.com/apache/apisix/pull/7634#discussion_r941158749


##########
ci/init-plugin-test-service.sh:
##########
@@ -41,3 +41,70 @@ docker exec -i rmqnamesrv 
/home/rocketmq/rocketmq-4.6.0/bin/mqadmin updateTopic
 
 # prepare vault kv engine
 docker exec -i vault sh -c "VAULT_TOKEN='root' 
VAULT_ADDR='http://0.0.0.0:8200' vault secrets enable -path=kv -version=1 kv"
+
+# prepare openfunction env
+prepare_kind_k8s() {
+    curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
+    chmod +x ./kind
+    curl -LO "https://dl.k8s.io/release/$(curl -L -s 
https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
+    sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
+    kind create cluster --name myk8s-01
+}
+
+install_openfuncntion() {
+    curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 
| bash
+    helm repo add openfunction https://openfunction.github.io/charts/
+    helm repo update
+    kubectl create namespace openfunction
+    helm install openfunction --set global.Keda.enabled=false --set 
global.Dapr.enabled=false openfunction/openfunction -n openfunction
+    kubectl wait pods --all  --for=condition=Ready --timeout=300s -n 
openfunction
+    kubectl delete -A ValidatingWebhookConfiguration ingress-nginx-admission
+    kubectl delete deployment -n keda --all
+    kubectl delete deployment -n dapr-system --all
+    kubectl delete pod -n keda --all
+    kubectl delete pod -n dapr-system --all
+}
+
+set_container_registry_secret() {
+    REGISTRY_SERVER=https://index.docker.io/v1/ 
REGISTRY_USER=apisixtestaccount123 REGISTRY_PASSWORD=apisixtestaccount

Review Comment:
   Why use this? We can push the docker images through `kind load docker-image`.



##########
docs/en/latest/plugins/openfunction.md:
##########
@@ -0,0 +1,122 @@
+---
+title: openfunction
+keywords:
+  - APISIX
+  - Plugin
+  - OpenFunction
+  - openfunction
+description: This document contains information about the CNCF OpenFunction 
Plugin.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Description
+
+The `openfunction` Plugin is used to integrate APISIX with [CNCF 
OpenWhisk](https://openfunction.dev/) serverless platform.

Review Comment:
   ```suggestion
   The `openfunction` Plugin is used to integrate APISIX with [CNCF 
OpenFunction](https://openfunction.dev/) serverless platform.
   ```



##########
apisix/plugins/openfunction.lua:
##########
@@ -0,0 +1,104 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core              = require("apisix.core")
+local http              = require("resty.http")
+local ngx_encode_base64 = ngx.encode_base64
+
+local schema = {
+    type = "object",
+    properties = {
+        function_uri = {type = "string"},
+        ssl_verify = {
+            type = "boolean",
+            default = true,
+        },
+        service_token = {type = "string"},
+        timeout = {
+            type = "integer",
+            minimum = 1,
+            maximum = 60000,
+            default = 60000,
+            description = "timeout in milliseconds",
+        },
+        keepalive = {type = "boolean", default = true},
+        keepalive_timeout = {type = "integer", minimum = 1000, default = 
60000},
+        keepalive_pool = {type = "integer", minimum = 1, default = 5}
+    },
+    required = {"function_uri"}
+}
+
+
+local _M = {
+    version = 0.1,
+    priority = -1902,
+    name = "openfunction",
+    schema = schema,
+}
+
+
+function _M.check_schema(conf)
+    local ok, err = core.schema.check(schema, conf)
+    if not ok then
+        return false, err
+    end
+
+    return true
+end
+
+
+function _M.access(conf, ctx)

Review Comment:
   Can we reuse code base in 
https://github.com/apache/apisix/blob/master/apisix/plugins/serverless/init.lua?



##########
docs/en/latest/plugins/openfunction.md:
##########
@@ -0,0 +1,122 @@
+---
+title: openfunction
+keywords:
+  - APISIX
+  - Plugin
+  - OpenFunction
+  - openfunction
+description: This document contains information about the CNCF OpenFunction 
Plugin.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Description
+
+The `openfunction` Plugin is used to integrate APISIX with [CNCF 
OpenWhisk](https://openfunction.dev/) serverless platform.
+
+This Plugin can be configured on a Route and requests will be send to the 
configured OpenWhish API endpoint as the upstream.
+
+## Attributes
+
+| Name              | Type    | Required | Default | Valid values | 
Description                                                                     
                           |
+| ----------------- | ------- | -------- | ------- | ------------ | 
----------------------------------------------------------------------------------------------------------
 |
+| function_uri      | string  | True     |         |              | function 
uri. For example, `https://localhost:30858/default/function-sample`.            
                  |
+| ssl_verify        | boolean | False    | true    |              | When set 
to `true` verifies the SSL certificate.                                         
                  |
+| service_token     | string  | False    |         |              | The token 
format is 'xx:xx' which support basic auth for ingress controller, .            
                          |
+| timeout           | integer | False    | 60000ms | [1, 60000]ms | 
OpenFunction action and HTTP call timeout in ms.                                
                              |
+| keepalive         | boolean | False    | true    |              | When set 
to `true` keeps the connection alive for reuse.                                 
                  |
+| keepalive_timeout | integer | False    | 60000ms | [1000,...]ms | Time is ms 
for connection to remain idle without closing.                                  
                |
+| keepalive_pool    | integer | False    | 5       | [1,...]      | Maximum 
number of requests that can be sent on this connection before closing it.       
                   |
+
+:::note
+
+The `timeout` attribute sets the time taken by the OpenFunction to execute, 
and the timeout for the HTTP client in APISIX. OpenFunction  calls may take 
time to pull the runtime image and start the container. So, if the value is set 
too small, it may cause a large number of requests to fail.
+
+
+:::
+
+## Enabling the Plugin
+
+Before configuring the Plugin, you need to have OpenFunction running. The 
example below shows OpenFunction installed in Helm:
+
+```shell
+#add the OpenFunction chart repository
+helm repo add openfunction https://openfunction.github.io/charts/
+helm repo update
+
+#install the OpenFunction chart
+kubectl create namespace openfunction
+helm install openfunction openfunction/openfunction -n openfunction
+```
+
+You can then verify if OpenFunction is ready:
+
+```shell
+kubectl get pods -namespace openfunction

Review Comment:
   ```suggestion
   kubectl get pods --namespace openfunction
   ```



##########
docs/en/latest/plugins/openfunction.md:
##########
@@ -0,0 +1,122 @@
+---
+title: openfunction
+keywords:
+  - APISIX
+  - Plugin
+  - OpenFunction
+  - openfunction
+description: This document contains information about the CNCF OpenFunction 
Plugin.
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## Description
+
+The `openfunction` Plugin is used to integrate APISIX with [CNCF 
OpenWhisk](https://openfunction.dev/) serverless platform.
+
+This Plugin can be configured on a Route and requests will be send to the 
configured OpenWhish API endpoint as the upstream.
+
+## Attributes
+
+| Name              | Type    | Required | Default | Valid values | 
Description                                                                     
                           |
+| ----------------- | ------- | -------- | ------- | ------------ | 
----------------------------------------------------------------------------------------------------------
 |
+| function_uri      | string  | True     |         |              | function 
uri. For example, `https://localhost:30858/default/function-sample`.            
                  |
+| ssl_verify        | boolean | False    | true    |              | When set 
to `true` verifies the SSL certificate.                                         
                  |
+| service_token     | string  | False    |         |              | The token 
format is 'xx:xx' which support basic auth for ingress controller, .            
                          |
+| timeout           | integer | False    | 60000ms | [1, 60000]ms | 
OpenFunction action and HTTP call timeout in ms.                                
                              |
+| keepalive         | boolean | False    | true    |              | When set 
to `true` keeps the connection alive for reuse.                                 
                  |
+| keepalive_timeout | integer | False    | 60000ms | [1000,...]ms | Time is ms 
for connection to remain idle without closing.                                  
                |
+| keepalive_pool    | integer | False    | 5       | [1,...]      | Maximum 
number of requests that can be sent on this connection before closing it.       
                   |
+
+:::note
+
+The `timeout` attribute sets the time taken by the OpenFunction to execute, 
and the timeout for the HTTP client in APISIX. OpenFunction  calls may take 
time to pull the runtime image and start the container. So, if the value is set 
too small, it may cause a large number of requests to fail.
+
+
+:::
+
+## Enabling the Plugin
+
+Before configuring the Plugin, you need to have OpenFunction running. The 
example below shows OpenFunction installed in Helm:

Review Comment:
   Also give a link to the installation page of OpenFunction.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to