Google Kubernetes引擎-从外部IP到云端点配置

Google Kubernetes引擎-从外部IP到云端点配置,kubernetes,ip,google-kubernetes-engine,grpc,google-cloud-endpoints,Kubernetes,Ip,Google Kubernetes Engine,Grpc,Google Cloud Endpoints,我有一个具有多个节点的集群。我已经建立了一个云端点门户,并部署了我的api\u config.yaml # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.ap

我有一个具有多个节点的集群。我已经建立了一个云端点门户,并部署了我的
api\u config.yaml

#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# A Bookstore example API configuration.
#
# Below, replace MY_PROJECT_ID with your Google Cloud Project ID.
#

# The configuration schema is defined by service.proto file
# https://github.com/googleapis/googleapis/blob/master/google/api/service.proto
type: google.api.Service
config_version: 3

#
# Name of the service configuration.
#
name: MY-SERVICE.service.endpoints.MY-PROJECT-ID.cloud.goog

#
# API title to appear in the user interface (Google Cloud Console).
#
title: MyService gRPC API
apis:
  - name: endpoints.MY-PROJECT-ID.service.MY-SERVICE.MyService

我的问题很简单:我如何使用url作为API端点而不是节点的外部IP?因为如果我的IP发生变化,我不想在配置方面对代码进行任何更改,只需更新我的“地址绑定”

我可以从URL访问API文档,并且可以从外部IP访问我的服务。我只是想把它们都绑起来

现在我有以下行为:

MBP-de-Emixam23:service-interface emixam23$ gcloud endpoints services deploy service.pb api_config.yaml
ERROR: (gcloud.endpoints.services.deploy) INVALID_ARGUMENT: Cannot convert to service config.
'location: "api_config.yaml:36"
kind: ERROR
message: "Cannot resolve api \'endpoints.MY-PROJECT-ID.service.MY-SERVICE.MyService\'."
'
谢谢

编辑v2(基于Andres的评论/回答)
host:“.endpoints.YOUR_PROJECT_ID.cloud.goog”
x-google-endpoints:
-名称:“.endpoints.YOUR_PROJECT_ID.cloud.goog”
目标:“IP_地址”
#主机:“test.service.endpoints.example project.cloud.goog”
#x-google-endpoints:
#-name:“test.service.endpoints.example project.cloud.goog”
#目标:“23.11.95.72”
错误:(gcloud.endpoints.services.deploy)无法从API_config.yaml解析开放API或Google服务配置规范

这是可能的


以下是openapi的代码,但这可能会对您有所帮助。

必须根据此代码将这些代码行添加到您的api\u config.yaml中

我通过以下方法进行测试:

最终能够使用域从端点获得答案

(emerald-cumulus-260322是我用于测试的时间投影)

我的最终api_config.yaml如下所示:

# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# A Bookstore example API configuration.
#
# Below, replace MY_PROJECT_ID with your Google Cloud Project ID.
#

# The configuration schema is defined by service.proto file
# https://github.com/googleapis/googleapis/blob/master/google/api/service.proto
type: google.api.Service
name: bookstore.endpoints.projectidhere.cloud.goog
endpoints:
- name: bookstore.endpoints.projectidhere.cloud.goog
  target: "X.X.X.X"

config_version: 3

#
# Name of the service configuration.
#

#
# API title to appear in the user interface (Google Cloud Console).
#
title: Bookstore gRPC API
apis:
- name: endpoints.examples.bookstore.Bookstore

#
# API usage restrictions.
#
usage:
  rules:
  # ListShelves methods can be called without an API Key.
  - selector: endpoints.examples.bookstore.Bookstore.ListShelves
    allow_unregistered_calls: true

谢谢你的回答。我目前正在跟踪该链接,但yaml会抛出错误。您可以发布在尝试使用所述FQDN时遇到的具体错误吗?另外,您是否尝试为您的端点配置DNS(也许这会使其成为可能)。我遵循了,并且能够通过其URL到达端点,您可以检查它。我想可能是api_config.yaml有问题,您可以共享它吗?你正在替换url中的projectid吗?问题中已经有了,谢谢你的帮助我知道,检查我的更新,我的api_config.yaml现在看起来像第二段代码我不确定这是否是由于stackoverflow中的UI造成的,但在问题中,前三行没有缩进,只有第四行目标。。。之前有一个空格,第一步指定不缩进或嵌套,但在您共享的那一步中,每行都有一个增量缩进,这可能值得更改和尝试抱歉,我认为建议的快速启动是错误的,因为您使用的是gRPC api,建议的DNS设置在这种情况下不正确,我会用正确的答案更新我的答案,因为我确实尝试了你的链接(我实际上遵循的第一个链接),但我得到了一个错误。请看编辑V2I将在我有时间的时候看一看,让我回到你身边:)谢谢你的帮助,谢谢!没问题!好啊我有很多工作要做,所以我现在要重新开始,如果我有任何问题,我会发表评论:)我做了,谢谢你的帮助!我现在不想设置任何API限制,我该怎么做?
endpoints:
- name: name.projectid.cloud.goog
  target: "X.X.X.X"
$ python bookstore_client.py --host bookstore.endpoints.emerald-cumulus-260322.cloud.goog --port 80                                 
ListShelves: shelves {
  id: 1
  theme: "Fiction"
}
shelves {
  id: 2
  theme: "Fantasy"
}
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# A Bookstore example API configuration.
#
# Below, replace MY_PROJECT_ID with your Google Cloud Project ID.
#

# The configuration schema is defined by service.proto file
# https://github.com/googleapis/googleapis/blob/master/google/api/service.proto
type: google.api.Service
name: bookstore.endpoints.projectidhere.cloud.goog
endpoints:
- name: bookstore.endpoints.projectidhere.cloud.goog
  target: "X.X.X.X"

config_version: 3

#
# Name of the service configuration.
#

#
# API title to appear in the user interface (Google Cloud Console).
#
title: Bookstore gRPC API
apis:
- name: endpoints.examples.bookstore.Bookstore

#
# API usage restrictions.
#
usage:
  rules:
  # ListShelves methods can be called without an API Key.
  - selector: endpoints.examples.bookstore.Bookstore.ListShelves
    allow_unregistered_calls: true