# ingress for tidbcloud serverless o11y openapi
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    konghq.com/plugins: openapi-plugin-force-https,openapi-plugin-bearer-token-auth,openapi-plugin-digest-auth,openapi-plugin-rate-limit
    konghq.com/preserve-host: "false"
    kubernetes.io/ingress.class: kong
  name: serverlessapi-to-o11y-global-portal
  namespace: nightly-ms
spec:
  rules:
  - host: serverless.dev.tidbapi.com
    http:
      paths:
      - backend:
          service:
            name: o11y-global-portal-for-serverless
            port:
              number: 80
        path: /v1beta1/clusters/[0-9A-Za-z]+/monitoringPipelines
        pathType: Prefix
---
# ingress for tidbcloud dedicated o11y openapi
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    konghq.com/plugins: openapi-plugin-force-https,openapi-plugin-bearer-token-auth,openapi-plugin-digest-auth,openapi-plugin-rate-limit
    konghq.com/preserve-host: "false"
    kubernetes.io/ingress.class: kong
  name: dedicatedapi-to-o11y-global-portal
  namespace: nightly-ms
spec:
  rules:
  - host: dedicated.dev.tidbapi.com
    http:
      paths:
      - backend:
          service:
            name: o11y-global-portal-for-dedicated
            port:
              number: 80
        path: /v1beta1/clusters/[0-9A-Za-z]+/monitoringPipelines
        pathType: Prefix
---
# ingress for tidbcloud premium o11y openapi
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    konghq.com/plugins: openapi-plugin-force-https,openapi-plugin-bearer-token-auth,openapi-plugin-digest-auth,openapi-plugin-rate-limit
    konghq.com/preserve-host: "false"
    kubernetes.io/ingress.class: kong
  name: premiumapi-to-o11y-global-portal
  namespace: nightly-ms
spec:
  rules:
  - host: cloud.dev.tidbapi.com
    http:
      paths:
      - backend:
          service:
            name: o11y-global-portal-for-premium
            port:
              number: 80
        path: /v1beta2/tidbs/[0-9A-Za-z]+/monitoringPipelines
        pathType: Prefix
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: o11y-ds-proxy
  namespace: nightly-ms
  annotations:
    konghq.com/plugins: console-plugin-bearer-token-fallback,console-plugin-cookie-auth,console-plugin-console-header-management,o11y-proxy-plugin
    konghq.com/strip-path: "false"
    kubernetes.io/ingress.class: kong
spec:
  rules:
  - host: o11y-ds.us-west-2.nightly.shared.aws.tidbcloud.com
    http:
      paths:
      # regex for o11y cluster uuid to avoid routing to other services.
      # Known issue: whether the o11y cluster uuid belongs to the tenant of this request is not checked
      - path: /[0-9a-fA-F-]{36}/(metrics|diagnosis)/
        pathType: Prefix
        backend:
          service:
            # placeholder for o11y ds, the traffic is routed by o11y-proxy-plugin
            name: o11y-prod-globalserver-svc
            port:
              number: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: o11y-ds-byoc-proxy
  namespace: nightly-ms
  annotations:
    konghq.com/headers.X-Biz-Type: byoc
    konghq.com/plugins: console-plugin-bearer-token-fallback,console-plugin-cookie-auth,console-plugin-console-header-management,o11y-byoc-proxy-plugin
    konghq.com/strip-path: "false"
    kubernetes.io/ingress.class: kong
spec:
  rules:
  - host: o11y-ds.us-west-2.nightly.shared.aws.tidbcloud.com
    http:
      paths:
      - path: /[0-9a-fA-F-]{36}/metrics/
        pathType: Prefix
        backend:
          service:
            name: o11y-dev-globalserver-svc
            port:
              number: 8080
      - path: /[0-9a-fA-F-]{36}/diagnosis/
        pathType: Prefix
        backend:
          service:
            name: o11y-dev-globalserver-svc
            port:
              number: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: o11y-gs-proxy
  namespace: nightly-ms
  annotations:
    konghq.com/plugins: console-plugin-bearer-token-fallback,console-plugin-cookie-auth,console-plugin-console-header-management
    konghq.com/strip-path: "false"
    kubernetes.io/ingress.class: kong
spec:
  rules:
  - host: o11y-gs.us-west-2.nightly.shared.aws.tidbcloud.com
    http:
      paths:
      - path: /api/v1/external/
        pathType: Prefix
        backend:
          service:
            name: o11y-prod-globalserver-svc
            port:
              number: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: o11y-gs-byoc-proxy
  namespace: nightly-ms
  annotations:
    konghq.com/plugins: console-plugin-bearer-token-fallback,console-plugin-cookie-auth,console-plugin-console-header-management
    konghq.com/strip-path: "false"
    kubernetes.io/ingress.class: kong
spec:
  rules:
  - host: o11y-gs.us-west-2.nightly.shared.aws.tidbcloud.com
    http:
      paths:
      - path: /api/v1/external/byoc/
        pathType: Prefix
        backend:
          service:
            name: o11y-dev-globalserver-svc
            port:
              number: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: spend-limit-proxy
  namespace: nightly-ms
  annotations:
    konghq.com/plugins: console-plugin-bearer-token-fallback,console-plugin-cookie-auth,console-plugin-console-header-management,o11y-internal-proxy-plugin
    konghq.com/strip-path: "false"
    kubernetes.io/ingress.class: kong
spec:
  rules:
  - host: us-west-2.nightly.shared.aws.tidbcloud.com
    http:
      paths:
      - path: /external/metrics/tidbcloud/tenant/[0-9A-Za-z]+/project/[0-9A-Za-z]+/application/drhouse
        pathType: Prefix
        backend:
          service:
            name: o11y-prod-globalserver-svc
            port:
              number: 8080
