Skip to content

Conversation

@vichaos
Copy link

@vichaos vichaos commented Oct 1, 2025

Fix: Resolve duplicate volume mounts for custom plugins sharing same ConfigMap

Problem

When multiple APISIX custom plugins reference the same ConfigMap, the Helm chart creates duplicate volume mounts, causing deployment failures. This occurs because the chart template generates a volume for each plugin individually, without checking if multiple plugins share the same ConfigMap.

Example:

customPlugins:
  plugins:
  - name: "custom-forward-auth"
    attrs: {}
    configMap:
      name: "apisix-custom-plugins"
      mounts:
      - key: "custom-forward-auth.lua"
        path: "/opt/apisix/plugins/custom-forward-auth.lua"
  - name: "header-to-cookie"
    attrs: {}
    configMap:
      name: "apisix-custom-plugins"
      mounts:
      - key: "header-to-cookie.lua"
        path: "/opt/apisix/plugins/header-to-cookie.lua"

Solution

This PR introduces a helper function that deduplicates ConfigMap references across custom plugins, ensuring only one volume is created per unique ConfigMap while preserving all individual plugin file mounts.

Changes Made

  1. Added helper function in templates/_helpers.tpl:

    • apisix.uniqueConfigMaps: Collects and returns unique ConfigMap names from all custom plugins
  2. Modified deployment template in templates/deployment.yaml:

    • Updated volumes section to use the helper function
    • Creates volumes based on unique ConfigMap names instead of per-plugin

Before vs After

Before (Broken):

volumes:
- name: plugin-apisix-custom-plugins
  configMap:
    name: apisix-custom-plugins
volumes:
- name: plugin-apisix-custom-plugins
  configMap:
    name: apisix-custom-plugins  # Duplicate!

Result: Duplicate volume mount error

After (Fixed):

  • Same configuration works correctly
  • Single volume created for shared ConfigMap
  • All plugin files properly mounted
volumes:
- name: plugin-apisix-custom-plugins
  configMap:
    name: apisix-custom-plugins

Benefits

  • ✅ Eliminates duplicate volume mount errors
  • ✅ Maintains backward compatibility
  • ✅ Preserves all existing functionality
  • ✅ Supports multiple plugins sharing ConfigMaps
  • ✅ No breaking changes to values.yaml format

Testing

  • helm build succeeds without errors
  • Single volume created for shared ConfigMap
  • All plugin files correctly mounted
  • Both custom plugins properly configured

This fix resolves the deployment issue while maintaining the clean, intuitive configuration format for custom plugins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant