3

How to deploy a web page architecture from a GCP Cloud Deployment yaml, which includes static files in a storage and a load balancer that has a backend bucket connected to this storage?

We need the load balancer to connect it to the GCP CDN.

6
  • Howdy ... can you elaborate on what you mean by a "web page architecture"? I am thinking that a GCS bucket can host your static files and at that point you have a "web page architecture" ... but there should be no need for a load balance as GCS is just "there" already. What are you load balancing too? Do you have back-end logic such as Compute Engines or Cloud Functions? If so ... then a generic GCP Deployment Manager yaml isn't likely to assist.
    – Kolban
    Commented Nov 18, 2019 at 19:28
  • Hi Kolban, we need the load balancer to connect it to the GCP CDN. I will update the question. Thx
    – pcortez
    Commented Nov 18, 2019 at 20:05
  • Could your question be a duplicate of ... stackoverflow.com/questions/55089580/…
    – Kolban
    Commented Nov 18, 2019 at 20:29
  • 1
    Aha!! A trick I use when building Deployment Manager scripts is to ask how would I do this with just GCLOUD. It appears that the gcloud recipe uses gcloud compute backend-services update [BACKEND_SERVICE_NAME] \ --enable-cdn .... note the "--enable-cdn". This then takes me to cloud.google.com/compute/docs/reference/rest/beta/… and I see that enableCDN is the corresponding property and THAT can be used in the Deployment Manager script.
    – Kolban
    Commented Nov 18, 2019 at 20:34
  • Here you have a guide on how to add Storage buckets to load balancers - cloud.google.com/load-balancing/docs/https/… . Am I getting this right ? Commented Nov 19, 2019 at 10:29

2 Answers 2

3

I think you need to create the resources based on google's API on the deployment manager YAML script.

As my understanding you need to connect a load balancing with a backend bucket, and the latter connect it to a storage bucket. I will asume the bucket creation is not necessary.

So the resources you need are compute.beta.backendBucket and the compute.v1.urlMap. The YAML file will look -kind- of this:

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: ["/*"]

Note that the names are completely up to you. Also see there are ref (from reference) to link the backendBucket created on the first step to the urlMap of the second one.

Is good to mention that you will probably need more resources for a complete solution (specifically the frontend part of the load balancer).

Hope it can help in some way, Cheers!

0

You can follow this guide from Google on how to create a Load Balancer to serve static content from a bucket. Note that the bucket and its content must already exists, the content will not be created by DM.

Follow the gcloud steps, not the console steps. For each step, find the correct API call and create a separate resource in your deployment manager config for each step.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.