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.

Dharman
  • 30,962
  • 25
  • 85
  • 135
pcortez
  • 348
  • 2
  • 11
  • 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 Nov 18 '19 at 19:28
  • Hi Kolban, we need the load balancer to connect it to the GCP CDN. I will update the question. Thx – pcortez Nov 18 '19 at 20:05
  • Could your question be a duplicate of ... https://stackoverflow.com/questions/55089580/deploying-cdn-through-google-cloud-deployment-manager – Kolban Nov 18 '19 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 https://cloud.google.com/compute/docs/reference/rest/beta/backendServices and I see that enableCDN is the corresponding property and THAT can be used in the Deployment Manager script. – Kolban Nov 18 '19 at 20:34
  • Here you have a guide on how to add Storage buckets to load balancers - https://cloud.google.com/load-balancing/docs/https/adding-backend-buckets-to-load-balancers . Am I getting this right ? – Andrei Tigau Nov 19 '19 at 10:29
  • as you can see from using gcloud, building a load balancer is not a single resource but actually many individual resources. Each gcloud command is a single API call, each of those API calls needs to be configured as separate resources in the deployment manager config file – Patrick W Nov 20 '19 at 05:06

2 Answers2

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!

Alejandro Barone
  • 1,743
  • 2
  • 13
  • 24
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.

Patrick W
  • 4,603
  • 1
  • 12
  • 26