api7/Amesh

proposal: AmeshPluginConfig support

Opened this issue · 1 comments

AmeshPluginConfig Resource

The resource AmeshPluginConfig is a custom resource that defines all the plugin configurations that will be used by the APISIX.
A minimum sample configuration is as follows:

apiVersion: apisix.apache.org/v1alpha1
kind: AmeshPluginConfig
metadata:
  name: go-plugins
spec:
  type: pre-req
  plugins:
  - name: say
    config: "{\"body\":\"hello\"}"

This CRD indicates that the routes should be injected with the following plugin configuration:

{
  // ... Route configurations ...
  "plugins": {
    "ext-plugin-pre-req": {
       "conf": [
         {"name":"say", "value":"{\"body\":\"hello\"}"}
       ]
    } 
  },
}

If you only want the plugin to run on specific workloads, you can add the selector field for filtering.

apiVersion: apisix.apache.org/v1alpha1
kind: AmeshPluginConfig
metadata:
  name: go-plugins
spec:
  type: pre-req
  plugins: 
  - name: say
    config: "{\"body\":\"hello\"}"
  # selectors
  nodeSelector:
    kubernetes.io/hostname: node1
  selector:
    matchLabels:
      component: redis
    matchExpressions:
    - key: zone
      operator: In
      values:
      - foo
      - bar
    - key: environment
      operator: NotIn
      values:
      - dev

For more information about selectors, please refer to Resources that support set-based requirements.
Custom Plugins
Apart from the official plugins, users can also add custom plugins to the Amesh.
To make the image used by the sidecar include user custom plugins, the user needs to build a new image based on Amesh's APISIX image and the user's plugins.
Test Plan
We need a complete and solid test suite to validate this functionality, including the following cases:

  • Test the plugin configuration is injected into the routes
  • Test the plugin with a custom selector
  • Test the plugin definition updates are reflected