我已经设置了 Google Cloud Endpoints 项目,并且可以调用 http/https 请求。 Endpoints 为我提供了可以使用的 MY_API.endpoints.MY_PROJECT.cloud.goog 域名。我正在使用具有 HTTP/JSON 到 gRPC 转码功能的 gRPC Cloud Endpoints。
它部署在Google Kubernetes Engine上(部署yaml脚本附在最后)。
当我尝试使用该 URL 创建推送订阅时,出现下一个错误:
“提供的 HTTP URL 未在订阅的父级中注册
项目(url =“https://MY_API.endpoints.MY_PROJECT.cloud.goog/v1/path”,project_id =“PROJECT_ID”)。
我的 gcloud 通话:
gcloud pubsub subscriptions create SUB_NAME --topic=projects/MY_PROJECT/topics/MY_TOPIC --push-endpoint="https://MY_API.endpoints.MY_PROJECT.cloud.goog/v1/path"
我尝试使用该 DNS 名称创建 Cloud DNS 公共区域并设置相应的记录。但我仍然无法在 Google Search Console 中验证所有权。
问题是如何为 MY_API.endpoints.MY_PROJECT.cloud.goog 域设置 DNS TXT 记录以验证所有权?或者如何以其他方式将 Pubsub 推送订阅与 Cloud Endpoints gRPC 结合使用?
如果我能够更改转换为 HTTP 的 gRPC 响应的元或标头,我可以验证域的所有权。但我怀疑是否有办法。
我用于部署的 Kubernetes 脚本(如果有帮助的话)。
apiVersion: v1
kind: Service
metadata:
name: GKE_SERVICE_NAME
spec:
ports:
# Port that accepts gRPC and JSON/HTTP2 requests over HTTP.
- port: 80
targetPort: 9000
protocol: TCP
name: http2
selector:
app: GKE_SERVICE_NAME
type: LoadBalancer
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: GKE_SERVICE_NAME
spec:
replicas: 1
template:
metadata:
labels:
app: GKE_SERVICE_NAME
spec:
containers:
- name: esp
image: gcr.io/endpoints-release/endpoints-runtime:1
args: [
"--http2_port=9000",
"--service=MY_API.endpoints.MY_PROJECT.cloud.goog",
"--rollout_strategy=managed",
"--backend=grpc://127.0.0.1:50051"
]
ports:
- containerPort: 9000
- name: MY_CONTAINER_NAME
image: gcr.io/MY_PROJECT/IMAGE_NAME:v1
ports:
- containerPort: 50051