【问题标题】:How do I configure a Google Compute Instance to allow http traffic when deploying from a YAML config file?从 YAML 配置文件部署时,如何配置 Google 计算实例以允许 http 流量?
【发布时间】:2019-01-30 15:19:01
【问题描述】:

正如标题所示,我正在尝试在 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 配置文件,因此可能存在一些简单的上下文问题。

【问题讨论】:

    标签: yaml google-compute-engine google-deployment-manager


    【解决方案1】:

    我自己解决了这个问题:

    tags:
      items:
      - http-server
      - https-server
    

    【讨论】:

      【解决方案2】:

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

      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"]
      

      【讨论】:

        猜你喜欢
        • 2019-04-06
        • 2019-11-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-05-19
        • 1970-01-01
        • 2012-11-19
        相关资源
        最近更新 更多