准备将 *.cnblogs.com 泛域名转发到 k8s ingress 上,遇到一个问题,如何用一个规则匹配其他规则没有匹配的 host ?
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: cnblogs-ingress
spec:
ingressClassName: nginx
rules:
- host: q.cnblogs.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: q-web
port:
number: 80
# fallback for *.cnblogs.com
通过 defaultBackend
解决了
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: cnblogs-ingress
spec:
ingressClassName: nginx
rules:
- host: q.cnblogs.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: q-web
port:
number: 80
defaultBackend:
service:
name: blog-web
port:
number: 80