From 436d3e715d821b3a507cf05c0db4cce30a18aef1 Mon Sep 17 00:00:00 2001 From: "vichao.s" Date: Wed, 1 Oct 2025 18:06:39 +0700 Subject: [PATCH] fix: Resolve duplicate volume mounts for custom plugins sharing same ConfigMap --- charts/apisix/templates/_helpers.tpl | 15 +++++++++++++++ charts/apisix/templates/deployment.yaml | 11 +++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/charts/apisix/templates/_helpers.tpl b/charts/apisix/templates/_helpers.tpl index 53a49bb0..d4de9a67 100644 --- a/charts/apisix/templates/_helpers.tpl +++ b/charts/apisix/templates/_helpers.tpl @@ -157,3 +157,18 @@ Key to use to fetch viewer token from secret {{- "viewer" }} {{- end }} {{- end }} + +{{/* +Get unique ConfigMap names from custom plugins +*/}} +{{- define "apisix.uniqueConfigMaps" -}} +{{- $configMaps := dict }} +{{- if .Values.apisix.customPlugins.enabled }} +{{- range $plugin := .Values.apisix.customPlugins.plugins }} +{{- if ne $plugin.configMap.name "" }} +{{- $_ := set $configMaps $plugin.configMap.name true }} +{{- end }} +{{- end }} +{{- end }} +{{- keys $configMaps | join "," }} +{{- end }} diff --git a/charts/apisix/templates/deployment.yaml b/charts/apisix/templates/deployment.yaml index 1c4102eb..317d231c 100644 --- a/charts/apisix/templates/deployment.yaml +++ b/charts/apisix/templates/deployment.yaml @@ -279,11 +279,14 @@ spec: name: id {{- end }} {{- if .Values.apisix.customPlugins.enabled }} - {{- range $plugin := .Values.apisix.customPlugins.plugins }} - {{- if ne $plugin.configMap.name "" }} - - name: plugin-{{ $plugin.configMap.name }} + {{- $uniqueConfigMaps := include "apisix.uniqueConfigMaps" . }} + {{- if ne $uniqueConfigMaps "" }} + {{- range $configMapName := splitList "," $uniqueConfigMaps }} + {{- if ne $configMapName "" }} + - name: plugin-{{ $configMapName }} configMap: - name: {{ $plugin.configMap.name }} + name: {{ $configMapName }} + {{- end }} {{- end }} {{- end }} {{- end }}