Menu Close

6.5.4. 定义后端映射规则

将 Openshift Container Platform 与新创建的 3scale 租户一起使用,在后端自定义资源中定义所需的后端映射规则。

考虑以下观察:

  • httpMethod、mode、in c rement 和 metricMethodRef 是必填字段。
  • metricMethodRef 包含对现有指标或方法映射键名称 system_name 的引用。在以下示例中,按s

步骤

  • 将后端映射规则添加到新的 3scale 后端,如下例所示:

    apiVersion: capabilities.3scale.net/v1beta1
    kind: Backend
    metadata:
      name: backend-1
    spec:
      name: "My Backend Name"
      privateBaseURL: "https://api.example.com"
      mappingRules:
        - httpMethod: GET
          pattern: "/pets"
          increment: 1
          metricMethodRef: hits
        - httpMethod: GET
          pattern: "/pets/id"
          increment: 1
          metricMethodRef: hits
      metrics:
        hits:
          description: Number of API hits
          friendlyName: Hits
          unit: "hit"