Sign inSign up

userbradley/gcs-web-server

By userbradley

•Updated over 3 years ago

Container to mount a GCS bucket and serve it using nginx

Image
0

872

userbradley/gcs-web-server repository overview

⁠GCS Web server

This is a simple docker container that allows you to connect to a GCS bucket and serve webpages from it, in Kubernetes.

⁠Quick start

See the Quick Start⁠ with supplied Terraform and Kubernetes Manifests

⁠What you need pre-existing

  • GKE Cluster
  • Workload Identity Enabled
  • Kubernetes Service account connected to GSA
  • GCS Bucket
⁠What if I don't want to use Workload Identity

Warning You should really consider using workload identity

Learn more here⁠

plutov/gcs-k8f-deployment-full.yml⁠

⁠Useful information

⁠Where the content should go

Upload what ever static site you want in to the root of the bucket.

All pages will get rendered when you hit the link.

The server supports sub-pages, so if you are uploading everything in go gs://gcs-webstite/site/index.html - Your page will be available at http://<>/site/index.html

⁠What health check endpoints exist?
Name of endpointResponse codeExample response
/healthzhttp/200{"status":"UP"}
/healthhttp/200{"status":"UP"}

Note These endpoints do not generate logs, to save costs.

⁠Custom 404 page

To make use of your own custom 404 page, place a 404.html file in the root of the bucket/

This page will be served for the below errors:

⁠Custom 5xx errors

Currently not supported. If this is required please open an issue.

⁠What ports does the container listen on
IP Stack versionIP addressPort
v6[::]80
v40.0.0.080
⁠Where are the docker images
⁠Building the image locally
docker build -t gcs-web-server:latest .

⁠Example manifest

apiVersion: apps/v1
kind: Deployment
metadata:
  name: gcs-website
spec:
  replicas: 2
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/name: gcs-website
  template:
    metadata:
      labels:
        app.kubernetes.io/name: gcs-website
    spec:
      volumes:
        - name: gcs
          emptyDir: {}
      serviceAccountName: gcs-website
      containers:
        - name: gcs-website
          image: "userbradley/gcs-web-server"
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 80
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /healthz
              port: 80
            initialDelaySeconds: 10
            periodSeconds: 10
          securityContext:
            privileged: true
            capabilities:
              add:
                - SYS_ADMIN
          volumeMounts:
            - mountPath: /var/www/site
              name: gcs
          lifecycle:
            postStart:
              exec:
                command: [ "gcsfuse","--implicit-dirs", "-o", "allow_other", "gcs-bucket-name", "/var/www/site" ]
            preStop:
              exec:
                command: [ "fusermount", "-u", "/var/www/site/" ]

Tag summary

Content type

Image

Digest

sha256:c54fbf052…

Size

21.5 MB

Last updated

over 3 years ago

docker pull userbradley/gcs-web-server