feat: support consumer labels from metadata labels#2760
Merged
AlinsRan merged 3 commits intoMay 12, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
nic-6443
approved these changes
May 11, 2026
shreemaan-abhishek
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ApisixConsumer.metadata.labelsandConsumer.metadata.labelsas consumer labelsApisixRoutewith the same merge behavior and add coverageConsumer labels
This change is mainly for propagating CRD labels into data plane resource labels.
Both
ApisixConsumer.metadata.labelsandConsumer.metadata.labelsare propagated to the generated APISIX consumer as custom labels, so users can inject business metadata such as tenant, team, or plan from the Kubernetes CRD into the data plane resource.If a user-defined label key conflicts with a controller-generated reserved label, the controller-generated value is preserved.
ApisixConsumer CRD example
Consumer CRD example
Data plane result example
The generated APISIX consumer will carry the injected labels together with controller-managed labels, for example:
{ "username": "ingress-apisix_alice", "labels": { "team": "payments", "plan": "gold", "k8s/name": "alice", "k8s/namespace": "ingress-apisix", "k8s/kind": "ApisixConsumer", "k8s/controller-name": "apisix.apache.org/apisix-ingress-controller", "manager-by": "apisix-ingress-controller" } }The same merge behavior also applies to
Consumerresources, so labels defined on either CRD can be consumed directly on the data plane side.Testing
go test ./internal/controller/label ./internal/adc/translatorgo test $(go list ./... | grep -v /e2e | grep -v /conformance)(the benchmark package still requires a live Kubernetes endpoint in this environment)