简体   繁体   中英

Pointing to a file in GCP located in Google Storage Buckets

I have a link to a public URL in the format of https://storage.googleapis.com/companyname/foldername/.another-folder/file.txt

I want to create an ingress rule to create a path to this public file, so that whoever open a specific URL, eg, https://myapp.mydomain.com/.another-folder/myfile.txt -> it open up above file.

I tried a few different ingress rules such as:

apiVersion: v1
kind: Service
metadata:
  name: googlestoragebucket
spec:
  externalName: storage.googleapis.com
  ports:
  - name: https
    port: 443
    protocol: TCP
    targetPort: 443
  type: ExternalName
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: staging-ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: staging-static-ip
    kubernetes.io/ingress.class: gce
spec:
  defaultBackend:
    service:
      name: website-frontend
      port:
        number: 80
  rules:
  - host: myapp.mydomain.com
    http:
      paths:
      - path: /.another-folder/
        pathType: Prefix
        backend:
          service:
            name: googlestoragebucket
            port:
              number: 443
       - pathType: ImplementationSpecific
         backend:
          service:
            name: myactual-app
            port:
              number: 80

But I couldn't make it wrok. In this case I've got an error: Translation failed: invalid ingress spec: service "staging/googlestoragebucket" is type "ExternalName", expected "NodePort" or "LoadBalancer

I don't mind any other solutions to achieve the same result in the context of GCP and Kubernetes.

Do you have any ideas?

Looking forward for you suggestions.

Think that you should be able to do it via Cloud External Load Balancer:

Here is some information about that:

https://cloud.google.com/load-balancing/docs/https/ext-load-balancer-backend-buckets

Then you can point the ingress to that load balancer: https://cloud.google.com/kubernetes-engine/docs/how-to/ingress-features

Another option is use some proxy, la Nginx, there is a post on GitHub about this: https://github.com/kubernetes/ingress-nginx/issues/1809

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM