Kubernetes ingress-nginx LoadBalancer指向云桶

问题描述 投票:1回答:1

我用nginx-ingress-controller:0.24.1Inspired by

我想将DNS A记录设置为LB IP地址,因此它会将其连接到Google云公共存储桶(my-back-end-bucket),其在根目录中具有公共index.html并且通过另一个网址规则连接到后端。

kind: Service
apiVersion: v1
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  externalTrafficPolicy: Local
  type: LoadBalancer
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
  ports:
    - name: http
      port: 80
      targetPort: http
    - name: https
      port: 443
      targetPort: https

---

kind: Service
apiVersion: v1
metadata:
  name: google-storage-buckets-service
  namespace: ingress-nginx
spec:
  type: ExternalName
  externalName: storage.googleapis.com

---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: proxy-assets-ingress
  namespace: ingress-nginx
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /my.bucket.com
    nginx.ingress.kubernetes.io/secure-backends: "true"
    nginx.ingress.kubernetes.io/upstream-vhost: "storage.googleapis.com"
spec:
  rules:
    - http:
        paths:
          - path: /*
            backend:
              serviceName: google-storage-buckets-service
              servicePort: 443
          - path: /c/
            backend:
              serviceName: hello-world-service
              servicePort: 8080

通过达到https://my.ip.add.ress/c - 得到两个输出:你好,世界!桶内容。

“你好,世界!”形成你好世界的服务

来自存储桶'index.html文件的“存储桶内容”

问题:如何让它工作,通过ip / - 我有一个桶内容和ip / c - 后端响应内容?

kubernetes load-balancing gcloud nginx-ingress
1个回答
1
投票

您可以将入口拆分为两个,其中一个用必要的注释定义path: /*,另一个定义path: /c/的入口。

单个入口的问题在于,您想要应用于path: /*的注释也只能应用于其他路径。

© www.soinside.com 2019 - 2024. All rights reserved.