APISIX Declarative CLI (ADC)
The APISIX Declarative CLI (ADC) is a command-line tool that allows you to manage both APISIX and API7 Enterprise resources in a declarative manner. It offers simplicity and clarity in defining the desired state of API7 Enterprise, allowing developers and administrators to focus on the end result rather than the procedural steps. The declarative configurations could serve as a single source of truth that can be managed through version control systems.
The ADC tool has the following general syntax:
adc [command] [options]
with global options:
-V, --version
to check the version-h, --help
to print the help menu of the command
Commands
adc sync
Configure the backend type and instance location.
Options | Default Value | Description | Valid Value | Env Variable |
---|---|---|---|---|
--verbose <integer> | 1 | Adjust verbose logging level, where 0 represents no log, 1 represents basic logs, and 2 represents debug logs. | 0 , 1 or 2 | |
--backend <backend-type> | apisix | Configure the backend type. | apisix or api7ee | ADC_BACKEND |
--server <server-addr> | http://localhost:9180 | Configure backend server address. | ADC_SERVER | |
--token <token> | Configure API token used to access the API7 server. | ADC_TOKEN | ||
--gateway-group <gateway-group-name> | default | Specify gateway group to operate on (API7 Enterprise only). | ADC_GATEWAY_GROUP | |
--label-selector <selectors> | Specify resource labels to filter for. | |||
-f, --file <file-path> | Synchronize configuration file. | |||
--include-resource-type <string> | Filter for resource types, such that the resource search results should only contain the specified type. | |||
--exclude-resource-type <string> | Filter for resource types, such that the resource search results should exclude the specified type. | |||
--timeout <duration> | 10s | Set a request timeout for the client to connect with the backend Admin API in duration, such as 30s, 10m, and 1h10m. | ||
--ca-cert-file <string> | Specify path to CA certificate for verifying the backend Admin API. | ADC_CA_CERT_FILE | ||
--tls-client-cert-file <string> | Specify path to mutual TLS client certificate for verifying the backend Admin API. | ADC_TLS_CLIENT_CERT_FILE | ||
--tls-client-key-file <string> | Specify path to mutual TLS client key for verifying the backend Admin API. | ADC_TLS_CLIENT_KEY_FILE | ||
--tls-skip-verify | false | Whether to verify the TLS certificate when connecting to the backend Admin API. | ADC_TLS_SKIP_VERIFY |
Sample Usage
adc sync -f service-a.yaml -f service-b.yaml --backend api7ee --server https://localhost:7443
adc ping
Ping API7 instance to verify connectivity.
Options | Default Value | Description | Valid Value | Env Variable |
---|---|---|---|---|
--verbose <integer> | 1 | Adjust verbose logging level, where 0 represents no log, 1 represents basic logs, and 2 represents debug logs. | 0 , 1 or 2 | |
--backend <backend-type> | apisix | Configure the backend type. | apisix or api7ee | ADC_BACKEND |
--server <server-addr> | http://localhost:9180 | Configure backend server address. | ADC_SERVER | |
--token <token> | Configure API token used to access the API7 server. | ADC_TOKEN | ||
--gateway-group <gateway-group-name> | default | Specify gateway group to operate on (API7 Enterprise only). | ADC_GATEWAY_GROUP | |
--label-selector <selectors> | Specify resource labels to filter for. | |||
--include-resource-type <string> | Filter for resource types, such that the resource search results should only contain the specified type. | |||
--exclude-resource-type <string> | Filter for resource types, such that the resource search results should exclude the specified type. | |||
--timeout <duration> | 10s | Set a request timeout for the client to connect with the backend Admin API in duration, such as 30s, 10m, and 1h10m. | ||
--ca-cert-file <string> | Specify path to CA certificate for verifying the backend Admin API. | ADC_CA_CERT_FILE | ||
--tls-client-cert-file <string> | Specify path to mutual TLS client certificate for verifying the backend Admin API. | ADC_TLS_CLIENT_CERT_FILE | ||
--tls-client-key-file <string> | Specify path to mutual TLS client key for verifying the backend Admin API. | ADC_TLS_CLIENT_KEY_FILE | ||
--tls-skip-verify | false | Whether to verify the TLS certificate when connecting to the backend Admin API. | ADC_TLS_SKIP_VERIFY |
Sample Usage
adc ping --backend api7ee --server https://localhost:7443
adc dump
Dump configurations from the backend.
Options | Default Value | Description | Valid Value | Env Variable |
---|---|---|---|---|
--verbose <integer> | 1 | Adjust verbose logging level, where 0 represents no log, 1 represents basic logs, and 2 represents debug logs. | 0 , 1 or 2 | |
--backend <backend-type> | apisix | Configure the backend type. | apisix or api7ee | ADC_BACKEND |
--server <server-addr> | http://localhost:9180 | Configure backend server address. | ADC_SERVER | |
--token <token> | Configure API token used to access the API7 server. | ADC_TOKEN | ||
--gateway-group <gateway-group-name> | default | Specify gateway group to operate on (API7 Enterprise only). | ADC_GATEWAY_GROUP | |
--label-selector <selectors> | Specify resource labels to filter for. | |||
-o, --output <file-path> | Specify the file path where the backend data should be dumped. | |||
--include-resource-type <string> | Filter for resource types, such that the resource search results should only contain the specified type. | |||
--exclude-resource-type <string> | Filter for resource types, such that the resource search results should exclude the specified type. | |||
--timeout <duration> | 10s | Set a request timeout for the client to connect with the backend Admin API in duration, such as 30s, 10m, and 1h10m. | ||
--ca-cert-file <string> | Specify path to CA certificate for verifying the backend Admin API. | ADC_CA_CERT_FILE | ||
--tls-client-cert-file <string> | Specify path to mutual TLS client certificate for verifying the backend Admin API. | ADC_TLS_CLIENT_CERT_FILE | ||
--tls-client-key-file <string> | Specify path to mutual TLS client key for verifying the backend Admin API. | ADC_TLS_CLIENT_KEY_FILE | ||
--tls-skip-verify | false | Whether to verify the TLS certificate when connecting to the backend Admin API. | ADC_TLS_SKIP_VERIFY |
Sample Usage
adc dump -o apisix-dump.yaml --backend api7ee --server https://localhost:7443
adc diff
Show differences between local and backend configurations.
Options | Default Value | Description | Valid Value | Env Variable |
---|---|---|---|---|
--verbose <integer> | 1 | Adjust verbose logging level, where 0 represents no log, 1 represents basic logs, and 2 represents debug logs. | 0 , 1 or 2 | |
--backend <backend-type> | apisix | Configure the backend type. | apisix or api7ee | ADC_BACKEND |
--server <server-addr> | http://localhost:9180 | Configure backend server address. | ADC_SERVER | |
--token <token> | Configure API token used to access the API7 server. | ADC_TOKEN | ||
--gateway-group <gateway-group-name> | default | Specify gateway group to operate on (API7 Enterprise only). | ADC_GATEWAY_GROUP | |
--label-selector <selectors> | Specify resource labels to filter for. | |||
-f, --file <file-path> | Compare with local configuration file. | |||
--include-resource-type <string> | Filter for resource types, such that the resource search results should only contain the specified type. | |||
--exclude-resource-type <string> | Filter for resource types, such that the resource search results should exclude the specified type. | |||
--timeout <duration> | 10s | Set a request timeout for the client to connect with the backend Admin API in duration, such as 30s, 10m, and 1h10m. | ||
--ca-cert-file <string> | Specify path to CA certificate for verifying the backend Admin API. | ADC_CA_CERT_FILE | ||
--tls-client-cert-file <string> | Specify path to mutual TLS client certificate for verifying the backend Admin API. | ADC_TLS_CLIENT_CERT_FILE | ||
--tls-client-key-file <string> | Specify path to mutual TLS client key for verifying the backend Admin API. | ADC_TLS_CLIENT_KEY_FILE | ||
--tls-skip-verify | false | Whether to verify the TLS certificate when connecting to the backend Admin API. | ADC_TLS_SKIP_VERIFY |
Sample Usage
adc diff -f service-a.yaml -f service-b.yaml --backend api7ee --server https://localhost:7443
adc convert
Convert API specifications to ADC configurations.
Options | Default Value | Description | Valid Value | Env Variable |
---|---|---|---|---|
openapi | Convert OpenAPI spec to ADC Configurations. |
Sample Usage
adc convert openapi -f open-api-spec.yaml -o adc.yaml
adc lint
Lint the provided configuration files to ensure the configurations meet ADC requirements.
Options | Default Value | Description | Valid Value | Env Variable |
---|---|---|---|---|
-f, --file <file-path> | Files to lint. |
Sample Usage
adc lint -f service-a.yaml -f service-b.yaml
adc help
Print help menu.
Sample Usage
adc help
Using Environment Variables
A number of variables, such as backend type, server address, token, and gateway group, can be configured in environment variables.
For instance, you could define the variables in .env
file as such:
ADC_BACKEND=api7ee
ADC_SERVER=https://localhost:7443
Alternatively, you could export these variables in the terminal:
export ADC_BACKEND=api7ee
export ADC_SERVER=https://localhost:7443
Once defined, you can run ADC commands without configuring these values repetitively in the --backend
and --server
flags.