是否可以将多个主机添加到Ingress控制器,以便它们引用AWS负载均衡器中的同一目标组?示例:
rules:
- host: ["foobar.com", "api.foobar.com", "status.foobar.com"]
http:
paths:
- backend:
serviceName: foobar
servicePort: 80 ```
答案 0 :(得分:1)
如果您使用的是 Kubernetes > 1.18 版本,则可以使用主机名通配符。
有关更多信息,请查看以下链接:
https://docs.nginx.com/nginx-ingress-controller/configuration/ingress-resources/basic-configuration/ https://kubernetes.io/docs/concepts/services-networking/ingress/
rules:
- host: "foobar.com"
http:
paths:
- backend:
serviceName: foobar
servicePort: 80
- host: "*.foobar.com"
http:
paths:
- backend:
serviceName: foobar
servicePort: 80
答案 1 :(得分:0)
TLDR;否
长答案:
在k8s source code中,您可以看到host
字段的数据类型是字符串,因此您不能在该位置使用字符串数组。
但是您应该能够执行以下操作:
rules:
- host: "foobar.com"
http:
paths:
- backend:
serviceName: foobar
servicePort: 80
- host: "api.foobar.com"
http:
paths:
- backend:
serviceName: foobar
servicePort: 80
- host: "status.foobar.com"
http:
paths:
- backend:
serviceName: foobar
servicePort: 80