多规则示例
多规则示例
spec:
rules:
- host: www.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: site-www
port:
number: 80
- host: api.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: site-api
port:
number: 8080
- host: "*.static.example.com"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: site-static
port:
number: 80验证
验证
kubectl describe ingress multi-site | grep -E 'Host|Path'
curl -s -H 'Host: api.example.com' http://<入口IP>/health通配只能覆盖一级子域(*.example.com 匹配 a.example.com,不匹配 a.b.example.com)。