Dav*_*ugh 6 google-cloud-platform google-kubernetes-engine google-cloud-api-gateway
我正在寻找有关如何将 Google Cloud API Gateway 与 GKE 中托管的微服务/API 结合使用的工作示例/教程。例如,当我尝试创建 API 网关并将其指向 GKE 上的现有 API 时,出现以下错误:
后端 URL“http://35.xxx.xxx.xxx/legalentities”被禁止:无法通过 IP 地址路由请求。
在撰写本文时,API Gateway 仍处于Beta阶段,因此它的功能可能不完整,并且文档可能很少。目前,API Gateway 的缺点之一是您的 GKE 环境生成只能通过 IP 地址访问的面向互联网的服务。但是,您需要将 FQDN 放入您的文件中openapi.yaml(见下文)。这就是你的错误可能来自的地方。
缓解此问题的两种选择:
在 GKE IP 地址前面使用负载均衡器。这样您就可以使用负载均衡器的 FQDN。但是,我不确定在此设置中身份验证是否仍然有效,并且用户可能能够绕过 API 网关。
在托管 Cloud Run 中部署面向互联网的应用程序。这将始终生成 FQDN。您只需填写即可x-google-backend address。您需要为 Cloud Run 配置无服务器 VPC 访问,以便应用程序与您的 GKE 集群进行通信。
swagger: '2.0'
info:
title: API_ID optional-string
description: Sample API on API Gateway with a Google Cloud Functions backend
version: 1.0.0
schemes:
- https
produces:
- application/json
paths:
/hello:
get:
summary: Greet a user
operationId: hello
x-google-backend:
address: [FQDN HERE]
responses:
'200':
description: A successful response
schema:
type: string
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7592 次 |
| 最近记录: |