apache / apisix

The Cloud-Native API Gateway
https://apisix.apache.org/blog/
Apache License 2.0
14.36k stars 2.49k forks source link

help request: How to use Admin API filter with label #11296

Open jmcorne opened 4 months ago

jmcorne commented 4 months ago

Description

Hi team,

I am trying to use Admin API filter to select routes, upstreams, ... with their labels

For example, I have a route defined like this

{
  "createdIndex": 38,
  "key": "/apisix/routes/89da83f2",
  "modifiedIndex": 95,
  "value":
    {
      "priority": 0,
      "methods": ["GET", "POST", "DELETE", "PUT"],
      "desc": "Created by apisix-ingress-controller, DO NOT modify it manually",
      "update_time": 1716803625,
      "id": "89da83f2",
      "name": "services-rlio-sops10-svc_tst_auth-service",
      "upstream_id": "29adb2f2",
      "create_time": 1716803624,
      "labels":
        {
          "argocd.argoproj.io/instance": "shared-services",
          "managed-by": "apisix-ingress-controller",
          "app.kubernetes.io/instance": "rlio-sops10-shared-services",
          "app.kubernetes.io/part-of": "apisix"
        },
      "uris": ["/auth/*"],
      "status": 1
    }
}

I tested

When adding value to filter, it returns nothing.

Does the filter work with key only? If not what is the syntax to filter routes based on label key and value, plz?

Environment

hanqingwu commented 4 months ago

yes, from the source code, i think filter label only support key. image