10.4. 使服务发现
3scale 可以发现部署或部署到 OpenShift 集群的 API 服务。要达到此目的,请将 OpenShift Service Object YAML 定义配置为包含以下元数据:
metadata:
labels:
discovery.3scale.net: "true"
annotations:
discovery.3scale.net/scheme: <http | https>
discovery.3scale.net/port: '<port number of the service within the cluster>'
discovery.3scale.net/path: <relative base path of the API backend from the root>
discovery.3scale.net/description-path: <relative or absolute path to the Open API Specification for the API>
在描述的元数据中,端口和 方案是 强制注解。
另外,只有在 Content-Type 标头是以下值之一时,服务发现才会导入规格:
-
application/swagger+json -
application/vnd.oai.openapi+json -
application/json
注意
确保用户或服务帐户(取决于配置的身份验证模式)具有查看命名空间和服务的适当特权。