首页 > 解决方案 > GCP 云部署负载均衡器后端存储桶

问题描述

如何从 GCP 云部署 yaml 部署网页架构,其中包括存储中的静态文件和具有连接到此存储的后端存储桶的负载均衡器?

我们需要负载均衡器将其连接到 GCP CDN。

标签: google-cloud-platformgoogle-deployment-manager

解决方案


我认为您需要在部署管理器 YAML 脚本上基于 google 的API创建资源。

据我了解,您需要将负载平衡后端存储桶连接,后者将其连接到存储桶。我假设不需要创建存储桶。

所以你需要的资源是compute.beta.backendBucketcompute.v1.urlMap. YAML 文件看起来像这样:

resources:
- type: compute.beta.backendBucket
  name: backendbucket-test
  properties:
    bucketName: already-created-bucket
- type: compute.v1.urlMap
  name: urlmap-test
  properties:
    defaultService: $(ref.backendbucket-test.selfLink)
    hostRules: 
    - hosts: ["*"]
      pathMatcher: "allpaths"
    pathMatchers:
    - name: "allpaths"
      defaultService: $(ref.backendbucket-test.selfLink)
      pathRules:
      - service: $(ref.backendbucket-test.selfLink)
        paths: ["/*"]

请注意,这names完全取决于您。另请参阅ref(来自参考)将backendBucket第一步创建的链接到第二步的链接urlMap

值得一提的是,您可能需要更多资源来获得完整的解决方案(特别是负载均衡器的前端部分)。

希望它可以在某种程度上有所帮助,干杯!


推荐阅读