未找到 GCP 健康检查外部 HTTP LoadBalancer yaml

GCP Healthcheck not found External HTTP LoadBalancer yaml

我对 google 云部署有点陌生,但我目前正在尝试在 google 云部署管理器中使用 yaml 设置外部 http 负载平衡器。 负载均衡器使用健康检查,但是当我尝试重定向到我的健康检查所在的位置时,它给出了找不到它的错误。

我尝试在控制台中手动创建健康检查,但它仍然说找不到它。

我已经查看了此处的文档 https://cloud.google.com/compute/docs/reference/rest/v1/backendServices and here https://cloud.google.com/compute/docs/reference/rest/v1/healthChecks,它看起来应该可以工作,但实际上没有。

我还在 google 和堆栈溢出上搜索了答案,但没有找到任何答案。我还尝试使用 selflink 到 link 进行健康检查。但这也行不通。我觉得我在这里错过了什么。

- name: healthcheckpls
  type: compute.v1.httpHealthCheck
  properties:
    port: 80
    requestPath: /

- name: bes
  type: compute.v1.backendService
  properties:
    port: 80
    portName: http
    protocol: HTTP
    backends:
    - name: bes
      balancingMode: UTILIZATION
      capacityScaler: 1.0
      group: zones/us-central1-f/instanceGroups/instancegroup-1
    maxUtilization: 0.8
    connectionDraining:
      drainingTimeoutSec: 300
    healthChecks: 
    - global/httpHealthChecks/healthcheckpls
- name: apache-url-map
  type: compute.v1.urlMap
  properties:
    defaultService: $(ref.bes.selfLink)
- name: apache-http-proxy
  type: compute.v1.targetHttpProxy
  properties:
    urlMap: $(ref.apache-url-map.selfLink)
- name: apache-ipaddress
  type: compute.v1.globalAddress
- name: apache-http-forwardingrule
  type: compute.v1.globalForwardingRule
  properties:
    target: $(ref.apache-http-proxy.selfLink)
    IPAddress: $(ref.apache-ipaddress.address)
    IPProtocol: TCP
    portRange: 80-80

这是我从部署管理器得到的错误。

ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1606653109305-5b53e13db7fbd-7084e34a-f0444d0f]: errors:
- code: RESOURCE_ERROR
  location: /deployments/lampdeployment/resources/bes
  message: "{\"ResourceType\":\"compute.v1.backendService\",\"ResourceErrorCode\"\
    :\"404\",\"ResourceErrorMessage\":{\"code\":404,\"errors\":[{\"domain\":\"global\"\
    ,\"message\":\"The resource 'projects/cloudautomation-296812/global/httpHealthChecks/healthcheckpls'\
    \ was not found\",\"reason\":\"notFound\"}],\"message\":\"The resource 'projects/cloudautomation-296812/global/httpHealthChecks/healthcheckpls'\
    \ was not found\",\"statusMessage\":\"Not Found\",\"requestPath\":\"https://compute.googleapis.com/compute/v1/projects/cloudautomation-296812/global/backendServices\"\
    ,\"httpMethod\":\"POST\"}}"

我错过了什么吗?为什么这不起作用?

我对此很陌生,所以如果我缺少一些基本知识,我也想知道 :D

感谢大家的帮助!非常感谢。

经过大量故障排除后,我明白了。我必须使用:

    healthChecks: 
    - $(ref.healthcheckpls.selfLink)