Google Kubernetes Engine - From External IP to Cloud Endpoint Configuration

11/25/2019

I have a cluster with multiple nodes. I've set up a Cloud Endpoints Portal and deployed my api_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

My issue is I think pretty simple: How can I use the url as API endpoint instead of the external IP of my node? Because if my IP change, I don't want to have to change anything in the code in term on configuration, but just update my 'addresses binding'

I can access the API Documentation from the URL and my service is available from the External IP. I am just looking to bind these both

Right now I have the following behavior:

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\'."
'

Thanks!

EDIT v2 (based on Andres S comment/answer)

host: "<YOUR_NAMING>.endpoints.YOUR_PROJECT_ID.cloud.goog"
x-google-endpoints:
- name: "<YOUR_NAMING>.endpoints.YOUR_PROJECT_ID.cloud.goog"
  target: "IP_ADDRESS"
# host: "test.service.endpoints.example-project.cloud.goog"
  # x-google-endpoints:
  # - name: "test.service.endpoints.example-project.cloud.goog"
  # target: "23.11.95.72"

ERROR: (gcloud.endpoints.services.deploy) Unable to parse Open API, or Google Service Configuration specification from api_config.yaml

-- Emixam23
google-cloud-endpoints
google-kubernetes-engine
grpc
ip
kubernetes

2 Answers

11/26/2019

It might be possible.

Here's the link to openapi but that might be helpful to you.

-- Frank
Source: StackOverflow

12/4/2019

These lines have to be added to your api_config.yaml according to this doc

endpoints:
- name: name.projectid.cloud.goog
  target: "X.X.X.X"

I tested by following the quickstart for gRPC endpoints / GKE

And ultimately was able to get an answer from the endpoint using the domain

(emerald-cumulus-260322 is my temporal projectid used for testing)

$ 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"
}

My final api_config.yaml looks like this:

# 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
-- Andres S
Source: StackOverflow