## FIXME: move to dataplane folder until all regions are migrated to new dataplane cd.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/auth-cache-key: $tenant$clusterid$remote_user$http_authorization
    nginx.ingress.kubernetes.io/auth-url: https://us-west-2.nightly.shared.aws.tidbcloud.com/api/v2025/cloud/v1beta2/tidbs/$clusterid?orgId=$tenant
    nginx.ingress.kubernetes.io/cors-allow-methods: GET
    nginx.ingress.kubernetes.io/cors-allow-origin: '*'
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/configuration-snippet: |
      set $tenant $2;
      set $clusterid $3;
      access_by_lua_block {
        local dynamic_route = require("dynamic_route")
        dynamic_route.rewrite_url("ignoreProject")
      }
  name: dev-dataplane-nextgen-open-read
  namespace: observability
spec:
  ingressClassName: nginx-read
  rules:
  - http:
      paths:
      - backend:
          service:
            name: vmselect-vmcluster
            port:
              number: 8481
        path: /external/metrics/(dev-tidbcloud-nextgen)/tenant/(.*)/application/(.*)/(api/v1/.*)
        pathType: ImplementationSpecific
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/auth-cache-key: $tenant$clusterid$remote_user$http_authorization
    nginx.ingress.kubernetes.io/auth-url: https://us-west-2.staging.shared.aws.tidbcloud.com/api/v2025/cloud/v1beta2/tidbs/$clusterid?orgId=$tenant
    nginx.ingress.kubernetes.io/cors-allow-methods: GET
    nginx.ingress.kubernetes.io/cors-allow-origin: '*'
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/configuration-snippet: |
      set $tenant $2;
      set $clusterid $3;
      access_by_lua_block {
        local dynamic_route = require("dynamic_route")
        dynamic_route.rewrite_url("ignoreProject")
      }
  name: staging-dataplane-nextgen-open-read
  namespace: observability
spec:
  ingressClassName: nginx-read
  rules:
  - http:
      paths:
      - backend:
          service:
            name: vmselect-vmcluster
            port:
              number: 8481
        path: /external/metrics/(staging-tidbcloud-nextgen)/tenant/(.*)/application/(.*)/(api/v1/.*)
        pathType: ImplementationSpecific
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/auth-cache-key: $tenant$clusterid$remote_user$http_authorization
    nginx.ingress.kubernetes.io/auth-url: https://us-west-2.prod.aws.tidbcloud.com/api/v2025/cloud/v1beta2/tidbs/$clusterid?orgId=$tenant
    nginx.ingress.kubernetes.io/cors-allow-methods: GET
    nginx.ingress.kubernetes.io/cors-allow-origin: '*'
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/configuration-snippet: |
      set $tenant $2;
      set $clusterid $3;
      access_by_lua_block {
        local dynamic_route = require("dynamic_route")
        dynamic_route.rewrite_url("ignoreProject")
      }
  name: prod-dataplane-nextgen-open-read
  namespace: observability
spec:
  ingressClassName: nginx-read
  rules:
  - http:
      paths:
      - backend:
          service:
            name: vmselect-vmcluster
            port:
              number: 8481
        path: /external/metrics/(prod-tidbcloud-nextgen)/tenant/(.*)/application/(.*)/(api/v1/.*)
        pathType: ImplementationSpecific
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/auth-cache-key: $tenant$clusterid$remote_user$http_authorization
    nginx.ingress.kubernetes.io/auth-url: https://us-west-2.nightly.shared.aws.tidbcloud.com/api/v2025/cloud/v1beta2/tidbs/$clusterid?orgId=$tenant
    nginx.ingress.kubernetes.io/cors-allow-methods: GET
    nginx.ingress.kubernetes.io/cors-allow-origin: '*'
    nginx.ingress.kubernetes.io/cors-allow-headers: >-
      content-type,
      authorization,
      x-provider,
      x-region,
      x-env,
      x-biz-type,
      x-org-id,
      x-cluster-id,
      x-deploy-type
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/configuration-snippet: |
      set $tenant $2;
      set $clusterid $3;
  name: dev-dataplane-nextgen-open-read-diagnosis-query
  namespace: observability
spec:
  ingressClassName: nginx-read
  rules:
  - http:
      paths:
      - backend:
          service:
            name: diagnosis-query
            port:
              number: 8081
        path: /external/slowquery/(dev-tidbcloud-nextgen)/tenant/(.*)/application/(.*)/(api/v1/.*)
        pathType: ImplementationSpecific
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/auth-cache-key: $tenant$clusterid$remote_user$http_authorization
    nginx.ingress.kubernetes.io/auth-url: https://us-west-2.staging.shared.aws.tidbcloud.com/api/v2025/cloud/v1beta2/tidbs/$clusterid?orgId=$tenant
    nginx.ingress.kubernetes.io/cors-allow-methods: GET
    nginx.ingress.kubernetes.io/cors-allow-origin: '*'
    nginx.ingress.kubernetes.io/cors-allow-headers: >-
      content-type,
      authorization,
      x-provider,
      x-region,
      x-env,
      x-biz-type,
      x-org-id,
      x-cluster-id,
      x-deploy-type
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/configuration-snippet: |
      set $tenant $2;
      set $clusterid $3;
  name: staging-dataplane-nextgen-open-read-diagnosis-query
  namespace: observability
spec:
  ingressClassName: nginx-read
  rules:
  - http:
      paths:
      - backend:
          service:
            name: diagnosis-query
            port:
              number: 8081
        path: /external/slowquery/(staging-tidbcloud-nextgen)/tenant/(.*)/application/(.*)/(api/v1/.*)
        pathType: ImplementationSpecific
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/auth-cache-key: $tenant$clusterid$remote_user$http_authorization
    nginx.ingress.kubernetes.io/auth-url: https://us-west-2.prod.aws.tidbcloud.com/api/v2025/cloud/v1beta2/tidbs/$clusterid?orgId=$tenant
    nginx.ingress.kubernetes.io/cors-allow-methods: GET
    nginx.ingress.kubernetes.io/cors-allow-origin: '*'
    nginx.ingress.kubernetes.io/cors-allow-headers: >-
      content-type,
      authorization,
      x-provider,
      x-region,
      x-env,
      x-biz-type,
      x-org-id,
      x-cluster-id,
      x-deploy-type
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/configuration-snippet: |
      set $tenant $2;
      set $clusterid $3;
  name: prod-dataplane-nextgen-open-read-diagnosis-query
  namespace: observability
spec:
  ingressClassName: nginx-read
  rules:
  - http:
      paths:
      - backend:
          service:
            name: diagnosis-query
            port:
              number: 8081
        path: /external/slowquery/(prod-tidbcloud-nextgen)/tenant/(.*)/application/(.*)/(api/v1/.*)
        pathType: ImplementationSpecific
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/cors-allow-methods: GET,POST
    nginx.ingress.kubernetes.io/cors-allow-origin: "*"
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/configuration-snippet: |
      access_by_lua_block {
        local dynamic_route = require("dynamic_route")
        dynamic_route.rewrite_url("useO11yID")
      }
  name: dataplane-metrics-read
  namespace: observability
spec:
  ingressClassName: nginx-read
  rules:
    - http:
        paths:
          - backend:
              service:
                name: vmselect-vmcluster
                port:
                  number: 8481
            path: /([0-9a-fA-F-]{36})/metrics/(api/v1/.+)
            pathType: ImplementationSpecific
