Reputation: 389
I'm trying to create a Cloud Run service using the Deployment Manager. As there's no native support for Cloud Run resource type, I created a type provider for the Cloud Run API using the following custom descriptor file.
resources:
- name: cloudrun-type
type: deploymentmanager.v2beta.typeProvider
properties:
descriptorUrl: https://europe-west1-run.googleapis.com/$discovery/rest?version=v1
options:
inputMappings:
- fieldName: Authorization
location: HEADER
value: >
$.concat("Bearer ", $.googleOauth2AccessToken())
collectionOverrides:
- collection: namespaces.services
options:
virtualProperties: |
schema: http://json-schema.org/draft-04/schema#
type: object
properties:
metadata:
type: object
description: https://cloud.google.com/run/docs/reference/rest/Shared.Types/ObjectMeta
spec:
type: object
description: https://cloud.google.com/run/docs/reference/rest/v1/namespaces.services#ServiceSpec
status:
type: object
description: https://cloud.google.com/run/docs/reference/rest/v1/namespaces.services#ServiceStatus
inputMappings:
- methodMatch: ^create$
location: PATH
fieldName: parent
value: $.concat("namespaces/", $.project)
- methodMatch: ^(get|replaceService|delete)$
location: PATH
fieldName: name
value: $.concat("namespaces/", $.project, "/services/", $.resource.name)
- methodMatch: ^create$
location: BODY
fieldName: apiVersion
value: $.concat("serving.knative.dev/v1")
- methodMatch: ^create$
location: BODY
fieldName: kind
value: $.concat("Service")
- methodMatch: ^create$
location: BODY
fieldName: metadata.name
value: $.resource.name
- methodMatch: ^replaceService$
location: BODY
fieldName: metadata
value: $.resource.self.metadata
- methodMatch: ^(create|replaceService)$
location: BODY
fieldName: spec.template.spec
value: $.resource.properties.spec
However, when I run this configuration to create the service using the Deployment Manager, I'm getting the error 404 - Requested entity was not found.
ERROR: (gcloud.deployment-manager.deployments.update) Error in Operation:
- code: RESOURCE_ERROR
location: /deployments/run1/resources/dm-cloud-run
message: '{"ResourceType":"<project-id>/cloudrun-type:namespaces.services","ResourceErrorCode":"404","ResourceErrorMessage":{"code":404,"message":"Requested
entity was not found.","status":"NOT_FOUND","statusMessage":"Not Found","requestPath":"https://run.googleapis.com/apis/serving.knative.dev/v1/namespaces/<project-id>/services","httpMethod":"POST"}}'
This is because when the Deployment Manager tries to perform the create operation, instead of calling the location specific service endpoint (e.g. https://europe-west1-run.googleapis.com/apis/serving.knative.dev/v1/namespaces
), it is using the global endpoint (https://run.googleapis.com/apis/serving.knative.dev/v1/namespaces
) returned by the discovery url, and as stated in the API documentation, the global endpoint supports list method only.
Could someone let me know how to overcome this issue? Any help would be greatly appreciated.
Upvotes: 2
Views: 871