0

I have a static website bundle I want to serve on my cluster. The bundle is stored in a google cloud storage bucket, which makes me think I may not actually need a separate "server" to return the files.

I have been able to get Python-Flask to reference the files from the bucket, but I can't seem to figure out how to get Ambassador to do the same. I could do something like add the bundle to an nginx instance, but I don't want to build the JS bundle into any docker image so I can do rapid updates.

I can't figure out how to set up an ambassador route to do the following:

If a user goes to

https://my-website.com/

They get the index.html served from my Google Bucket my-bucket/index.html

and when the index.html references a file internally (/static/js/main.js), Ambassador serves up the file found at my-bucket/static/js/main.js

I have tried setting up a service like so:

apiVersion: v1
kind: Service
metadata:
  annotations:
    getambassador.io/config: |
      ---
      apiVersion: ambassador/v0
      kind: Mapping
      name: website_mapping
      prefix: /website/
      service: https://my-bucket-url/index.html
  name: website-service
  labels:
    app: website-service
spec:
  ports:
    - port: 80
      targetPort: 80
      name: http-website
  selector:
    app: website

But navigating to my-website.com/website/ only gets me a 503 error with the console complaining "the character of the encoding of the plain text document was not declared"

I feel like I'm going about this wrong. Can I serve straight from the bucket like this using Ambassador, or do I really need something like nginx?

mstorkson
  • 1,130
  • 1
  • 10
  • 26
  • If you enter `https://my-bucket-url/index.html` into your browser, do you get what you want? Ambassador will serve that content (as a reverse proxy). Of course, for this to work, 'my-website.com' has to point to the IP address of the Ambassador service. – Laszlo Valko Jan 27 '19 at 03:07
  • I get the index.html, but the problem is there needs to be a little more logic involved to properly interpret the import paths inside index.html. For this to work in flask, I had to write an endpoint that would redirect certain paths as file access. – mstorkson Jan 28 '19 at 16:16
  • I definitely don't understand what you wanted to say... Ambassador will provide a reverse proxy for you. You need a web service running behind Ambassador. If you happen to have a bucket storage web service that looks exactly like a web server serving your web site (it can serve your files as a web server, ie you can browse your web site directly there), then Ambassador can do the reverse proxying to this web service. If not, then you need an extra web server as well somewhere between the Ambassador and your file storage service. – Laszlo Valko Jan 29 '19 at 12:56

1 Answers1

1

Ambassador is actually not a web server (as Laszlo Valko points out). It needs to proxy your request to some other web server for this to work -- that can certainly be Flask (in fact, the Ambassador diagnostic service is a Flask application started at boot time inside the Ambassador pod), but it needs to be running somewhere. :)

Flynn
  • 36
  • 1