Configuration Reference
ADC uses a single configuration file or multiple configuration files to define services, routes, plugins, and other configurations in API7 Enterprise. The configuration file can either be in YAML or JSON format and serves as the single source of truth.
This document provides an example configuration file that can be used as a reference to create your own configuration files. See the command reference for more information on using the configuration files with ADC.
Example Configuration File
The following configuration file defines two services with multiple routes and labels, two consumers with key-authentication credentials, and a global rule configuring the Prometheus plugin:
services:
- name: mockbin-service
labels:
deployment: staging
upstream:
name: Default Upstream
scheme: http
type: roundrobin
hash_on: vars
nodes:
- host: mock.api7.ai
port: 80
weight: 100
priority: 0
timeout:
connect: 60
send: 60
read: 60
retry_timeout: 0
keepalive_pool:
size: 320
idle_timeout: 60
requests: 1000
pass_host: pass
strip_path_prefix: true
routes:
- uris:
- /api
name: api
methods:
- GET
enable_websocket: false
priority: 0
- name: httpbin-service
labels:
deployment: production
upstream:
name: Default Upstream
scheme: http
nodes:
- host: httpbin.org
port: 80
routes:
- uris:
- /ip
name: ip
labels:
app: catalog
methods:
- GET
- uris:
- /anything/*
name: anything
methods:
- GET
consumers:
- username: Jane
labels:
organisation: ACME
credentials:
- name: primary-key
labels:
type: internal
type: key-auth
config:
key: c1_yN0nCWousUfiR4EzfH
metadata:
namespace: api7
id: 9ae2df2b-e578-46d9-8357-cf7c3cd64d51
- username: John
labels:
organisation: API7.ai
credentials:
- name: primary-key
type: key-auth
config:
key: EIul6mAuYkLJ27on1aJD4
metadata:
namespace: api7
id: c5e8c41e-37c5-4329-87a9-ba2e6916cfe3
global_rules:
prometheus:
_meta:
disable: false
prefer_name: false
Variables in Configuration File
ADC supports several different syntaxes for referencing variables within configuration files, each of which resolves values from different sources at runtime.
Data Plane Environment Variables
ADC supports the $env:// syntax to reference data plane environment variables in eligible fields. This allows configuration values to be dynamically resolved from the environment of the running data plane (gateway) instance. See Custom Environment Variables.
ADC Environment Variables
ADC supports the ${ENV} syntax for ADC-side environment variables in all ADC fields. This is resolved by ADC itself and is commonly used to externalize configuration without hardcoding values directly into files.
Built-in Variables
ADC supports configuring built-in variables in eligible fields using the \\${} syntax.
For example, the plugin below uses built-in variables to dynamically determine the rate limiting key and limit values from the values in the HTTP header X-User-Info:
plugins:
limit-count:
count: "\\${http_x_user_info.low_rate_limit}"
key: "\\${http_x_user_info.rate_limit_key}"
time_window: 60
key_type: var