0

正如标题所示,我正在尝试在 GCP 中配置部署。目前,所有部署都包含一个 Compute 实例,尽管我在尝试将 http-server 和 https-server 标签添加到配置文件中时遇到了麻烦。无需尝试添加标签即可正常创建实例。这是我的 yaml 文件的顶部:

resources:
- type: compute.v1.instance
  name: [redacted]
  properties:
    zone: europe-west1-b
    # Allow http and https traffic
    tags:
    - http-server
    - https-server
    machineType: https://www.googleapis.com/compute/v1/projects/[redacted]/zones/europe-west1-b/machineTypes/f1-micro
.......etc

我得到的错误是:

ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1548860751491-580ae3ee63331-467fd040-1f00fce0]: errors:
- code: CONDITION_NOT_MET
  location: /deployments/[redacted]/resources/[redacted]>$.properties
  message: '"/tags": domain: validation; keyword: type; message: instance does not
    match any allowed primitive type; allowed: ["object"]; found: "array"'

这是我第一次尝试编写 yaml 配置文件,因此可能存在一些简单的上下文问题。

4

2 回答 2

2

我设法自己修复它:

tags:
  items:
  - http-server
  - https-server
于 2019-01-30T15:56:49.707 回答
0

添加标签以计算实例属性:

tags:
      items: ["http-server"]

添加新资源(在计算实例网络接口下方):

- type: compute.v1.firewall
  name: default-allow-http
  properties:
    targetTags: ["http-server"]
    sourceRanges: ["0.0.0.0/0"]
    allowed:
      - IPProtocol: TCP
        ports: ["80"]
于 2021-10-09T00:44:27.937 回答