--label-selector scopes ADC operations to resources with matching labels. Use it when multiple teams, applications, or CI pipelines manage separate parts of the same backend.
Without a selector, adc sync reconciles all resources in the command scope. If team A and team B sync separate files to the same backend without partitioning, one team can accidentally delete the other team's resources. A selector prevents that by making each run see only its own labeled resources.
adc sync -f team-a.yaml --label-selector team=aYou can provide multiple labels in one flag or repeat the flag:
adc sync -f catalog.yaml --label-selector team=catalog,env=prod
adc sync -f catalog.yaml --label-selector team=catalog --label-selector env=prodMatching uses exact string equality. Multiple labels are combined with AND, so a resource must match every key-value pair to be included.
ADC does not support wildcards, OR expressions, or key-exists selectors. There is no ADC_* environment variable for label selectors; pass them as command-line flags.
For dump, and for the remote side of diff and sync, ADC filters remote resources by label.
Remote filtering applies to top-level resource collections that carry labels, such as:
servicesconsumersconsumer_groupsssls- other label-bearing top-level resource collections supported by the backend
Remote filtering does not apply to global_rules or plugin_metadata. These resources are keyed by plugin name and are treated as global configuration.
Filtering does not independently select nested resources. If a service matches the selector, its routes and stream routes are included with the service. If a consumer group matches the selector, its nested consumers are included with the group.
For API7 Enterprise, ADC passes label filters to the Admin API so the backend can filter matching top-level resources. For Apache APISIX, ADC fetches the remote configuration and applies the same label filtering client-side.
ADC also applies the selector to the local file. It merges the selector labels into each local top-level resource and selected nested resources. For diff and sync, this happens before ADC compares the local file with the backend. For validate, this happens before ADC sends the local resources for backend validation.
For example, this command:
adc sync -f catalog.yaml --label-selector team=catalogturns a local service like this:
services:
- name: catalog
routes:
- name: list-products
uris:
- /productsinto an in-memory configuration equivalent to:
services:
- name: catalog
labels:
team: catalog
routes:
- name: list-products
labels:
team: catalog
uris:
- /productsIf the file already has the same label key, the selector value wins.
This behavior keeps future runs stable. Resources created under a selector remain visible to that selector, and nested resources do not produce repeated diffs just because the backend copy has labels added by an earlier sync.
Team A and team B can manage separate files against the same backend:
# Team A
adc sync -f team-a.yaml --label-selector team=a
# Team B
adc sync -f team-b.yaml --label-selector team=bTeam A sees and reconciles only resources labeled team=a. Team B sees and reconciles only resources labeled team=b.
To inspect one partition:
adc dump -o team-a.yaml --label-selector team=a- Do not use label selectors to split ownership of routes inside one shared service. A service is the top-level unit for filtering, so its nested routes move with it.
- Use
--gateway-groupfor API7 Enterprise gateway group isolation. Use--label-selectorwhen teams share a gateway group or when the backend is Apache APISIX. - Be careful with
global_rulesandplugin_metadata. They are global and are not filtered by label selector.