You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by zh...@apache.org on 2022/10/07 16:42:33 UTC

[apisix-helm-chart] branch master updated: add wasmPlugins options and set wasm plugins to apisix config to apisix chart (#356)

This is an automated email from the ASF dual-hosted git repository.

zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-helm-chart.git


The following commit(s) were added to refs/heads/master by this push:
     new b0fd2cf  add wasmPlugins options and set wasm plugins to apisix config to apisix chart (#356)
b0fd2cf is described below

commit b0fd2cf502699a6d6faa84393cd2239d2f759b68
Author: xshadowlegendx <ly...@gmail.com>
AuthorDate: Fri Oct 7 23:42:27 2022 +0700

    add wasmPlugins options and set wasm plugins to apisix config to apisix chart (#356)
---
 charts/apisix/README.md                | 42 ++++++++++++++++++++++++++++++++++
 charts/apisix/templates/configmap.yaml |  6 +++++
 charts/apisix/values.yaml              |  4 ++++
 3 files changed, 52 insertions(+)

diff --git a/charts/apisix/README.md b/charts/apisix/README.md
index f7a66f4..fac8d4d 100644
--- a/charts/apisix/README.md
+++ b/charts/apisix/README.md
@@ -157,6 +157,48 @@ Default enabled plugins. See [configmap template](https://github.com/apache/apis
 | `extPlugin.enabled` | Enable External Plugins. See [external plugin](https://apisix.apache.org/docs/apisix/next/external-plugin/) | `false` |
 | `extPlugin.cmd` | the command and its arguements to run as a subprocess | `{}` |
 
+### wasm plugin parameters
+
+| Parameter                       | Description                                                                                                                                                      | Default                     |
+|---------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
+| `wasmPlugins.enabled` | Enable Wasm Plugins. See [wasm plugin](https://apisix.apache.org/docs/apisix/next/wasm/) | `false` |
+| `wasmPlugins.plugins[].name` | Set wasm plugin name | `""` |
+| `wasmPlugins.plugins[].priority` | Set wasm plugin priority | `7999` |
+| `wasmPlugins.plugins[].file` | Set path to wasm plugin | `""` |
+| `wasmPlugins.plugins[].http_request_phase` | Set which http request phase for the plugin to run in | `access` |
+
+Note:
+  - the easiest way to include your wasm custom plugin is to rebuild the apisix image with those custom plugins included within the directory you define and later on gets referenced to `wasmPlugins.plugins[].file`
+  - otherwise you could use `extraVolumes` and `extraVolumeMounts` option to include your plugin by creating your plugin via `ConfigMap` and mount it to apisix pod like example below
+    ```
+    #... more options omitted ...
+    ingress-controller:
+      enabled: true
+
+    dashboard:
+      enabled: true
+
+    # assuming you install apisix in `apisix` namespace,
+    # create the plugin by this command and had the wasm plugin
+    # kubectl create configmap --namespace apisix --from-file=./wasm_plugin_x.wasm wasm-plugin-x
+    # Note: there are also size limitation on `ConfigMap`
+
+    # these options are kubernetes
+    # Volume and VolumeMount api objects
+    extraVolumes:
+    - name: wasm-plugin-x
+      configMap:
+        name: wasm-plugin-x
+        items:
+        - key: wasm_plugin_x.wasm
+          path: wasm_plugin_x.wasm
+    extraVolumeMounts:
+    - name: wasm-plugin-x
+      mountPath: /var/local/wasm-plugins/ # later on reference to `wasmPlugins.plugins[].file` as its value
+      readOnly: true
+    #... more options omitted ...
+    ```
+
 ### custom plugin parameters
 
 | Parameter                       | Description                                                                                                                                                      | Default                     |
diff --git a/charts/apisix/templates/configmap.yaml b/charts/apisix/templates/configmap.yaml
index 9398877..999b913 100644
--- a/charts/apisix/templates/configmap.yaml
+++ b/charts/apisix/templates/configmap.yaml
@@ -293,5 +293,11 @@ data:
     plugin_attr: {{- $pluginAttrs | nindent 6 }}
     {{- end }}
     {{- end }}
+
+    {{- if .Values.wasmPlugins.enabled }}
+    wasm:
+      plugins:
+        {{- toYaml .Values.wasmPlugins.plugins | nindent 8 }}
+    {{- end }}
 {{- end }}
 {{- end }}
diff --git a/charts/apisix/values.yaml b/charts/apisix/values.yaml
index fed5c18..f3d5f06 100644
--- a/charts/apisix/values.yaml
+++ b/charts/apisix/values.yaml
@@ -274,6 +274,10 @@ extPlugin:
   enabled: false
   cmd: ["/path/to/apisix-plugin-runner/runner", "run"]
 
+wasmPlugins:
+  enabled: false
+  plugins: []
+
 # customPlugins allows you to mount your own HTTP plugins.
 customPlugins:
   enabled: false