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

tokers 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 c08b21c  feat: support to mount 3rd plugins from configmap (#161)
c08b21c is described below

commit c08b21cd58108c6d4abcc8e9b1c482dfc6f37c1c
Author: Alex Zhang <[email protected]>
AuthorDate: Thu Oct 28 10:49:34 2021 +0800

    feat: support to mount 3rd plugins from configmap (#161)
    
    Signed-off-by: Chao Zhang <[email protected]>
---
 charts/apisix/templates/configmap.yaml  | 18 +++++++++++++++++-
 charts/apisix/templates/deployment.yaml | 16 ++++++++++++++++
 charts/apisix/values.yaml               | 22 ++++++++++++++++++++++
 3 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/charts/apisix/templates/configmap.yaml 
b/charts/apisix/templates/configmap.yaml
index 278f5cf..76a373b 100644
--- a/charts/apisix/templates/configmap.yaml
+++ b/charts/apisix/templates/configmap.yaml
@@ -49,6 +49,10 @@ data:
       enable_ipv6: true
       config_center: etcd             # etcd: use etcd to store the config 
value
                                       # yaml: fetch the config value from 
local yaml file `/your_path/conf/apisix.yaml`
+      {{- if .Values.customPlugins.enabled }}
+      extra_lua_path: {{ .Values.customPlugins.luaPath | quote }}
+      {{- end }}
+
 
       #proxy_protocol:                 # Proxy Protocol configuration
       #  listen_http_port: 9181        # The port with proxy protocol for 
http, it differs from node_listen and port_admin.
@@ -175,12 +179,24 @@ data:
 
     {{- if .Values.plugins }}
     plugins:                          # plugin list
-    {{- end }}
     {{- range $plugin := .Values.plugins }}
       - {{ $plugin }}
     {{- end }}
+    {{- if .Values.customPlugins.enabled }}
+    {{- range $plugin := .Values.customPlugins.plugins }}
+      - {{ $plugin.name }}
+    {{- end }}
+    {{- end }}
+    {{- end }}
     stream_plugins:
     {{- range $plugin := .Values.stream_plugins }}
       - {{ $plugin }}
     {{- end }}
+
+    {{- if .Values.customPlugins.enabled }}
+    plugin_attr:
+    {{- range $plugin := .Values.customPlugins.plugins }}
+      {{ $plugin.name }}: {{ $plugin.attrs | toYaml | nindent 8 }}
+    {{- end }}
+    {{- end }}
 {{- end }}
diff --git a/charts/apisix/templates/deployment.yaml 
b/charts/apisix/templates/deployment.yaml
index 9cf7d40..bccbcba 100644
--- a/charts/apisix/templates/deployment.yaml
+++ b/charts/apisix/templates/deployment.yaml
@@ -82,6 +82,15 @@ spec:
             - mountPath: /usr/local/apisix/conf/config.yaml
               name: apisix-config
               subPath: config.yaml
+          {{- if .Values.customPlugins.enabled }}
+          {{- range $plugin := .Values.customPlugins.plugins }}
+          {{- range $mount := $plugin.configMap.mounts }}
+            - mountPath: {{ $mount.path }}
+              name: plugin-{{ $plugin.configMap.name }}
+              subPath: {{ $mount.key }}
+          {{- end }}
+          {{- end }}
+          {{- end }}
           resources:
             {{- toYaml .Values.apisix.resources | nindent 12 }}
       {{- if .Values.etcd.enabled }}
@@ -94,6 +103,13 @@ spec:
         - configMap:
             name: {{ include "apisix.fullname" . }}
           name: apisix-config
+      {{- if .Values.customPlugins.enabled }}
+      {{- range $plugin := .Values.customPlugins.plugins }}
+        - name: plugin-{{ $plugin.configMap.name }}
+          configMap:
+            name: {{ $plugin.configMap.name }}
+      {{- end }}
+      {{- end }}
       {{- with .Values.apisix.nodeSelector }}
       nodeSelector:
         {{- toYaml . | nindent 8 }}
diff --git a/charts/apisix/values.yaml b/charts/apisix/values.yaml
index 247ec74..44d8a38 100644
--- a/charts/apisix/values.yaml
+++ b/charts/apisix/values.yaml
@@ -184,6 +184,28 @@ stream_plugins:
   - ip-restriction
   - limit-conn
 
+# customPlugins allows you to mount your own HTTP plugins.
+customPlugins:
+  enabled: false
+  # the lua_path that tells APISIX where it can find plugins,
+  # note the last ';' is required.
+  luaPath: "/opts/custom_plugins/?.lua"
+  plugins:
+      # plugin name.
+    - name: ""
+      # plugin attrs
+      attrs: |
+      # plugin codes can be saved inside configmap object.
+      configMap:
+        # name of configmap.
+        name: ""
+        # since keys in configmap is flat, mountPath allows to define the mount
+        # path, so that plugin codes can be mounted hierarchically.
+        mounts:
+          - key: ""
+            path: ""
+          - key: ""
+            path: ""
 
 dns:
   resolvers:

Reply via email to