我有一个yaml格式的入口文件。我在主机和服务级别上看到了很多重复。我有很多指向service_2的路线。如何减少代码行大小和数量?我只有一个域名xx.com。
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: default
name: ingress
annotations:
acme.cert-manager.io/http01-edit-in-place: "true"
ingress.kubernetes.io/ssl-redirect: "false"
spec:
tls:
- hosts:
- xx.com
secretName: xx
rules:
- host: xx.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: servic_1
port:
number: 3000
- host: xx.com
http:
paths:
- path: /api_2
pathType: Prefix
backend:
service:
name: service_2
port:
number: 8000
- host: xx.com
http:
paths:
- path: /api_3
pathType: Prefix
backend:
service:
name: service_2
port:
number: 8000
可以为一个主机创建多条路径
rules:
- host: xx.com
http:
paths:
- path: /
...
- path: /api_2
...
- path: /api_3
...