I use nginx-ingress-controller:0.24.1 (Inspired by)
I would like to set a DNS A record to LB IP address, so it would connect it to the Google cloud public bucket (my-back-end-bucket
) that has public index.html in the root AND to the back-end by another url rule.
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
By reaching https://my.ip.add.ress/c - got both outputs: Hello, world! bucket content.
"Hello, world!" form the hello-world-service
"bucket content" from the bucket' index.html file
Question: how to make it work so, that by ip/ - I got a bucket content and by ip/c - back-end response content ?
You can split your ingress into two where one defines path: /*
with necessary annotation and another ingress that defines path: /c/
.
The problem with your single ingress is that its annotations that you want to apply to path: /*
only gets applied to other paths as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With