Hi,
I want to enable my custom auth plugin for about 20 services but there are services also (for example: dummy service in the configuration below) that I don’t want to attach with that plugin.
My custom plugin requires some config parameters as shown below.
In declarative config, I have to define 20 plugins for each service because each plugin definition can only be attached to one service only via service attribute
This means repeating the same plugin configuration parameters for each plugin definition which I found it is not manageable.
The solution I use is YAML anchors and references but the downside is I can’t define anchor on the root level. I have to define it in the first plugin definition and reference it on the next definitions.
Is there any better way?
Thanks in advance
_format_version: “1.1”
plugins:
-
name: custom-auth
service: alerts-service
config: &CONFIG
auth_sidecar_host: “127.0.0.1”
auth_sidecar_port: 8082
auth_sidecar_timeout: 3000
auth_sidecar_path: “/auth”
log_to_file: true
log_file_path: “…/work/logs/api-gateway-access.log” -
name: custom-auth
service: users-service
config: *CONFIG -
name: custom-auth
service: teams-service
config: *CONFIG -
name: prometheus
services:
-
name: alerts-service
url: https://ALERTS_SERVICE_HOST/
routes:- name: route
strip_path: false
paths:- /v2/alerts
- name: route
-
name: users-service
url: https://USERS_SERVICE_HOST/
routes:- name: route
strip_path: false
paths:- /v2/users
- name: route
-
name: teams-service
url: https://TEAMS_SERVICE_HOST/
routes:- name: route
strip_path: false
paths:- /v2/teams
- name: route
-
name: dummy-service
url: http://localhost:6000/
routes:- name: route
strip_path: false
paths:- /dummy
- name: route