使用部署管理器创建云运行服务将返回错误"Requested entity was not found."



我正在尝试使用部署管理器创建云运行服务。由于没有对Cloud Run资源类型的本机支持,我使用以下自定义描述符文件为Cloud Run API创建了一个类型提供程序。

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

但是,当我运行此配置以使用部署管理器创建服务时,我会收到错误404-未找到请求的实体。

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

这是因为当部署管理器尝试执行创建操作时,它不是调用特定于位置的服务端点(例如https://europe-west1-run.googleapis.com/apis/serving.knative.dev/v1/namespaces(,而是使用发现url返回的全局端点(https://run.googleapis.com/apis/serving.knative.dev/v1/namespaces(,并且如API文档中所述,全局端点仅支持列表方法。

有人能告诉我如何克服这个问题吗?如有任何帮助,我们将不胜感激。

正如您所说,部署管理器(docs(不支持Cloud Run,也没有很好的解决方法。
因此,我建议使用Terraform来实现此目的。

相关内容

最新更新