0
votes

I am trying to configure Google Cloud Endpoints using Cloud Functions. For the same I am following instructions from: https://cloud.google.com/endpoints/docs/openapi/get-started-cloud-functions

I have followed the steps given and have come to the point of building the service config into a new ESPv2 Beta docker image. When I give the command:

chmod +x gcloud_build_image
./gcloud_build_image -s CLOUD_RUN_HOSTNAME \
    -c CONFIG_ID -p ESP_PROJECT_ID

after replacing the hostname and configid and projectid I get the following error

>     -c service-host-name-xxx -p project-id
Using base image: gcr.io/endpoints-release/endpoints-runtime-serverless:2
++ mktemp -d /tmp/docker.XXXX
+ cd /tmp/docker.5l3t
+ gcloud endpoints configs describe service-host-name-xxx.run.app --project=project-id --service=service-host-name-xxx.app --format=json
ERROR: (gcloud.endpoints.configs.describe) NOT_FOUND: Service configuration 'services/service-host-name-xxx.run.app/configs/service-host-name-xxx' not found.
+ error_exit 'Failed to download service config'
+ echo './gcloud_build_image: line 46: Failed to download service config (exit 1)'
./gcloud_build_image: line 46: Failed to download service config (exit 1)
+ exit 1

Any idea what am I doing wrong? Thanks

2

2 Answers

0
votes

My bad. I repeated the steps and got it working. So I guess there must have been some mistake I did while trying it out. The document works as it states.

0
votes

I had the same error. When running the script twice it works. This means you have to already have a service endpoint configured, which does not exist yet when the script tries to fetch the endpoint information with:

gcloud endpoints configs describe service-host-name-xxx.run.app

What I would do (in cloudbuild) is to supply some sort of an "empty" container first. I used the following example on top of my cloudbuild.yaml:

gcloud run services list \
  --platform managed \
  --project ${PROJECT_ID} \
  --region europe-west1 \
  --filter=${PROJECT_ID}-esp-svc \
  --format yaml | grep . ||
gcloud run deploy ${PROJECT_ID}-esp-svc \
  --image="gcr.io/endpoints-release/endpoints-runtime-serverless:2" \
  --allow-unauthenticated \
  --platform managed \
  --project=${PROJECT_ID} \
  --region=europe-west1 \
  --timeout=120